1

我正在使用 asp.net 图表控件在我的网站上显示图表,下面是它的片段: 折线图

问题是我想在每个点上添加文本和箭头线,例如在点(10 月 60 日)我想在这一点上写文本:投影最高和箭头图像。是否有可能实现这样的目标,任何建议或帮助将不胜感激,以下是我用来生成此图表的代码:

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");
4

1 回答 1

3

您需要搜索最大的数据点并使用属性

datapoint.Label = "projection was highest";

突出这一点的最简单方法是使用datapoint.MarkerStyle属性。你可以画一个箭头,但我认为它不值得麻烦。

于 2012-08-09T14:57:12.643 回答