Reputation: 3383
How to draw rectangular area from the bottom to the top of a MS Chart, starting and ending on specific DateTime.
I succeed to add area from 0 to Max. I add this area before the other series.
chart.Series.Add("Stagnation");
chart.Series["Stagnation"].Points.AddXY(stagnation.StartTime, stagnation.MaxBalance);
chart.Series["Stagnation"].Points.AddXY(stagnation.EndTime, stagnation.MaxBalance);
chart.Series["Stagnation"].ChartType = SeriesChartType.StackedArea;
chart.Series["Stagnation"].Color = Color.FromArgb(100, R, G, B);
Where stagnation.StartTime
and stagnation.EndTime
are DateTime.
Upvotes: 0
Views: 558
Reputation: 6591
I think what you are looking for is called StripLine
which are used as shown below
StripLine sline = new StripLine();
sline.IntervalOffset = <the start point>;
sline.StripWidth = <the duration>;
//sline.Text = "You can set a label";
sline.Interval = 0.0D; // IMPORTANT: prevent repeating striplines
sline.BackColor = Color.AliceBlue;
sline.BorderColor = Color.LightSteelBlue;
Chart.AxisX.StripLines.Add(sline);
By default striplines are designed to be repeated every Interval
but you can define single instances by setting Interval = 0
.
Upvotes: 1