[英]Ploting points on the Chart Control
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: 我有一种在图表中创建序列并绘制1对x和y坐标的方法,尽管我无法添加多于一对的点/坐标:
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
类型或名称空间名称“ Points”在名称空间“ Chart2”中不存在
The error tells you that Points is not a member of chart2. 该错误告诉您Points不是chart2的成员。 I think you need to try:
我认为您需要尝试:
chart2.Series["seriesname"].Points.AddXY(22,23). 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: 编辑:您需要知道应该在aspx页面中的序列名称,如下所示:
<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. series [0]也可能有效。
My suggestion would be to create a "SeriesCollection" and add that collection to the Chart Series something like below: 我的建议是创建一个“ SeriesCollection”,然后将该集合添加到Chart Series中,如下所示:
chart2.Series.Add(<SeriesCollection>);
Hope this Helps!! 希望这可以帮助!!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.