I have a method that creates a series in a chart and plots 1 pair of x and y coordinates, although I am unable to add more than one pair of points / coordinates:
private void button1_Click(object sender, EventArgs e)
{
// Set palette.
this.chart2.Palette = ChartColorPalette.SeaGreen;
// Set title.
this.chart2.Titles.Add("Test Chart");
// Add series and points
chart2.Series.Add("RAM").Points.AddXY(22,23);
If I try adding something like:
chart2.Points.AddXY(22,23);
I get the following message:
The type or namespace name 'Points' does not exist in the namespace 'Chart2
The error tells you that Points is not a member of chart2. I think you need to try:
chart2.Series["seriesname"].Points.AddXY(22,23).
Refer to this post for an example on how to add a series of points at once:
Adding a series of points to a chart
Edit: You need to know the seriesname which should be in your aspx page as something like this:
<asp:Chart ID="Chart1" runat="server">
<Series>
<asp:Series Name="Series1">
</asp:Series>
</Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1">
</asp:ChartArea>
</ChartAreas>
</asp:Chart>
series[0] may also work.
My suggestion would be to create a "SeriesCollection" and add that collection to the Chart Series something like below:
chart2.Series.Add(<SeriesCollection>);
Hope this Helps!!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.