I have a bar chart that has items overlapping - how do I center these overlapped bars
The code below aligns all the items to the left.
Overlapping is 100% but the additional stacked bars have had their widths reduced to half the width of the main series column. Please view the attached chart to see what I am attempting to achieve.
Dim oTargetSeries As New ChartSeries("Target")
Dim oAchievementSeries As New ChartSeries("Target Achievement")
Dim oVarianceAccSeries As New ChartSeries("Variance - Accessories")
Dim oVariancePartsSeries As New ChartSeries("Variance - Parts")
With oTargetSeries
.Clear()
.Appearance.FillStyle.FillType = FillType.Solid
.Appearance.FillStyle.MainColor = Color.Black
.Type = ChartSeriesType.Line
.YAxisType = ChartYAxisType.Primary
.Appearance.LabelAppearance.Visible = False
End With
With oAchievementSeries
.Clear()
.Appearance.FillStyle.FillType = FillType.Solid
.Appearance.FillStyle.MainColor = Color.Green
.Type = ChartSeriesType.Bar
.YAxisType = ChartYAxisType.Primary
.Appearance.LabelAppearance.Visible = False
End With
With oVarianceAccSeries
.Clear()
.Appearance.FillStyle.FillType = FillType.Solid
.Appearance.FillStyle.MainColor = Color.Yellow
.Type = ChartSeriesType.StackedBar
.YAxisType = ChartYAxisType.Secondary
.Appearance.BarWidthPercent = 50
End With
With oVariancePartsSeries
.Clear()
.Appearance.FillStyle.FillType = FillType.Solid
.Appearance.FillStyle.MainColor = Color.Blue
.Type = ChartSeriesType.StackedBar
.YAxisType = ChartYAxisType.Secondary
.Appearance.BarWidthPercent = 50
End With
oChart.Appearance.BarOverlapPercent = 100
With oChart
.PlotArea.Appearance.FillStyle.FillType = FillType.Solid
.PlotArea.Appearance.FillStyle.MainColor = Color.White
.IntelligentLabelsEnabled = False
.PlotArea.XAxis.AutoScale = False
.PlotArea.XAxis.IsZeroBased = False
.PlotArea.XAxis.Visible = False
.PlotArea.XAxis.AxisLabel.Visible = True
.PlotArea.XAxis.Appearance.LabelAppearance.RotationAngle = 320
.PlotArea.XAxis.Appearance.Width = 3
.PlotArea.XAxis.LayoutMode = ChartAxisLayoutMode.Between
.PlotArea.YAxis.AutoScale = False
.PlotArea.YAxis2.AutoScale = False
.PlotArea.YAxis.Appearance.Width = 3
.PlotArea.YAxis.MaxValue = 200
.PlotArea.YAxis.MinValue = 0
.PlotArea.YAxis.Step = 20
.PlotArea.YAxis2.Appearance.Width = 3
.PlotArea.YAxis2.MaxValue = 200
.PlotArea.YAxis2.MinValue = -200
.PlotArea.YAxis2.Step = 50
.PlotArea.XAxis.Clear()
For Each oItem As clsRptPerformanceVsTarget In oRptPerformanceVsTargetList
Dim oChartAxisItem As New ChartAxisItem
oChartAxisItem.TextBlock.Text = oItem.CICode
.PlotArea.XAxis.Items.Add(oChartAxisItem)
Next
End With
For Each oItem As clsRptPerformanceVsTarget In oRptPerformanceVsTargetList
Dim oTargetItem As New ChartSeriesItem()
Dim oAchievementItem As New ChartSeriesItem()
Dim oVarianceAccItem As New ChartSeriesItem()
Dim oVariancePartsItem As New ChartSeriesItem()
With oTargetItem
.YValue = oItem.Target
End With
With oAchievementItem
.YValue = oItem.TargetAchievement
'.Name = oItem.CICode
End With
With oVarianceAccItem
.YValue = oItem.VarianceAccessories
End With
With oVariancePartsItem
.YValue = oItem.VarianceParts
End With
oTargetSeries.Items.Add(oTargetItem)
oAchievementSeries.Items.Add(oAchievementItem)
oVarianceAccSeries.Items.Add(oVarianceAccItem)
oVariancePartsSeries.Items.Add(oVariancePartsItem)
Next
With oChart
.Series.Add(oTargetSeries)
.Series.Add(oAchievementSeries)
.Series.Add(oVarianceAccSeries)
.Series.Add(oVariancePartsSeries)
End With