Chart for .NET / About Nevron Chart for .NET / Porting From Older Versions / Porting from Q3 2006 to Q4 2006

Porting from Q3 2006 to Q4 2006

This topic describes the differences in the programming model between Nevron Chart for .NET Q3 2006 and Nevron Chart for .NET Q4 2006.

 Axis Scale Changes

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.

 Axis Labels and Titles

Standard axis labels and titles are again moved to the NStandardScaleConfigurator object. The labels and titles are improved to support automatic layout and label overlap detection. You can now align titles better relative to the axis.

Old code snippet:

C#
Copy Code
NChart chart = nChartControl1.Charts[0];
NAxis axis = chart.Axis(StandardAxis.PrimaryX);
axis.TextStyle.FontStyle.Name = "Tahoma";

Translates to:

C#
Copy Code
NChart chart = nChartControl1.Charts[0];
NAxis axis = chart.Axis(StandardAxis.PrimaryX);

NStandardScaleConfigurator scale = (NScaleConfigurator)axis.ScaleConfigurator;
scale.LabelStyle.TextStyle.FontStyle.Name = "Tahoma"

In Q4 you may add an unlimited number of axis titles by custom programming the scale. You can also define your own set of rules for creating value labels.

 Axis Positioning

Axis positioning is now controlled through the axis Anchor property accepting different types of axis anchors. For a detailed description on axis anchors please consult the documentation.

Old code snippet:

C#
Copy Code
NChart chart = nChartControl1.Charts[0];

NAxis axis = chart.Axis(StandardAxis.PrimaryX);
axis.PositionAxis(StandardAxis.PrimaryY, 10, true);

New code snippet:

C#
Copy Code
NChart chart = nChartControl1.Charts[0];
NAxis primaryX = chart.Axis(StandardAxis.PrimaryX);

NAxis primaryY = chart.Axis(StandardAxis.PrimaryY);
primaryX.Anchor = new NCrossAxisAnchor(AxisOrientation.Horizontal, new NValueAxisCrossing(primaryY, 10, true));

Old axis positioning did not support axis stacking (having multiple axes on the sides of the chart area without overlapping) as well as crossing of axis in model coordinates.

 Table of changes

Sizes that do not scale on the axes are now specified in NLength format.

Old code snippet:

C#
Copy Code
NChart chart = nChartControl1.Charts[0];
NBarSeries bar = (NBarSeries)chart.Series.Add(SeriesType.Bar);

bar.Values.Add(10);
bar.Values.Add(20);
bar.Values.Add(24);

bar.MarkerStyle.Visible = true;
bar.MarkerStyle.Width = 2.5f;
bar.MarkerStyle.Height = 2.5f;

Translates to:

C#
Copy Code
NChart chart = nChartControl1.Charts[0];
NBarSeries bar = (NBarSeries)chart.Series.Add(SeriesType.Bar);

bar.Values.Add(10);
bar.Values.Add(20);
bar.Values.Add(24);

bar.MarkerStyle.Visible = true;
bar.MarkerStyle.Width = new NLength(2.5f, NRelativeUnit.ParentPercentage);
bar.MarkerStyle.Height = new NLength(2.5f, NRelativeUnit.ParentPercentage);

The reason for this change is the to support better scaling of charts at different resolutions. Previously it was not possible to tell the markers of the series to scale in other units than model units (for example you will not able to specify marker size 10x10px).

 Table of changes

The following table describes the major changes in the programming interface in more detail:

Q3 2006 Q4 2006 Note
NAxis.NumericScale NAxis.ScaleConfigurator removed, use NLinearScaleConfigurator
NAxis.DimensionScale NAxis.ScaleConfigurator removed, use NOrdinalScaleConfigurator
NAxis.LogarithmicScale NAxis.ScaleConfigurator removed, use NLogarithmicScaleConfigurator
NAxis.DateTimeScale NAxis.ScaleConfigurator removed, use NDateTimeScaleConfigurator
NAxis.ScaleMode removed
NAxis.MajorGridLineStyle NScaleGridStyle.LineStyle use NStandardScaleConfigurator.MajorGridStyle.LineStyle
NAxis.SetMajorShowAtWall() NScaleGridStyle.SetShowAtWall() use NStandardScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true)
NAxis.GetMajorShowAtWall() NScaleGridStyle.GetShowAtWall() use NStandardScale.MajorGridStyle.GetShowAtWall(ChartWallType.Back)
NAxis.ValueFormater NStandardScaleConfigurator.LabelValueFormatter
NAxis.StaggerTexts NStandardScaleConfigurator.LabelGenerationMode NStandardScaleConfigurator.LabelGenerationMode = LabelGelerationMode.Stagger2
NAxis.DimentionalScale.AutoLabels NStandardScaleConfigurator.AutoLabels AutoLabels is a property of NStandardScaleConfigurator
NAxis.Labels NStandardScaleConfigurator.Labels Labels is a property of NStandardScaleConfigurator
NAxis.TextStyle NScaleLabelStyle.TextStyle NStandardScaleConfigurator.LabelStyle.TextStyle
NAxis.PredefinedPosition NDockAxisAnchor.AxisDockZone
NAxis.CustomLabels removed, use annotations objects instead
NAxis.OuterTickLength NScaleTickStyle.Length use NStandardScaleConfigurator.OuterMajorTickStyle.Length
NAxis.InnerTickLength NScaleTickStyle.Length use NStandardScaleConfigurator.InnerMajorTickStyle.Length
NAxis.EnableAxisScrolling NAxis.ScrollBar.Visible Need to set the NAxis.PagingView property too
NAxis.BorderStyle NRulerStyle.BorderStyle use NStandardScaleConfigurator.RulerStyle.BorderStyle
NAxis.Width NRulerStyle.Height
NAxis.AxisShape NRulerStyle.Shape use NStandardScaleConfigurator.RulerStyle.Shape
NAxis.FillStyle NRulerStyle.FillStyle use NStandardScaleConfigurator.RulerStyle.FillStyle
NAxis.Title NStandardScaleConfigurator.Title Title is now a property of NStandardScaleConfigurator
NAxis.TitleTextStyle NScaleTitleStyle.TextStyle use NStandardScaleConfigurator.Title.TextStyle
NAxis.PositionAxis() NValueAxisCrossing.Value ((NValueAxisCrossing)crossAxisAnchor.Crossings[1]).Value
NAxis.Offset removed
NAxis.MajorTicks
NAxis.MinorTicks
NAxis.InnerTickLineStyle NScaleTickStyle.LineStyle NStandardScale.InnerMajorTickStyle.LineStyle
NAxis.Ruler.PositionStartPercent NAxisAnchor.BeginPercent use NAxis.Anchor.BeginPercent
NAxis.Ruler.PositionEndPercent NAxisAnchor.EndPercent use NAxis.Anchor.EndPercent
NAxis.Ruler.Inverted NStandardScaleConfigurator.Invert
NAxis.Ruler.PageCount NPageAxisView.PageCount
NAxis.Ruler.PageSize NRangeAxisView.Range
NAxis.Ruler.CurrentPageMode NAxis.View assign an object derived from NAxisView to the NAxis.View property
NAxis.Ruler.CurrentPageIndex NPageAxisView.PageIndex
NAxis.Ruler.PagingMode NAxis.View assign an object derived from NAxisView to the NAxis.View property
NAxis.Ruler.CurrentPageBeginValue NRangeAxisView.Range
NAxis.Ruler.ClampValueToRuler() you can access the axes ranges directly (NAxis.SeriesRange, NAxis.ContentRange, NAxis.ViewRange, NAxis.PageRange)
NSettings.SmootingMode NSettings.ShapeRenderingMode
int NDataLabeStyle.ArrowLength NLength NDataLabeStyle.ArrowLength Type changed from int to NLength
float NBoxAndWhiskersSeries.OutliersSize NLength NBoxAndWhiskersSeries.OutliersSize Type changed from float to NLength
float NBoxAndWhiskersSeries.Width NLength NBoxAndWhiskersSeries.Width Type changed from float to NLength
float NPointSeries.Size NLength NPointSeries.Size Type changed from float to NLength
float NMarkerStyle.Width NLength NMarkerStyle.Width Type changed from float to NLength
float NMarkerStyle.Height NLength NMarkerStyle.Height Type changed from float to NLength
float NErrorBarSeries.SizeX NLength NErrorBarSeries.SizeX Type changed from float to NLength
float NErrorBarSeries.SizeY NLength NErrorBarSeries.SizeY Type changed from float to NLength
float NErrorBarSeries.SizeZ NLength NErrorBarSeries.SizeZ Type changed from float to NLength
float NMarkerStyle.Width NLength NMarkerStyle.Width Type changed from float to NLength
float NMarkerStyle.Height NLength NMarkerStyle.Height Type changed from float to NLength
float NMarkerStyle.Depth NLength NMarkerStyle.Depth Type changed from float to NLength
float NStockSeries.CandleWidth NLength NStockSeries.CandleWidth Type changed from float to NLength
Color NFillStyle.GetPrimaryColor() NColor NFillStyle.GetPrimaryColor() Type changed from Color to NColor
NFillStyle.Specular NMaterialStyle.Specular use NFillStyle.MaterialStyle.Specular
NFillStyle.Diffuse NMaterialStyle.Diffuse use NFillStyle.MaterialStyle.Diffuse
NFillStyle.Ambient NMaterialStyle.Ambient use NFillStyle.MaterialStyle.Ambient
NFillStyle.Shininess NMaterialStyle.Shininess use NFillStyle.MaterialStyle.Shininess