lineChart xAxis integer days of months worngly formatted

UI Components for JSF
Post Reply
banto.78
Posts: 38
Joined: 26 Dec 2013, 18:45

17 Apr 2014, 19:41

Hi experts,

i have this code to show a simple chart :

Code: Select all

<p:lineChart id="categoryDailyAmt"
								value="#{chartBean.dailyWEAmountModel}"
								title="#{res.chartCategoryDailyAmt}" minY="0"
								maxY="#{chartBean.maxYAxisWE}" minX="1" maxX="#           {chartBean.maxXAxisWEDailyAmt}"
								animate="true" style="height:300px; margin-top:20px" widgetVar="catAm" />
where maxXAxisWEDailyAmt it is just a java int which represents the number of days in a month.

When i plot the chart though i get very bad xAxis format.

something like this with 4 decimal digits:

1.0000 3.1429 5.2857 7.4286 .....

How can i get instead the day of month like natural number:

1 2 3 4 5 .........

thanks for you help in advance.
Tomcat/7.0.35, primefaces-4.0.jar
atmosphere-runtime-2.1.0-RC2.jar,
jsf-api-2.2.0-m05.jar, jsf-impl-2.2.0-m05.jar
Eclipse 3.8 ¦ FF

banto.78
Posts: 38
Joined: 26 Dec 2013, 18:45

17 Apr 2014, 19:46

just to be more precise. This is how i build the chart:

Code: Select all

ChartSeries dailyWEAmountSeries = new ChartSeries();
....
dailyWEAmountSeries.set(new Integer(i+1), amtWE[i]);
...
maxXAxisWEDailyAmt = amtWE.length();
but on the xAxis i want to set-up the max scale equal to the number of days in a month. E.g. for April will be 30. That's why i added the :

Code: Select all

 maxX="#{chartBean.maxXAxisWEDailyAmt}"
but i get the problem described above.
Tomcat/7.0.35, primefaces-4.0.jar
atmosphere-runtime-2.1.0-RC2.jar,
jsf-api-2.2.0-m05.jar, jsf-impl-2.2.0-m05.jar
Eclipse 3.8 ¦ FF

banto.78
Posts: 38
Joined: 26 Dec 2013, 18:45

17 Apr 2014, 19:55

ok - very strange but i solved although i cannot explain why the behaviour:

this does not work:

Code: Select all

dailyWEAmountSeries.set(new Integer(i+1), amtWE[i]);

this works:

Code: Select all

dailyWEAmountSeries.set(new Integer(i+1).toString(), amtWE[i]);
the .toString() method makes the difference :roll:

any thought?
Tomcat/7.0.35, primefaces-4.0.jar
atmosphere-runtime-2.1.0-RC2.jar,
jsf-api-2.2.0-m05.jar, jsf-impl-2.2.0-m05.jar
Eclipse 3.8 ¦ FF

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 14 guests