Skip to main content Skip to footer

ActiveReports7: Plotting Negative and Positive Values in 2D Bar Chart

Users often want to display both positive and negative values on the Bar chart and require the bars to be plotted on either side of the X Axis depending on whether the Y value is positive or negative. This can be achieved by setting the P**osition property of the X Axis to 0. This results in X Axis to be plotted from the position where Y value is 0. However, this causes the X Axis labels to follow the Axis and are displayed inside the chart. Hence to make it more appropriate and display the labels at the default bottom location, set X Axis’s LabelsAtBottom property to True so that X Axis labels are rendered at the bottom the chart. Here is the code snippet for runtime implementation C# Code:**


public void ActiveReport_ReportStart()  
{  
  this.ChartControl1.ChartAreas["defaultArea"].Axes["AxisX"].Position = 0;  
  this.ChartControl1.ChartAreas["defaultArea"].Axes["AxisX"].LabelsAtBottom = true;  
}  

VB.Net Code:


Public Sub ActiveReport_ReportStart  
  Me.ChartControl1.ChartAreas("defaultArea").Axes("AxisX").Position = 0  
  Me.ChartControl1.ChartAreas("defaultArea").Axes("AxisX").LabelsAtBottom = true  
End Sub  


Chart Please note that in case of 3D Bar Charts, setting the Position property of the X Axis to 0 will not give correct results as the Bars stand on an Area, whereas X axis is a 2D line, so it cannot cover the whole area. Rather it will be rendered on the front side of the Area, and therefore there will always be a gap between the X Axis line and the Bars. Download C# Sample Download VB Sample

MESCIUS inc.

comments powered by Disqus