c# - Line chart with two series based on single column values -


i want build line chart based on table: 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

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -