c# - MS Chart Control: Drawing and Labeling Line Series Across the Chart Area -



c# - MS Chart Control: Drawing and Labeling Line Series Across the Chart Area -

i have questions ms asp.net chart control.

how can line series set on bar series extends y-axis of chart? is possible place name of line series, i.e. "goal", right of chart replacement including series in legend?

as can see in screenshot below, have line series presenting on top of bar series doesn't extend y-axis of chart.

the code follows:

var data1 = new dictionary<string, float> { { "w1", 80}, { "w2", 60}, { "w3", 40}, { "w4", 20}, { "w5", 10} }; var data2 = new dictionary<string, float> { { "w1", 10}, { "w2", 10}, { "w3", 0}, { "w4", 10}, { "w5", 10} }; var data3 = new dictionary<string, float> { { "w1", 10}, { "w2", 30}, { "w3", 50}, { "w4", 70}, { "w5", 80} }; var data4 = new dictionary<string, float> { { "w1", 50}, { "w2", 50}, { "w3", 50}, { "w4", 50}, { "w5", 50} }; var chart = new chart(); chart.height = unit.pixel(300); chart.width = unit.pixel(450); chart.legends.add("legend").alignment = stringalignment.center; chart.palette = chartcolorpalette.none; chart.palettecustomcolors = new color[] { color.fromargb(191, 214, 151), color.fromargb(249, 255, 149), color.fromargb(191, 79, 75), color.green }; var area = new chartarea(); area.axisx.majorgrid.linecolor = color.transparent; chart.chartareas.add(area); var series1 = new series("done"); foreach (var item in data1) { series1.points.addxy(item.key, item.value); } series1.markerborderwidth = 1; var series2 = new series("in progress"); foreach (var item in data2) { series2.points.addxy(item.key, item.value); } var series3 = new series("needs review"); foreach (var item in data3) { series3.points.addxy(item.key, item.value); } var series4 = new series("goal"); foreach (var item in data4) { series4.points.addxy(item.key, item.value); } series4.charttype = seriescharttype.line; series4.borderwidth = 2; series1.charttype = series2.charttype = series3.charttype = seriescharttype.stackedcolumn; series1.font = series2.font = series3.font = series4.font = new font("verdana", 8.25f, fontstyle.regular); chart.series.add(series1); chart.series.add(series2); chart.series.add(series3); chart.series.add(series4);

thanks help.

update: go on search appropriate solution, implemented additional chart "goal" line series intentions of:

setting color of properties of new chart transparent and laying chart on top of existing chart

this approach provided right presentation displaying "goal" line series on bar series , allowing "goal" line series extend y-axis. disabled tooltips , click actions of bar series on existing chart. due deficient user experience, approach isn't suitable solution.

the search solution continues...

for question 1:

another way utilize postpaint event, can draw wish, anywhere on chart... still lose tooltips , such interactive features line.

for question 2:

you can exclude unwanted legend entry legend item collection; can customize legend done example:

yourchart.customizelegend += new eventhandler<customizelegendeventargs> (customizelegendeventhandler); //... static void customizelegendeventhandler(object sender, customizelegendeventargs e) { int anotherindex = 3; if (sender != null && sender chart) { if (e != null && e.legenditems != null && e.legenditems.count > 0) { chart ch = ((chart)sender); if (...) //your logic here { //example: can move legend item 1 index here: legenditem item = e.legenditems[0]; e.legenditems.removeat(0); e.legenditems.insert(anotherindex, item); } } } }

and, can have secondary y axis 1 label, 1 point, etc. or: can utilize postpaint event handler draw wish.

you can download great installable sample pack ms: here. show many code examples can study. found out these things samples , using new free reflector: ilspy.

hope helps.

c# asp.net charts data-visualization dundas

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -