【问题标题】:TeeChart WPF Histogram color of binsTeeChart WPF 柱状图颜色
【发布时间】:2013-03-26 15:51:29
【问题描述】:

我正在使用 TeeChart 和直方图系列来显示数据。 我想根据值单独为垃圾箱着色,但我发现的只是为每个垃圾箱着色的选项。我希望显示相同值的箱具有相同的颜色。 TeeChart 可以吗?

【问题讨论】:

    标签: wpf histogram teechart


    【解决方案1】:

    是的,这是可能的。您可以使用适当的 Add 方法覆盖或使用 BeforeDrawPoint 事件在填充系列时提供颜色值,如下所示:

    public Form1()
    {
      InitializeComponent();
      InitializeChart();
    }
    
    private void InitializeChart()
    {
      tChart1.Aspect.View3D = false;
    
      Histogram histogram1 = new Histogram(tChart1.Chart);
    
      histogram1.LinePen.Visible = false;
      histogram1.LinesPen.Visible = false;
    
      for (int i = 0; i < 20; i++)
      {
        histogram1.Add(i);
      }
    
      histogram1.BeforeDrawPoint += histogram1_BeforeDrawPoint;
    }
    
    void histogram1_BeforeDrawPoint(Series series, BeforeDrawPointEventArgs e)
    {
      series.Colors[e.ValueIndex] = (series.YValues[e.ValueIndex] > 10) ? Color.Red : Color.Blue;
    }
    

    【讨论】:

    • 带有颜色参数的 Add 方法正是我想要的。谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多