wpf - C# chart adding data in a for-int loop -


i need one, have created chart in wpf, , in c# have following:

((columnseries)calllogs.series[0]).itemssource =   new keyvaluepair<string, int>[]{        for(int i=0; i<counter; i++)       {         new keyvaluepair<string, int>(callhour[i], callcounter[i])       } }; 

now above statement doesn't work.

the variables callhour , callcounter arrays pull needed data database , work fine, need way of adding data graph amount of values stored in array, if makes sense?

in other words instead of using method:

((columnseries)calllogs.series[0]).itemssource =   new keyvaluepair<string, int>[]{     new keyvaluepair<string, int>(callhour[0], callcounter[0]),     new keyvaluepair<string, int>(callhour[1], callcounter[1]),     new keyvaluepair<string, int>(callhour[2], callcounter[2]),     new keyvaluepair<string, int>(callhour[3], callcounter[3]),     new keyvaluepair<string, int>(callhour[4], callcounter[4]),     new keyvaluepair<string, int>(callhour[5], callcounter[5]),     ...}; 

thanks in advance

if have not found solution, create array of keyvaluepair object first , assign itemsource:

 var items = new keyvaluepair<string, int>[counter];         for(var = 0; < counter; i++)         {             items[i] = new keyvaluepair<string, int>(callhour[i], callcounter[i]);         };  (columnseries)calllogs.series[0]).itemssource = items; 

Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -