Reputation: 554
I'm looking to fill a c# chart with multiple backcolours in relation to timestamp.
Does anyone know of any code to do this or perhaps a method to implement the equivalent.
I thought about adding semi-transparent columns with appropriate widths but this seems a bit messy.
Any insight and ideas would be appreciated.
Upvotes: 0
Views: 107
Reputation: 13960
This might be useful to you
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); } }
Upvotes: 0
Reputation: 3837
If you are using mschart
Use a timer
Every tick event, set back color
to color you want
Upvotes: 1