添加文本,图像asp.net图表控件 [英] Adding text , image to asp.net chart control
问题描述
我使用asp.net图表控件在我的网站上显示的图表,下面是它的片段:
问题是我想添加文本并在每个点上的箭头线,所以例如在点(60月)我想在这一点上写的文字:预测最高和箭头的形象。
是否有可能acheive这样的事情,任何建议或帮助将是非常美联社preciated,下面是code我已经用于生成此图:
双击[] = yValues {15,60,12,13};
字符串[] = xValues {九月,十月,十一月,十二月};
chart.Width = 500;
chart.Height = 200;
chart.BorderSkin.SkinStyle = BorderSkinStyle.FrameThin1; ChartArea CA =新ChartArea();
ca.Name =默认;
ca.AxisX.LineColor = System.Drawing.ColorTranslator.FromHtml(#FEFEFE);
ca.AxisX.LineWidth = 3;
ca.AxisX.MajorGrid.LineDashStyle = ChartDashStyle.Dash;
ca.AxisX.MajorGrid.Enabled = FALSE;
ca.AxisX.MajorTickMark.LineWidth = 2;
ca.AxisX.LabelStyle.Format =L; ca.AxisY.LineColor = System.Drawing.ColorTranslator.FromHtml(#FEFEFE);
ca.AxisY.LineWidth = 3;
ca.AxisY.MajorGrid.Enabled = TRUE;
ca.AxisY.MajorTickMark.LineWidth = 2;
ca.AxisY.Title =Y轴; chart.ChartAreas.Add(CA); 传奇名宿=新传奇();
chart.Legends.Add(传奇);
系列系列=新系列(系列1);
series.IsValueShownAsLabel = FALSE;
series.MarkerStyle = MarkerStyle.Circle;
series.BorderWidth = 5;
series.ChartType = SeriesChartType.Line; series.ShadowOffset = 2;
series.XValueType = ChartValueType.String;
series.YValueType = ChartValueType.Double;
series.Font =新System.Drawing.Font(投石机MS,8);
series.BorderColor = System.Drawing.ColorTranslator.FromHtml(#33CCFF);
series.Color = System.Drawing.ColorTranslator.FromHtml(#33CCFF); chart.Series.Add(系列);
chart.Series [系列1] Points.DataBindXY(xValues,yValues)。
chart.DataManipulator.InsertEmptyPoints(1,System.Web.UI.DataVisualization.Charting.IntervalType.Days系列1);
您需要搜索最大的数据点,并使用属性
datapoint.Label =投影最高;
突出显示该点
还有最简单的方法是使用 datapoint.MarkerStyle
属性。你可以画一个箭头,但我不认为它值得冒这个险。
I am using asp.net chart control to display chart on my website , below is the snippet of it:
The issue is i want to add the text and an arrow line on each point , so for instance on the point (60,october) I want to write text at this point: projection was highest and an arrow image. Is it possible to acheive something like this, any suggestion or assistance will be highly appreciated, below is the code i have used to generate this chart:
double[] yValues = { 15, 60, 12, 13 };
string[] xValues = { "September", "October", "November", "December" };
chart.Width = 500;
chart.Height = 200;
chart.BorderSkin.SkinStyle = BorderSkinStyle.FrameThin1;
ChartArea ca = new ChartArea();
ca.Name = "Default";
ca.AxisX.LineColor = System.Drawing.ColorTranslator.FromHtml("#FEFEFE");
ca.AxisX.LineWidth = 3;
ca.AxisX.MajorGrid.LineDashStyle = ChartDashStyle.Dash;
ca.AxisX.MajorGrid.Enabled = false;
ca.AxisX.MajorTickMark.LineWidth = 2;
ca.AxisX.LabelStyle.Format = "L";
ca.AxisY.LineColor = System.Drawing.ColorTranslator.FromHtml("#FEFEFE");
ca.AxisY.LineWidth = 3;
ca.AxisY.MajorGrid.Enabled = true;
ca.AxisY.MajorTickMark.LineWidth = 2;
ca.AxisY.Title = "yaxis";
chart.ChartAreas.Add(ca);
Legend legend = new Legend();
chart.Legends.Add(legend);
Series series = new Series("Series1");
series.IsValueShownAsLabel = false;
series.MarkerStyle = MarkerStyle.Circle;
series.BorderWidth = 5;
series.ChartType = SeriesChartType.Line;
series.ShadowOffset = 2;
series.XValueType = ChartValueType.String;
series.YValueType = ChartValueType.Double;
series.Font = new System.Drawing.Font("Trebuchet MS", 8);
series.BorderColor = System.Drawing.ColorTranslator.FromHtml("#33CCFF");
series.Color = System.Drawing.ColorTranslator.FromHtml("#33CCFF");
chart.Series.Add(series);
chart.Series["Series1"].Points.DataBindXY(xValues, yValues);
chart.DataManipulator.InsertEmptyPoints(1, System.Web.UI.DataVisualization.Charting.IntervalType.Days, "Series1");
You need to search for the largest data point and use property
datapoint.Label = "projection was highest";
Also easiest way to highlight the point is to use datapoint.MarkerStyle
property. You can draw an arrow but I dont think its worth the hassle.
这篇关于添加文本,图像asp.net图表控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!