in wpf application, have following query display selected date range 'date' , total number of servers being processed on each day 'amount'.
var query_1 = (this.db.servers .where(a => (a.date >= fromdp.selecteddate.value && a.date <= todp.selecteddate.value) && ((a.serverid == "serverid1" || a.serverid == "serverid2") && a.type == "complete")) .groupby(a => entityfunctions.truncatetime(a.date)) .orderby(a => a.key) .select(g => new { date = g.key, amount = g.count() })) .tolist();
which returns output following when bind listbox's itemssource ( check whether query works correctly)
now how bind result, date , amount wpf chart x , y axis. ( x- axis date , y-axis amount).
the chart can either bubble series/line series or column series.
this blogpost may have need.
http://www.itdevspace.com/2010/09/wpf-toolkit-datagrid-chart-example.html
basically place information retrieve linq query collection list have (the example in blog post above uses , observablecollection notification purposes) , chart itemsource property collection, independentvalue date, , dependentvalue amount.
<charting:lineseries itemssource="{binding path=data}" independentvaluebinding="{binding date}" dependentvaluebinding="{binding amount}"/>
i haven't tried on anonymous types may need change query logic more explicit. above xaml code expects datacontext have collection name data containing items properties date , amount.
Comments
Post a Comment