找回密码
 立即注册

QQ登录

只需一步,快速开始

781504429

注册会员

10

主题

36

帖子

102

积分

注册会员

积分
102

活字格认证

781504429
注册会员   /  发表于:2013-9-12 14:58  /   查看:4812  /  回复:3
在 Chart控件无数据时,左面和下面会显示两条线,请问如何去掉?

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x

3 个回复

倒序浏览
iceman
社区贡献组   /  发表于:2013-9-12 19:32:00
沙发
回复 1楼781504429的帖子

781504429 你好,

不好意思,让你久等了,可以通过 OverridesDefaultStyle 实现无数据时消除边框,测试代码如下:

  1. public MainWindow()
  2.         {
  3.             InitializeComponent();

  4.             chart1.Data.Children.Clear();

  5.             //Create dummy data
  6.             chart1.Data.Children.Clear();

  7.             //Create dummy data
  8.             List<Point> points = new List<Point>();
  9.             points.Add(new Point(0, 20));
  10.             points.Add(new Point(1, 22));
  11.             points.Add(new Point(2, 19));
  12.             points.Add(new Point(3, 24));
  13.             points.Add(new Point(4, 29));
  14.             points.Add(new Point(5, 7));
  15.             points.Add(new Point(6, 12));
  16.             points.Add(new Point(7, 15));

  17.             //Setup C1Chart data series
  18.             XYDataSeries ds = new XYDataSeries();
  19.             ds.ChartType = ChartType.Line;
  20.             ds.PointTooltipTemplate = (DataTemplate)Resources["StaticResource dotTT"];
  21.             ds.Label = "Series 1";
  22.             //Bind data series to collection
  23.             ds.ItemsSource = points;
  24.             //Important to set binding when using ItemsSource
  25.             ds.ValueBinding = new Binding("Y");
  26.             ds.XValueBinding = new Binding("X");
  27.             //Add data series to chart
  28.             chart1.Data.Children.Add(ds);

  29.             if (chart1.Data.Children.Count!=0)
  30.             {
  31.                 chart1.OverridesDefaultStyle = false;
  32.             }
  33.             else
  34.             {
  35.                 chart1.OverridesDefaultStyle = true;
  36.             }
  37.         }
复制代码
回复 使用道具 举报
781504429
注册会员   /  发表于:2013-9-16 08:43:00
板凳
回复 2楼iceman的帖子

没事,我这几天出差了,今天才看到,谢谢
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2013-9-16 09:04:00
地板
回复 3楼781504429的帖子

好的,不客气,有问题欢迎开新帖提问。
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部