Search code examples
primefacesjqplot

How to change the number separator of a LineChartSeries with spaces?


I would like to change the format of the axis of my graph like this: "1 000 000" and I can't find the solution.

Currently this code allows me to have this format "1,000,000" :

Axis y = lineModel.getAxis(AxisType.Y);
y.setTickFormat("%'.0f");

I work with Primefaces 6.0

Thanks


Solution

  • You can use a chartExtender.

    main.js

    function chartExtender() {
        this.cfg.axes.yaxis.tickOptions.formatString = "%'#.0f";
        $.jqplot.sprintf.thousandsSeparator = ' ';
    }
    

    chart.xhtml

    <p:lineChart extender='chartExtender'/>