Normal Line series on an XY chart usually connect data items with a straight line. Step line series are similar, except they connect the data items with a step. This tutorial will show how you can tweak the steps to suit your needs better.
Let’s take a very basic chart with Step line series:
Run * --------------------------------------------------------
* This demo was created using amCharts V4 preview release.
* V4 is the latest installement in amCharts data viz
* library family, to be released in the first half of
* For more information and documentation visit:
* https://www.amcharts.com/docs/v4/
* --------------------------------------------------------
am4core . useTheme ( am4themes_animated );
var chart = am4core . create ( " chartdiv " , am4charts . XYChart );
var categoryAxis = chart . xAxes . push ( new am4charts . CategoryAxis ());
categoryAxis . dataFields . category = " category " ;
categoryAxis . renderer . grid . template . location = 0 ;
categoryAxis . renderer . minGridDistance = 30 ;
var valueAxis = chart . yAxes . push ( new am4charts . ValueAxis ());
var series = chart . series . push ( new am4charts . StepLineSeries ());
series . dataFields . valueY = " value " ;
series . dataFields . categoryX = " category " ;
var bullet = series . bullets . push ( new am4charts . CircleBullet ());
bullet . fill = am4core . color ( " white " );
< div id = " chartdiv " ></ div >
-apple-system , BlinkMacSystemFont, " Segoe UI " , Roboto, Helvetica , Arial , sans-serif ,
" Apple Color Emoji " , " Segoe UI Emoji " , " Segoe UI Symbol " ;
Step line series (1) step-line-series-1
We’ve plopped a bullet on the Step line series, to indicate where the real value is.
As you can see the horizontal line part of each step goes horizontally on the value. It spans the whole width of the category/cell.
Vertical parts (risers) of the line just connect ends of the horizontal lines.
Now, let’s see how we can change where step starts and ends.
For that we have two Step line series’ property startLocation . In human terms it means “put vertical line at this relative position”.
The value - “relative position” - is a number between 0 and 1, where zero means start of the cell (default behavior) and 1 means end of the cell.
Any number in-between will mean relative position within cell. E.g. 0.5 will put the vertical part right in the middle - where the bullet is.
Let’s try that:
series . startLocation = 0.5 ;
series . startLocation = 0.5 ;
"type" : " StepLineSeries " ,
Run * --------------------------------------------------------
* This demo was created using amCharts V4 preview release.
* V4 is the latest installement in amCharts data viz
* library family, to be released in the first half of
* For more information and documentation visit:
* https://www.amcharts.com/docs/v4/
* --------------------------------------------------------
am4core . useTheme ( am4themes_animated );
var chart = am4core . create ( " chartdiv " , am4charts . XYChart );
var categoryAxis = chart . xAxes . push ( new am4charts . CategoryAxis ());
categoryAxis . dataFields . category = " category " ;
categoryAxis . renderer . grid . template . location = 0 ;
categoryAxis . renderer . minGridDistance = 30 ;
var valueAxis = chart . yAxes . push ( new am4charts . ValueAxis ());
var series = chart . series . push ( new am4charts . StepLineSeries ());
series . dataFields . valueY = " value " ;
series . dataFields . categoryX = " category " ;
series . startLocation = 0.5 ;
var bullet = series . bullets . push ( new am4charts . CircleBullet ());
bullet . fill = am4core . color ( " white " );
< div id = " chartdiv " ></ div >
-apple-system , BlinkMacSystemFont, " Segoe UI " , Roboto, Helvetica , Arial , sans-serif ,
" Apple Color Emoji " , " Segoe UI Emoji " , " Segoe UI Symbol " ;
Step line series (2) step-line-series-2
To disable vertical line connectors - risers - simply set noRisers to true.
"type" : " StepLineSeries " ,
Run * --------------------------------------------------------
* This demo was created using amCharts V4 preview release.
* V4 is the latest installement in amCharts data viz
* library family, to be released in the first half of
* For more information and documentation visit:
* https://www.amcharts.com/docs/v4/
* --------------------------------------------------------
am4core . useTheme ( am4themes_animated );
var chart = am4core . create ( " chartdiv " , am4charts . XYChart );
var categoryAxis = chart . xAxes . push ( new am4charts . CategoryAxis ());
categoryAxis . dataFields . category = " category " ;
categoryAxis . renderer . grid . template . location = 0 ;
categoryAxis . renderer . minGridDistance = 30 ;
var valueAxis = chart . yAxes . push ( new am4charts . ValueAxis ());
var series = chart . series . push ( new am4charts . StepLineSeries ());
series . dataFields . valueY = " value " ;
series . dataFields . categoryX = " category " ;
var bullet = series . bullets . push ( new am4charts . CircleBullet ());
bullet . fill = am4core . color ( " white " );
< div id = " chartdiv " ></ div >
-apple-system , BlinkMacSystemFont, " Segoe UI " , Roboto, Helvetica , Arial , sans-serif ,
" Apple Color Emoji " , " Segoe UI Emoji " , " Segoe UI Symbol " ;
Step line series (3) step-line-series-3