Formatar valor chart PrimeFaces

1 resposta Resolvido
Weverton_Reis

Boa tarde Senhores,

Algum de vocês sabe como formatar valores do chart PrimeFaces.

Exemplo:
R$ 1.499,57

Obrigado,

1 Resposta

Weverton_Reis
Solucao aceita

Encontrei a solução,

Trecho da documentação:

3.15.15 Extender

Chart API provide high level access to commonly used jqplot options however there are many more
customization options available in jqplot. Extender feature provide access to low level apis to do
advanced customization by enhancing the configuration object, here is an example to increase
shadow depth of the line series where model’s extender property is set to “ext”.

<p:chart type="line" model="#{bean.model}" />
function ext() {
   //this = chart widget instance
   //this.cfg = options
   this.cfg.seriesDefaults = {
      shadowDepth: 5
   };
}

Refer to jqPlot docs for available options.

A partir dessa informação fiz o seguinte:

No Java:

barModel = new BarChartModel(); 
barModel.setExtender("ajustarGrafico");

Axis yAxis = barModel.getAxis(AxisType.Y);
yAxis.setTickFormat("R$ %'.2f");

No Javascript:

function ajustarGrafico() {
	$.jqplot.sprintf.thousandsSeparator = '.';
	$.jqplot.sprintf.decimalMark = ',';	
}

Agora ficou no formato que estava precisando.

Criado 15 de fevereiro de 2017
Ultima resposta 16 de fev. de 2017
Respostas 1
Participantes 1