In chart below I had to use 2 category axes to get a trend line to appear in the same zone.
The only problem is that the line series is being drawn behind the stacked bars. I've tried adding axes in the opposite order, added the line series first, then after all the bar series. No difference.
I thought then maybe I could make the pale coloured bars translucent, but the CreateRenderer event isn't being called, I even tested that in a new project, so I gave up on that idea.
Another problem is that I've set the chart to showgrid = true. That's not being shown either.
Can somebody help please?
private void CreateChartComponents()
{
#region Code
try
{
_categoricalAxis1 = new Telerik.WinControls.UI.CategoricalAxis();
_categoricalAxis2 = new Telerik.WinControls.UI.CategoricalAxis();
_linearAxis1 = new Telerik.WinControls.UI.LinearAxis();
_categoricalAxis1.IsPrimary = true;
_categoricalAxis2.IsPrimary = true;
_categoricalAxis1.ShowLabels = false;
_categoricalAxis2.ShowLabels = false;
_categoricalAxis2.IsVisible = false;
_linearAxis1.AxisType = Telerik.Charting.AxisType.Second;
_linearAxis1.IsPrimary = true;
chart.Axes.Clear();
chart.Axes.AddRange(_categoricalAxis1, _linearAxis1, _categoricalAxis2);
_barSeriesNormal = new Telerik.WinControls.UI.BarSeries();
_barSeriesUnder = new Telerik.WinControls.UI.BarSeries();
_barSeriesOver = new Telerik.WinControls.UI.BarSeries();
_lineSeriesTrend = new Telerik.WinControls.UI.LineSeries();
_barSeriesNormal.HorizontalAxis = _categoricalAxis1;
_barSeriesUnder.HorizontalAxis = _categoricalAxis1;
_barSeriesOver.HorizontalAxis = _categoricalAxis1;
_lineSeriesTrend.HorizontalAxis = _categoricalAxis2;
_barSeriesNormal.VerticalAxis = _linearAxis1;
_barSeriesUnder.VerticalAxis = _linearAxis1;
_barSeriesOver.VerticalAxis = _linearAxis1;
_lineSeriesTrend.VerticalAxis = _linearAxis1;
_barSeriesNormal.CombineMode = Telerik.Charting.ChartSeriesCombineMode.Stack;
_barSeriesUnder.CombineMode = Telerik.Charting.ChartSeriesCombineMode.Stack;
_barSeriesOver.CombineMode = Telerik.Charting.ChartSeriesCombineMode.Stack;
var seriesColor = Color.FromArgb(68, 102, 163);
var trendColor = Color.Blue;
_barSeriesUnder.BackColor = Color.AliceBlue;
_barSeriesUnder.BorderColor = Color.AliceBlue;
_barSeriesUnder.LegendTitle = "Under Performance";
_barSeriesOver.BorderColor = seriesColor;
_barSeriesOver.BackColor = seriesColor;
_barSeriesOver.Shape = customShape1;
_barSeriesOver.LegendTitle = "Over Performance";
_barSeriesNormal.BorderColor = seriesColor;
_barSeriesNormal.BackColor = seriesColor;
_barSeriesNormal.LegendTitle = "Expected Performance";
_lineSeriesTrend.BorderColor = trendColor;
_lineSeriesTrend.BackColor = trendColor;
_lineSeriesTrend.LegendTitle = "Trend";
chart.Series.AddRange(_barSeriesNormal, _barSeriesUnder, _barSeriesOver, _lineSeriesTrend);
chart.ShowGrid = true;
}
catch (Exception err)
{
Log4Net.Log.Error(err);
throw;
}
#endregion
}// function