To be able to specify the X position with a BarSeries, you need to use the ShapeSeries instead.
<code>
private void Form1_Load( object sender, EventArgs e )
{
Chart m_chart = chartControl1.Charts[ 0 ];
Axis Xaxis = m_chart.Axis( StandardAxis.PrimaryX );
Xaxis.ScaleMode = AxisScaleMode.Numeric;
Xaxis.NumericScale.AutoMax = false;
Xaxis.NumericScale.AutoMin = false;
Xaxis.NumericScale.Max = 5;
Xaxis.NumericScale.Min = -2;
ShapeSeries m_Shape = ( ShapeSeries )m_chart.Series.Add( SeriesType.Shape );
m_Shape.UseXValues = true;
// add Bar1
m_Shape.AddShape( 10, // Y center of bar -> half its Y size
-1, // X position - not used since UseXValue is set to false
0, // Z position - not used since UseZValue is set to false
0.5, // X size - half category in width
20, // Y size of bar
0.66, // Z size - 2 thirds of series depth
"Bar1", // label
new FillEffect( Color.LightGreen ), // filling
new LineProperties( 1, Color.Black ) // border
);
// add Bar2
m_Shape.AddShape( 20, // Y center of bar -> half its Y size
2, // X position - not used since UseXValue is set to false
0, // Z position - not used since UseZValue is set to false
0.33, // X size - approximately 1 third of category width
40, // Y size of bar
0.33, // Z size - 1 third of series depth
"Bar2", // label
new FillEffect( Color.LightCoral ), // filling
new LineProperties( 1, Color.Black ) // border
);
// add Bar3
m_Shape.AddShape( 15, // Y center of bar -> half its Y size
3, // X position - not used since UseXValue is set to false
0, // Z position - not used since UseZValue is set to false
0.5, // X size - half category width
30, // Y size of bar
0.5, // Z size - half series depth
"Bar3", // label
new FillEffect( Color.LightSalmon ), // filling
new LineProperties( 1, Color.Black ) // border
);
}
</code>
Charles Bérubé-Rémillard
Technical Support
Xceed Software Inc.