当前位置: 代码迷 >> .NET报表 >> 怎样为微软winform中的chart控件添加Annotations注解,小弟我的代码错在哪
  详细解决方案

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

热度:5900   发布时间:2013-02-25 00:00:00.0
怎样为微软winform中的chart控件添加Annotations注解,我的代码错在哪
本帖最后由 SCAUSCNU 于 2013-01-21 23:45:30 编辑
网上资料说
Annotations注解集合
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
  相关解决方案