c# - Get data from DataGridView to Chart -


i need data single datagridview 3 distinct charts, each column chart. first time i'm working charts, i've researched bit them couldn't find me specific problem.

here follows screenshot of datagridview , charts like, respective legends:

datagridview , charts

what need (at least in theory) simple thing. in "sanity" chart need value located @ table[0, 0] sanitychart.series[0] 'y' value, , on. same thing "unit" , "issues db". appreciated.

from way asked question , image have shown believe want this:

enter image description here

i use 1 chart , have added 1 series each of columns.

after setting chart have added 1 data point each row in table each of series/columns..:

// setting datagridview table.rows.clear(); table.columns.clear(); table.columns.add("state", ""); table.columns.add("sanity", "sanity"); table.columns.add("unit", "unit"); table.columns.add("issuesdb", "issues db"); // filling in data table.rows.add("all passed", 86, 21, 2); table.rows.add("failed", 7, 0, 1); table.rows.add("cancelled", 0, 0, 0);  // can set chart: list<color> colors = new list<color>{color.green, color.red, color.black};  chart1.series.clear();  (int = 0 ; < table.rows.count; i++) {     series s = chart1.series.add(table[0, i].value.tostring());     s.charttype = seriescharttype.column;     s.color = colors[i]; }  // , fill in values dgv chart: (int = 0 ; < table.rows.count; i++) {    (int j = 1 ; j < table.columns.count; j++)    {       int p = chart1.series[i].points.addxy(table.columns[j].headertext, table[j, i].value);    } } 

note have chosen add datapoints addxy overload , decided want make life little easier adding x-values strings. internally still transformed doubles , have value of 0! not problem here, important understand didn't use valid numbers , therefore can't treat them numbers! advantage axis labels being set column headers without further work..


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

android - CollapsingToolbarLayout: position the ExpandedText programmatically -

Listeners to visualise results of load test in JMeter -