回复 1楼kyb11111的帖子
通过DataSeries.Visibility属性设置为false隐藏掉该线。
代码参考:
- XYDataSeries d1= this.c1Chart1.Data.Children[0] as XYDataSeries;
- d1.MouseLeftButtonUp += new MouseButtonEventHandler(d1_MouseLeftButtonUp);
复制代码
事件代码:
- void d1_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
- {
- XYDataSeries ds = sender as XYDataSeries;
- ds.Visibility = System.Windows.Visibility.Hidden;
-
- }
复制代码
Legend里显示的S1颜色和线的颜色保持一致,所以需要将线的颜色设置为灰色。
参考代码:- Brush[] customBrushes = new Brush[2] { Brushes.Gray, Brushes.Blue};
- c1Chart1.CustomPalette = customBrushes;
复制代码 |