i'm stuck now.
i have code reads database amount of calls per hour, when come time mapping them graph, nothing shows...
how map using following command: ls.itemssource = enumerable.range(0, counter).select(k => new keyvaluepair<int, int>(callhour[k], callcounter[k])).toarray();
here code:
xaml:
<dvc:chart name="chart" background="#463f3f"> <dvc:chart.plotareastyle> <style targettype="grid"> <setter property="background" value="transparent" /> </style> </dvc:chart.plotareastyle> </dvc:chart>
c#:
using system; using system.collections.generic; using system.linq; using system.windows; using system.data; using system.data.sqlclient; using system.windows.data; using system.windows.controls.datavisualization.charting; namespace wpfapplication1 { /// <summary> /// interaction logic mainwindow.xaml /// </summary> public partial class mainwindow : window { public mainwindow() { initializecomponent(); allagenthourdata(); } private void allagenthourdata() { string[] qid = new string[100]; int[] callhour = new int[100]; int[] callcounter = new int[100]; int qcounter = 0; //int counter = 0; sqlconnection sqlconnection1 = new sqlconnection("server=nl-reportserver;database=rc_dailer_wh;user id=sa;password=<password>"); sqlcommand cmd = new sqlcommand(); sqldatareader reader; sqlconnection1.open(); //cmd.commandtext = "select distinct queueid rc_call_logs order queueid"; cmd.commandtext = "select convert(date, starttime, 120) calldate, queueid, datepart(hour,convert(datetime,starttime,111)) chour, count(id) numberofcalls rc_call_logs convert(date,starttime,120) = convert(date,getdate(),120) , queueid = 17000 group convert(date, starttime, 120), datepart(hour,convert(datetime,starttime,111)), queueid order calldate, queueid, chour"; cmd.commandtype = commandtype.text; cmd.connection = sqlconnection1; reader = cmd.executereader(); if (reader.hasrows) { while (reader.read()) { callhour[qcounter] = reader.getint32(2); callcounter[qcounter] = reader.getint32(3); qcounter++; } } else { messagebox.show("no error message"); } reader.close(); sqlconnection1.close(); lineseries ls = new lineseries(); ls.title = "17000"; ls.independentvaluebinding = new binding("key"); ls.dependentvaluebinding = new binding("value"); ls.itemssource = enumerable.range(0, qcounter).select(i=> new keyvaluepair<int, int>(callhour[i], callcounter[i])).toarray(); } } }
you need add line series chart
chart.series.add(ls);
Comments
Post a Comment