Skip to content

Show only first and last labels on Gauge Chart

This quick tutorial will explain how you can limit your Gauge chart axis to showing only its first and last labels.

Normally, a Gauge chart axis will show a number of intermediate labels.

Open in CodePen

But what if we want to show only the first and last one?

There’s a trick: set axis renderer’s minGridDistance to some large value.

axis.renderer.minGridDistance = 10000;

That’s it.

Open in CodePen

There is another solution: disabling axis own labels and adding axis ranges for first ant last value.

The theory behind it is explain in “Using axis ranges to place labels at arbitrary values or dates”. Let’s just adapt it for Gauge chart.

axis.renderer.grid.template.disabled = true;
axis.renderer.labels.template.disabled = true;
let rangeMin = axis.axisRanges.create();
rangeMin.value = axis.min;
rangeMin.label.text = "" + axis.min; // converting to string
let rangeMax = axis.axisRanges.create();
rangeMax.value = axis.max;
rangeMax.label.text = "" + axis.max; // converting to string
Open in CodePen