sla*_*dau 2 .net mschart marker
以下是生成我的图表的代码:
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);
Run Code Online (Sandbox Code Playgroud)
在图表上的某个X值上设置标记的代码是什么?
您可以逐点设置标记属性,例如
double interestingValue = 12.34;
foreach (var pt in Chart2.Series[0].Points)
{
if (pt.XValue == interestingValue)
{
pt.MarkerColor = System.Drawing.Color.Red;
pt.MarkerSize = 5;
pt.MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Circle;
}
}
Run Code Online (Sandbox Code Playgroud)
XValues将来自您绑定的数据,即pointCollection变量.
如果pointCollection的"ExposureDate"中有日期,您可能更好地直接访问它以找到您想要的日期,然后使用
var pt = Chart2.Series[0].Points[interestingIndex];
访问 DataPoint
| 归档时间: |
|
| 查看次数: |
8050 次 |
| 最近记录: |