c# - Line chart with two series based on single column values -
i want build line chart based on table:
each different kpiname
has own line on chart.
how should this?
tried this:
foreach (kpi_pg kpi in _pg.kpi_pg) { series currentpg = new series(kpi.kpiname); chrt_pgbyyear.series.add(currentpg); currentpg.charttype = seriescharttype.line; currentpg.borderwidth = 3; currentpg.xvaluetype = chartvaluetype.string; currentpg.xvaluemember = "year"; currentpg.yvaluetype = chartvaluetype.int32; currentpg.yvaluemembers = "value"; }
but doesn't work because of same chart name.
series names must unique. should check if series exists , if don't add it. otherwise add series.
private void createnewseries(string seriesname) { if(chrt_pgbyyear.series.isuniquename(seriesname)) { series currentpg = chrt_pgbyyear.series.add(seriesname); currentpg.charttype = seriescharttype.line; currentpg.borderwidth = 3; currentpg.xvaluetype = chartvaluetype.string; currentpg.xvaluemember = "year"; currentpg.yvaluetype = chartvaluetype.int32; currentpg.yvaluemembers = "value"; } }
then use like:
foreach (kpi_pg kpi in _pg.kpi_pg) { createnewseries(kpi.kpiname); }
Comments
Post a Comment