Dundas Chart for Windows Forms
Crossing Points
See Also Send comments on this topic.
Using Dundas Chart > Axis > Crossing Points



Glossary Item Box

Overview

When a non-default crossing value is used, then by default, an axis's labels and tick marks will move along the axis. This topic discusses crossing points, and provides coding examples.

 

Setting a Crossing Value at Design-Time

Follow these steps to set a crossing value for an axis at design-time:

  1. Open the ChartArea Collection Editor by clicking on the ChartAreas item in the Properties window.
  2. Select the Axes collection item in the ChartArea Collection Editor to open the Axis Collection Editor.
  3. Find a Crossing item in the Axis Collection Editor, and set the crossing value as shown in Figure 1 below.

     


    Figure 1: Setting the Crossing Property at Design-Time.

 

Crossing Property Modes

Four modes can be used for the crossing property of an axis:

  1. Auto mode, which means that the crossing value will be set to the relevant axis's minimum or maximum value. If the axis is a primary axis, then the value set in this mode will be its minimum value. However, if the axis is a secondary axis, then the value set while in this mode will be its maximum value. To programmatically set to Auto mode at run-time, use the value Double.Nan.

  2. Minimum mode, which means the axis's crossing value will be its minimum value. To set to Minimum at run-time, use a Double.MinValue value.

  3. Maximum mode, which means the axis's crossing value will be its maximum value. To set to Maximum at run-time, use a Double.MaxValue value.

  4. A specified double value that must be between the relevant axis's Minimum and Maximum value as shown in the Figure 2 below. If the crossing value is less than the minimum value, or the crossing value is greater than maximum value an exception will be thrown.


Figure 2: Setting the Crossing property to 50.

 

Code Samples

These code examples have been included to demonstrate various techniques used with crossing points.

Example

This example demonstrates how to set the crossing point to an explicit value, and create a chart similar to the one shown in Figure 2 above. We assume that a series named "Series1" has been added at design-time, and that the series has had 3 data points added to it. 

Visual Basic Copy Code
Imports Dundas.Charting.WinControl
  ...
  
' The following can be accomplished at design-time by using the Properties window.
' Set Series1 to be a bar chart, and display it in "Chart Area 1".
Chart1.Series("Series1").Type = SeriesChartType.Bar
Chart1.Series("Series1").ChartArea = "Chart Area 1"

' Set the crossing point of the primary Y axis to 3. This will result in the 
' primary Y axis crossing the primary X axis where the X axis equals 3.
Chart1.ChartAreas("Chart Area 1").AxisY.Crossing = 3

' Disable legend.
Chart1.Legend.Enabled = False


C# Copy Code
using Dundas.Charting.WinControl;
  ...
  
// The following can be accomplished at design-time by using the Properties window.
// Set Series1 to be a bar chart, and display it in "Chart Area 1".
Chart1.Series("Series1").Type = SeriesChartType.Bar;
Chart1.Series("Series1").ChartArea = "Chart Area 1";
Chart1.ChartAreas("Chart Area 1").AxisY.Crossing = 3;

// Disable legend.
Chart1.Legend.Enabled = false;


 

Axis Labels Tick Marks and Crossing Points

The labels and tick marks of an axis will, by default, move along the axis if the crossing value is set to a non-default value. This behavior can be changed by setting the MarksNextToAxis property to False, in which case the axis labels and tick marks will stay fixed within the ChartArea object. This next sample demonstrates how to use this MarksNextToAxis property:

Example

In this example we demonstrate how to set the crossing point to an explicit value, and we create a chart similar to the one shown in Figure 3 below. We assume that a series named "Series1" has been added at design-time, and that the series had 3 data points added to it.  Further, we assume that the DundasBlue template has been applied to the original chart for appearance purposes.


  

Figure 3: Setting crossing points.

 

Visual Basic Copy Code
Imports Dundas.Charting.WinControl
...
' The following can be accomplished at design-time using the Properties window.
' Set Series1 to be a bar chart, and display it in "Chart Area 1". Chart1.Series("Series1").Type = SeriesChartType.Bar Chart1.Series("Series1").ChartArea = "Chart Area 1"
' Set the crossing point of the primary Y axis to 3. Chart1.ChartAreas("Chart Area 1").AxisY.Crossing = 3
' Set the MarksNextToAxis property of the primary X axis to fix its labels and tick marks. Chart1.ChartAreas("Default").AxisX.MarksNextToAxis = False
' Disable legend. Chart1.Legend.Enabled = False
C# Copy Code
using Dundas.Charting.WinControl;
  ...
// The following can be accomplished at design-time using the Properties window.
// Set Series1 to be a bar chart, and display it in "Chart Area 1".
Chart1.Series("Series1").Type = SeriesChartType.Bar;
Chart1.Series("Series1").ChartArea = "Chart Area 1";
Chart1.ChartAreas("Chart Area 1").AxisY.Crossing = 3;
// Set the MarksNextToAxis property of the primary X axis to fix its labels and tick marks.
Chart1.ChartAreas("Default").AxisX.MarksNextToAxis = false;
Chart1.Legend.Enabled = false;

 

See Also

How To
Axis Types

©2009. All Rights Reserved.