yunjianwu / achartengine

Automatically exported from code.google.com/p/achartengine
0 stars 0 forks source link

Setting Formatter for displaying chart values. #238

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I got a ScatteredChart with some float values to display. I enabled displaying 
chart values by using method renderer.setDisplayChartValues(true);

The float values are displayed. Thats ok! But I would like to format the floats 
with one decimal place. Maybe an example would be better:
Currently displayed:  8.198998
Should be displayed: 8.2

It would be nice, if a it will be possible to set up a Formatter for formating 
these numbers.

What version of the product binary library are you using?
1.0.0 

Thanks a lot!
Christopher

Original issue reported on code.google.com by plin...@gmail.com on 14 Aug 2012 at 10:27

GoogleCodeExporter commented 9 years ago
+1 for me, this would be a great addition!

Original comment by jethroborsje on 25 Aug 2012 at 9:44

GoogleCodeExporter commented 9 years ago
I took a short look at the code. Regarding the fix: would we just want a 
formatter for the chart values or should the same formatter be applied to the 
labels on the Y-axis? Personally I feel it would be consistent to apply the 
formatter to the axis as well. I'm curious to see what you guys think of this. 

Original comment by jethroborsje on 10 Sep 2012 at 7:52

GoogleCodeExporter commented 9 years ago
I think there exist some use cases where it could be useful to have two 
different formatter for the axis and the values. Maybe you would format the 
axis only with whole numbers and would like to see the values more detailed. 
Therefore i think it should also be possible to apply two different formatters. 

Original comment by plin...@gmail.com on 11 Sep 2012 at 5:47

GoogleCodeExporter commented 9 years ago
READ!!!
I had the same problem!
But I saw that using double variable, there isn't this issue!!
So I changed all my float variables to double variables.
It's the only way to solve it

Original comment by giacomo....@gmail.com on 11 Sep 2012 at 1:46

GoogleCodeExporter commented 9 years ago
After looking at the code some more I'm now thinking about adding 
addChartValuesFormat(String) and addYLabelsFormat(String) to XYChart.java. The 
String should be in a format according to String.format() (see: 
http://developer.android.com/reference/java/lang/String.html#format(java.lang.St
ring, java.lang.Object...)). I would than like to use String.format() to format 
the labels to be shown by making different version of the current getLabel() 
method: getChartValueLabel() and getYAxisLabel(). What do you guys think?

@commenter#4: it would be nice to have some more control over the format. 

Original comment by jethroborsje on 11 Sep 2012 at 5:42

GoogleCodeExporter commented 9 years ago
Sounds like a useful addition. I'm feeding a chart with sensor-data and the 
precision of values (up to 8 decimal places) makes it so that displayed values 
end up completely running together unless you zoom way in.

Another thing: Why is XYMultipleSeriesRenderer.setDisplayChartValues(Boolean) 
depricated?

Original comment by AWSmo...@gmail.com on 25 Sep 2012 at 5:17

GoogleCodeExporter commented 9 years ago
Issue 261 has been merged into this issue.

Original comment by dandrome...@gmail.com on 8 Jan 2013 at 12:25

GoogleCodeExporter commented 9 years ago
Custom annotations support has been added in SVN. In order to add annotations, 
do something like this:

series.addAnnotation("Vacation", 6, 30);

Original comment by dandrome...@gmail.com on 10 Jan 2013 at 6:31

GoogleCodeExporter commented 9 years ago
Fixed in SVN.

Example:
  NumberFormat format = NumberFormat.getNumberInstance();
  format.setMaximumFractionDigits(3);
  renderer.setLabelFormat(format);
  seriesRenderer.setChartValuesFormat(format);

Original comment by dandrome...@gmail.com on 16 Jan 2013 at 3:21

GoogleCodeExporter commented 9 years ago

Original comment by dandrome...@gmail.com on 16 Jan 2013 at 3:21

GoogleCodeExporter commented 9 years ago

Original comment by dandrome...@gmail.com on 16 Jan 2013 at 3:21