1

I want that numbers in my Primefaces Bar Chart should be displayed with decimal points (e.g.: 102.456,00).

Is it possible to set number format in a function extender:

function ext() {
    this.cfg.axes.yaxis.tickOptions.formatString = "R$ %d ";
    this.cfg.seriesDefaults.rendererOptions.dataLabelFormatString = "R$ %d";
}

With this function, the numbers are displayed like this: R$10832 | R$25476 etc. But I want it to be displayed like: R$10.832 | R$25.476 etc.

Is it possible to set it in the function or do I need to set it with Java Number Format?

Community
  • 1
  • 1
jMarcel
  • 958
  • 5
  • 24
  • 54

2 Answers2

6

I use this solution for thousand separator in bean controller :

Axis yAxis = graph.getAxis(AxisType.Y);
yAxis.setTickFormat("%'.0f");

So, for your question try yAxis.setTickFormat("R$%'.0f");

Randyka Yudhistira
  • 3,612
  • 1
  • 26
  • 41
  • Hi! Your solution displays results like 10,000.01; but I need dots for thousands separator and commas for decimal separator, like: 10.000,01. – jMarcel Jul 26 '17 at 19:15
3

After searching for a solution in the JQPlot documentation, I found that is possible to set the thousandsSeparator and decimalMark in the Extender, as follows:

<script>
            function ext() {
                this.cfg.axes.yaxis.tickOptions.formatString = "R$%'#.0f";
                $.jqplot.sprintf.thousandsSeparator = '.';
                $.jqplot.sprintf.decimalMark = ','; 

            }
</script>
jMarcel
  • 958
  • 5
  • 24
  • 54