首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

怎样为微软winform中的chart控件添加Annotations注解,小弟我的代码错在哪

2013-02-24 
怎样为微软winform中的chart控件添加Annotations注解,我的代码错在哪 一个图形上可以拥有多个注解对象,可

怎样为微软winform中的chart控件添加Annotations注解,我的代码错在哪

 
一个图形上可以拥有多个注解对象,可以添加十多种图形样式的注解对象,包括常见的箭头、云朵、矩行、图片等等注解符号,通过各个注解对象的属性,可以方便的设置注解对象的放置位置、呈现的颜色、大小、文字内容样式等常见的属性。


我的代码:

   
 chart1.Series.ElementAt(0).LegendText = "日期数量";
            chart1.ChartAreas[0].AxisX.LabelStyle.Format = "MM-dd HH" + "时";
            chart1.Series[0].XValueType = ChartValueType.DateTime;
            chart1.Series.ElementAt(0).ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
            foreach (var item in Data)
            {
                DataPoint dp = new DataPoint();
                dp.SetValueXY(item.Key, item.Value);
                chart1.Series.ElementAt(0).Points.Add(dp);
            }

然后这里写了注释,但是不起作用请问怎么改啊
 LineAnnotation a = new LineAnnotation();
          a.Name = "lineAnnotation";
            a.ToolTip = "放批注";
            a.X = 1;
            a.Y = 1;
            a.Visible = true;
            chart1.Annotations.Add(a);
            //放批注
            chart1.Annotations[0].AnchorDataPoint = chart1.Series[0].Points[1];


我是画一条线,然后再线上的第二个点添加注解


[解决办法]
注解框不能用LineAnnotation

热点排行