具有多个BackColours的图表c#

时间:2014-04-18 08:59:00

标签: c# .net charts

我希望用时间戳填充多个背景颜色的c#图表。

有没有人知道要执行此操作的任何代码,或者可能是实现等效代码的方法。

我考虑添加具有适当宽度的半透明列,但这看起来有点混乱。

任何见解和想法都将受到赞赏。

2 个答案:

答案 0 :(得分:1)

如果您使用mschart

  1. 使用计时器

  2. 每个tick事件,将back color设为color you want

答案 1 :(得分:0)

这可能对您有用

       foreach (Series charts in chart1.Series)
        {
            foreach (DataPoint point in charts.Points)
            {
                if (point.AxisLabel == LibereStr)
                {
                    point.Color = Color.Green;
                    point.Font = new Font("Trebuchet MS", 9, FontStyle.Bold);
                    if (Libere == 0)
                    {
                        point.IsEmpty = true;
                    }
                }
                else if (point.AxisLabel == OccupateStr)
                {
                    point.Color = Color.Red;
                    point.Font = new Font("Trebuchet MS", 9, FontStyle.Bold);
                    if (Occupate == 0)
                    {
                        point.IsEmpty = true;
                    }
                }
                else if (point.AxisLabel == PrenotateStr)
                {
                    point.Color = Color.Violet;
                    point.Font = new Font("Trebuchet MS", 9, FontStyle.Bold);
                    if (Prenotate == 0)
                    {
                        point.IsEmpty = true;
                    }
                }
                point.Label = string.Format("{0:0} - {1}", point.YValues[0], point.AxisLabel);
            }
        }