Guilherme Barboza
Guilherme Barboza

Reputation: 652

Primefaces 6.2 BarChart DatatipFormat

I am currently working with Primefaces 6.2 and JSF 2.2 and I am trying to build a bar chart. The chart itself is being rendered properly, but right now, the datatip of every value is the "y" value concatenated with the "x" value:
barModel.setDatatipFormat("%d - %.2f");
Ex:
'1 - 132.70',
'2 - 96.00',
'3 - 103.25'
....

What I need is to display only the second value: '132.70',
'96.00',
'103.25'
....

But every time I try to make something different like barModel.setDatatipFormat("%.2f");, only the first value is formatted and shown.

Is there a way to, for instance, ignore this first value? Thanks in advance.

EDIT: I tryed to do the same as this question, but there is no <p:lineChart.../> tag in Primefaces 6.2

Upvotes: 2

Views: 815

Answers (1)

fxrobin
fxrobin

Reputation: 652

You can use parameter index in your format String, as it's a classical format supported by String.format or System.out.printf. Parameter index starts at 1 not 0.

In your case, just try this "%2$.2f".

See also : http://devdocs.io/openjdk~8/java/util/formatter

Upvotes: 2

Related Questions