c# - How can I change Windows Forms Chart control data? -
this code i'm using now:
private void button1_click(object sender, eventargs e) { random rdn = new random(); (int = 116; > 0; i--) { chart1.series["series1"].points.addxy (rdn.next(0, 10), rdn.next(0, 10)); } chart1.series["series1"].charttype = seriescharttype.fastline; chart1.series["series1"].color = color.red; chart1.series["series1"].charttype = seriescharttype.fastline; }
what is:
but want change it.
on left side instead numbers 0 10 see numbers 1 116 , on bottom instead -1 10 see 1 30.
and draw line starting @ 116 until 1 according 1 30. example in 1 it's 116 in 2 105 100…it's testing can random or straight line 116 30.
but want know how use how draw line starting 116 , moving down according 1 30.
it not entirely clear me trying do. how interpreted question:
on left side instead numbers 0 10 see numbers 1 116 , on bottom instead -1 10 see 1 30.
i take mean change range of each axis, such x axis starts @ 1 , ends @ 30, , y axis starts @ 1, , ends @ 116.
but want know how use how draw line starting 116 , moving down according 1 30.
i take mean that, in addition actual data series (i.e. random points drawn xy scatter graph, in example), line overlaid on chart area, line starts @ graph coordinate of (1, 116) , connects graph coordinate of (30, 1).
with in mind, here original code additions accomplish above:
private void button1_click(object sender, eventargs e) { random rdn = new random(); (int = 116; > 0; i--) { chart1.series["series1"].points.addxy (rdn.next(0, 10), rdn.next(0, 10)); } chart1.series["series1"].charttype = seriescharttype.fastline; chart1.series["series1"].color = color.red; chartarea area = chart1.chartareas[0]; // set min , max each axis area.axisx.minimum = 1; area.axisx.maximum = 30; area.axisy.minimum = 1; area.axisy.maximum = 116; // add line on top of chart lineannotation line = new lineannotation(); chart1.annotations.add(line); // set annotation positioning relative x , y axes line.axisx = area.axisx; line.axisy = area.axisy; // set actual annotation position , boundary. disable // issizealwaysrelative annotation's size // determined absolute positioning of boundary. line.issizealwaysrelative = false; line.x = 1; line.y = 116; line.right = 30; line.bottom = 1; // format line shows better line.linecolor = color.blue; line.linewidth = 3; }
that results in chart looks this:
(i didn't change range on random number generation, had set select random integer points between 0 , 10 both x , y coordinates, data series of course clustered in lower left of chart).
Comments
Post a Comment