Thursday, 15 May 2014

c# - How to conditionally add data points to a chart rendered with MSChart -



c# - How to conditionally add data points to a chart rendered with MSChart -

i have sample code below, renders mschart in windows forms application, here chart looks like:

i add together code conditionally add together info points bars, if bar short info point not added, if bar long enough, datapoint added. in image of chart, first info point (10) not displayed in chart, rest of info points displayed. can help this?

chart1.chartareas.add(new chartarea()); chart1.series[0].isvalueshownaslabel = true; int[] dataset = { 10, 40, 100, 600, 300 }; foreach (var in dataset) { var series1 = chart1.series[0]; series1.charttype = seriescharttype.stackedbar; var index1 = series1.points.addy(i); }

i found able create conditionally create labels transparent code this:

chart1.chartareas.add(new chartarea()); chart1.series[0].isvalueshownaslabel = true; int[] dataset = { 10, 40, 100, 600, 300 }; var series1 = chart1.series[0]; foreach (var in dataset) { series1.charttype = seriescharttype.stackedbar; var index1 = series1.points.addy(i); } int j = 0; foreach (var point in series1.points) { if (dataset[j] > 20) { point.labelforecolor = color.black; } else { point.labelforecolor = color.transparent; } j++; }

c# mschart

No comments:

Post a Comment