在 MSChart 上的特定 X 值处设置标记
以下是生成图表的代码:
System.Web.UI.DataVisualization.Charting.Chart Chart2 = new System.Web.UI.DataVisualization.Charting.Chart();
Chart2.Width = 350;
Chart2.Height = 350;
Chart2.RenderType = RenderType.ImageTag;
Chart2.Palette = ChartColorPalette.BrightPastel;
Chart2.ChartAreas.Add("Series 1");
Chart2.ChartAreas["Series 1"].BackColor = System.Drawing.Color.Transparent;
// create a couple of series
Chart2.Series.Add("Series");
// databinding
Chart2.DataSource = pointCollection;
Chart2.ChartAreas[0].AxisX.Title = "Date";
Chart2.ChartAreas[0].AxisY.Title = "Future Exposure Amount";
Chart2.Series[0].ChartType = SeriesChartType.Line;
Chart2.Series[0].XValueMember = "ExposureDate";
Chart2.Series[0].XValueType = ChartValueType.Date;
Chart2.Series[0].YValueMembers = "MaximumExposure";
Chart2.BackColor = System.Drawing.Color.FromArgb(211, 223, 240); //"#D3DFF0"
Chart2.BorderSkin.SkinStyle = BorderSkinStyle.Emboss;
Chart2.BackGradientStyle = GradientStyle.TopBottom;
// Render chart control
Chart2.Page = this;
Page.Response.Clear();
HtmlTextWriter writer = new HtmlTextWriter(Page.Response.Output);
Chart2.RenderControl(writer);
在图表上的某个 X 值处设置标记的代码是什么?
Here is the code that generates my chart:
System.Web.UI.DataVisualization.Charting.Chart Chart2 = new System.Web.UI.DataVisualization.Charting.Chart();
Chart2.Width = 350;
Chart2.Height = 350;
Chart2.RenderType = RenderType.ImageTag;
Chart2.Palette = ChartColorPalette.BrightPastel;
Chart2.ChartAreas.Add("Series 1");
Chart2.ChartAreas["Series 1"].BackColor = System.Drawing.Color.Transparent;
// create a couple of series
Chart2.Series.Add("Series");
// databinding
Chart2.DataSource = pointCollection;
Chart2.ChartAreas[0].AxisX.Title = "Date";
Chart2.ChartAreas[0].AxisY.Title = "Future Exposure Amount";
Chart2.Series[0].ChartType = SeriesChartType.Line;
Chart2.Series[0].XValueMember = "ExposureDate";
Chart2.Series[0].XValueType = ChartValueType.Date;
Chart2.Series[0].YValueMembers = "MaximumExposure";
Chart2.BackColor = System.Drawing.Color.FromArgb(211, 223, 240); //"#D3DFF0"
Chart2.BorderSkin.SkinStyle = BorderSkinStyle.Emboss;
Chart2.BackGradientStyle = GradientStyle.TopBottom;
// Render chart control
Chart2.Page = this;
Page.Response.Clear();
HtmlTextWriter writer = new HtmlTextWriter(Page.Response.Output);
Chart2.RenderControl(writer);
What is the code to set a marker at a certain X-Value on the chart?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以逐点设置标记属性,例如,
XValues 将来自您绑定到的数据,即
pointCollection
变量。如果 pointCollection 的“ExposureDate”中有日期,您可能最好直接访问该日期以查找所需的日期,然后使用
to access the
DataPoint
You can set the Marker properties on a point by point basis, e.g.
The XValues will come from the data you bound to, the
pointCollection
variable.If there are dates in the "ExposureDate" of the pointCollection you may be better accessing that directly to find the Date you want, and then using
to access the
DataPoint