c# - Invoking a plot method in Point Collection class -
i'm trying plot data using window form, invoking delegate, plotted xy graph using button fire/initiate event (see code below).
i don't understand why code works plotting xy points doesn't work when want plot y points solely.
what mean plotting y solely i.e. x = 0 , 1, ,2, 3, 4, incrementing 1 or in general fixed increment , can 0.1 or 0.01 , or anything. y passed in user.
using system.windows.forms; using system.windows.forms.datavisualization.charting; namespace plottingsomedata { public partial class form1 : form { public form1() { initializecomponent(); } // delegate private delegate int plotxydelegate(double x, double y); // parameter chart, series of chart, x,y values of graph private void plotxyappend(chart chart, series dataseries, double x, double y) { // invoke delegate passing in add points method in point collection object chart.invoke(new plotxydelegate(dataseries.points.addxy), new object[] { x, y }); } double[] x = { 1, 2, 3, 4, 5, 6 }; double[] y = { 1, 2, 3, 4, 5, 6 }; private void button2_click(object sender, eventargs e) { (int = 0; < x.length || < y.length; i++) { plotxyappend(this.chart2, this.chart2.series[0], x[i], y[i]); } } //up line... code below doesn't work. private delegate int plotydelegate(double x, double y); private void plotyappend(chart chart, series dataseries, double y) { // same here fails... adding single y value. // there error invoking line. don't know problem is. chart.invoke(new plotydelegate(dataseries.points.addy), new object[] { y }); } } }
error: no overload 'addy' matches delegate 'plotsomedata.form1.plotydelegate sorry program work, need add button , chart toolbox .
Comments
Post a Comment