In Q4 2006 the axes in the chart component are redesigned in order to be more flexible and answer the demand for open customization. This version also addresses some issues like overlapped labels and dynamic scale decoration based on the length of the scale in device units.
Most of the properties / objects in the old model are replaced by equivalent properties / objects in the ScaleConfigurator attached to the axis. For a full description on the new axis model please consult the documentation of the axes. Following is a list of the changes:
Changing the type of scaling - linear, logarithmic, ordinal (former dimension) and date time is changed. To apply different type of scaling you need to change the scale configurator associated with the axis:
Old code snippet:
C# |
Copy Code
|
---|---|
NChart chart = nChartControl1.Charts[0]; NAxis axis = chart.Axis(StandardAxis.PrimaryX); axis.ScaleMode = AxisScaleMode.Dimension; |
Translates to:
C# |
Copy Code
|
---|---|
NChart chart = nChartControl1.Charts[0];
NAxis axis = chart.Axis(StandardAxis.PrimaryX);
NOrdinalScaleConfigurator oridnalScale = new NOrdinalScaleConfigurator();
axis.ScaleConfigurator = oridnalScale;
|
Changing the appearance of scale decorations (ticks, labels, ruler etc.) is moved from the axis object to the scale configurator. Furthermore they are grouped in objects corresponding to the type of the element – for example ticks are represented by the NScaleTickStyle object, grid lines are represented by NScaleGridStyle object. Each propery of the scale configurator describes the type of grid line or tick controlled by the attached NScaleGridStyle or NScaleTickStyle object. The following code snipped shows how to translate the change of the color of a major grid lines:
Old code snippet:
C# |
Copy Code
|
---|---|
NChart chart = nChartControl1.Charts[0]; NAxis axis = chart.Axis(StandardAxis.PrimaryX); axis.MajorGridLineStyle.Color = Color.Red; |
Translates to:
C# |
Copy Code
|
---|---|
NChart chart = nChartControl1.Charts[0]; NAxis axis = chart.Axis(StandardAxis.PrimaryX); NStandardScaleConfigurator scale = (NStandardScaleConfigurator)axis.ScaleConfigurator; scale.MajorGridStyle.LineStyle.Color = Color.Red; |
Axis ticks appearance properties are now controlled through special objects:
Old code snippet:
C# |
Copy Code
|
---|---|
NChart chart = nChartControl1.Charts[0]; NAxis axis = chart.Axis(StandardAxis.PrimaryX); axis.OuterTickLineStyle.Color = Color.Red; axis.MinorTickLineStyle.Color = Color.Red; axis.InnerTickLineStyle.Color = Color.Red; |
Translates to:
C# |
Copy Code
|
---|---|
NChart chart = nChartControl1.Charts[0]; NAxis axis = chart.Axis(StandardAxis.PrimaryX); NStandardScaleConfigurator scale = (NScaleConfigurator)axis.ScaleConfigurator; scale.OuterMinorTickStyle.LineStyle.Color = Color.Red; scale.OuterMajorTickStyle.LineStyle.Color = Color.Red; scale.InnerMajorTickStyle.LineStyle.Color = Color.Red; |
Older axis model assumed that the scale will have inner and outer ticks which may not be always true - some scales like the hierarchical scale that will be soon introduced by the component do not have ticks at all. Furthermore when custom programming the scale you may want to add new types of ticks with different settings.