Normally, a chart will try to hide axis labels so they do not overlap. However, you might need them all displayed. One option is to rotate labels . Other option is discussed in this tutorial.
The following chart was set up to show all labels, regardless if they are overlapping.
categoryAxis . renderer . minGridDistance = 30 ;
categoryAxis . renderer . minGridDistance = 30 ;
Run * --------------------------------------------------------
* This demo was created using amCharts 4.
* For more information visit:
* https://www.amcharts.com/
* Documentation is available at:
* 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 = " country " ;
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 . ColumnSeries ());
series . dataFields . valueY = " visits " ;
series . dataFields . categoryX = " country " ;
series . columns . template . tooltipText = " {categoryX}: [bold]{valueY}[/] " ;
series . columns . template . fillOpacity = 0.8 ;
< div id = " chartdiv " ></ div >
-apple-system , BlinkMacSystemFont, " Segoe UI " , Roboto, Helvetica , Arial , sans-serif ,
" Apple Color Emoji " , " Segoe UI Emoji " , " Segoe UI Symbol " ;
Selectively offsetting axis labels (1) selectively-offsetting-axis-labels-1
We do not have any labels missing, but their overlapping is not cool.
Normally, we could just set rotation on the label template, and call it a day .
However, rotated labels are more difficult to read, so let us put another option on the table: let’s shift every second label down, so that they don’t overlap.
The property to modify element’s vertical position is dy.
Let’s use an adapter to add a few pixels to every second label.
categoryAxis . renderer . labels . template . adapter . add ( " dy " , function ( dy , target ) {
if (target . dataItem && target . dataItem . index & 2 == 2 ) {
categoryAxis . renderer . labels . template . adapter . add ( " dy " , function ( dy , target ) {
if ( target . dataItem && target . dataItem . index & 2 == 2 ) {
"dy" : function(dy , target) {
if (target.dataItem && target.dataItem.index & 2 == 2) {
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 = " country " ;
categoryAxis . renderer . grid . template . location = 0 ;
categoryAxis . renderer . minGridDistance = 30 ;
categoryAxis . renderer . labels . template . adapter . add ( " dy " , function ( dy , target ) {
if ( target . dataItem && target . dataItem . index & ( 2 == 2 )) {
var valueAxis = chart . yAxes . push ( new am4charts . ValueAxis ());
var series = chart . series . push ( new am4charts . ColumnSeries ());
series . dataFields . valueY = " visits " ;
series . dataFields . categoryX = " country " ;
series . columns . template . tooltipText = " {categoryX}: [bold]{valueY}[/] " ;
series . columns . template . fillOpacity = 0.8 ;
< div id = " chartdiv " ></ div >
-apple-system , BlinkMacSystemFont, " Segoe UI " , Roboto, Helvetica , Arial , sans-serif ,
" Apple Color Emoji " , " Segoe UI Emoji " , " Segoe UI Symbol " ;
Selectively offsetting axis labels (2) selectively-offsetting-axis-labels-2
This chart might not win any design awards, but at least all labels are now readable.