Home > Sample Charts > StepChart > A Discontinuous Timeseries

A Discontinuous Timeseries

Stepcharts are used for two main purposes – timeseries where the values change discontinuously (interest rates are typical) and summary data where the groups are of variable width (monthly totals). SharpPlot can draw the steps with risers from the X-axis (which has the effect of abutted bars) and with shading down to either the axis or a given reference line.

This chart shows the values of the UK bank-rate over the last eight years. Note that the dates have been given in OLE-date format and the X-axis style is ‘Annual’ to have tickmarks placed at the year boundaries.


SharpPlot sp = new SharpPlot;

sp.SetPenWidths(2.5);
sp.SetColors(Color.Orange);

sp.Heading = "UK interest rates (%)";
sp.HeadingStyle = HeadingStyles.Left;
sp.SetHeadingFont("arial",16,FontStyle.Bold,Color.Black);
sp.XAxisStyle = XAxisStyles.AnnualTicks|XAxisStyles.MiddleLabels|XAxisStyles.Clipped;
sp.YAxisStyle = YAxisStyles.GridLines|YAxisStyles.InvisibleAxis;
sp.YLabelFormat = "#.00";
sp.SetYRange(3,7.5);

changedates = new int[] {35582,35582,35612,35643,35726,35947,36130,36141,36160,
         36165,36192,36231,36323,36415,36495,36537,36568,36923,36951,36993,37105,
         37151,37169,37204,37658,37812,37929,38023,38113,38141,38148,38205,38387,
         38568,38580};
baserate = new double[] {6.25,6.5,6.75,7,7.25,7.5,7.25,6.75,6.25,6,5.5,5.25,5,5.25,
         5.5,5.75,6,5.75,5.5,5.25,5,4.75,4.5,4,3.75,3.5,3.75,4,4.25,4.25,4.5,4.75,
         4.75,4.5,4.5};

sp.DrawStepChart(baserate,changedates);

Worked Examples

stepchart1 stepchart2 stepchart3 stepchart4

Send comments on this topic
© Dyalog Ltd 2013