回复 1楼781504429的帖子
781504429 你好,
不好意思,让你久等了,可以通过 OverridesDefaultStyle 实现无数据时消除边框,测试代码如下:
- public MainWindow()
- {
- InitializeComponent();
- chart1.Data.Children.Clear();
- //Create dummy data
- chart1.Data.Children.Clear();
- //Create dummy data
- List<Point> points = new List<Point>();
- points.Add(new Point(0, 20));
- points.Add(new Point(1, 22));
- points.Add(new Point(2, 19));
- points.Add(new Point(3, 24));
- points.Add(new Point(4, 29));
- points.Add(new Point(5, 7));
- points.Add(new Point(6, 12));
- points.Add(new Point(7, 15));
- //Setup C1Chart data series
- XYDataSeries ds = new XYDataSeries();
- ds.ChartType = ChartType.Line;
- ds.PointTooltipTemplate = (DataTemplate)Resources["StaticResource dotTT"];
- ds.Label = "Series 1";
- //Bind data series to collection
- ds.ItemsSource = points;
- //Important to set binding when using ItemsSource
- ds.ValueBinding = new Binding("Y");
- ds.XValueBinding = new Binding("X");
- //Add data series to chart
- chart1.Data.Children.Add(ds);
- if (chart1.Data.Children.Count!=0)
- {
- chart1.OverridesDefaultStyle = false;
- }
- else
- {
- chart1.OverridesDefaultStyle = true;
- }
- }
复制代码 |