bar chart - how to format the y-axis number labels

UI Components for JSF
Post Reply
jfss
Posts: 20
Joined: 26 Jul 2012, 20:59

24 Jan 2013, 20:36

Image
http://imgur.com/cKkW6Ja

How do I format the above image so that the numbers on the left side show the whole number instead of the 3 decimal places? this is the code:

Code: Select all

		            <p:barChart id="basic" value="#{bean.value}" yaxisLabel="%"
		            min="80" max="100" style="width:250px;height:200px"/>
PrimeFaces Version: 3.4.2
JSF Implementation/Version: Mojarra 2.1.8
Server: Weblogic 11g

jfss
Posts: 20
Joined: 26 Jul 2012, 20:59

24 Jan 2013, 21:32

I found the answer. You need to use a custom extender, e.g.:

Code: Select all

	<script type="text/javascript">
	 function extndr() {
		 this.cfg.axes.yaxis.tickOptions.formatString="%d";
	 }
	</script>


        <p:barChart id="basic" value="#{bean.value}" 
        extender="extndr"
        min="80" max="100" style="width:250px;height:200px"/>
PrimeFaces Version: 3.4.2
JSF Implementation/Version: Mojarra 2.1.8
Server: Weblogic 11g

javaone9
Posts: 317
Joined: 06 Nov 2012, 20:50

25 Jan 2013, 04:06

Do you know how to use extender to format bar chart value tip?
for value 1000 for bar 4, current tip is 4,1000. I like it to be 1000.

Thanks.
Dave

jfss
Posts: 20
Joined: 26 Jul 2012, 20:59

29 Jan 2013, 19:42

javaone9 wrote:Do you know how to use extender to format bar chart value tip?
for value 1000 for bar 4, current tip is 4,1000. I like it to be 1000.

Thanks.
Dave
somebody answered this before, but I can't find the post. they basically added this to the underlying bean:

Code: Select all

 
     public String getDatatipFormat(){
        return "<span style=\"display:none;\">%s</span><span>%s</span>";
     }
and then in the bar chart, add this attribute: datatipFormat="#{bean.datatipFormat}"
PrimeFaces Version: 3.4.2
JSF Implementation/Version: Mojarra 2.1.8
Server: Weblogic 11g

umakar
Posts: 1
Joined: 13 Sep 2021, 16:26

13 Sep 2021, 16:34

How can i adjust y axes label based on count
example: c1 = 10 c2=100,c3=1000 c4 =10000.
for this series i am missing C1 bar

raho
Posts: 27
Joined: 05 Feb 2016, 21:08

22 Sep 2021, 07:56

I am also interested in how to format tooltip and labels!

For the values i want something like this:

Code: Select all

<p:barChart model="#{berichte1Model.barModel}" style="width: 100%; height: 500px;">
    <f:convertNumber minFractionDigits="2" maxFractionDigits="2" groupingUsed="true"/>
</p:barChart>
But this results in

Code: Select all

<f:convertNumber> Parent not an instance of ValueHolder: org.primefaces.component.barchart.BarChart
In PF8 i did it this way:

Code: Select all

barModel.setDatatipFormat("%2$s"); // show only 2. part (the value) in Tooltip
Axis yAxis = new LinearAxis();
yAxis.setTickFormat("%'.2f"); // use only 2 fraction digits
barModel.getAxes().put(AxisType.Y, yAxis);
PF 12.0.4
WildFly 23.0.2.Final

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 53 guests