DaxiaK / achartengine

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

Please change APIs to use CharSequence instead of String #233

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
This should allow for displaying styled text for the various UI elements of the 
charts.

Original issue reported on code.google.com by zvasv...@gmail.com on 12 Jul 2012 at 3:12

GoogleCodeExporter commented 9 years ago
My use case for this is to be able to change the color of the labels when the 
chart goes negative.  But supporting styled text is a very simple way of 
allowing all kinds of custom formatting with almost no effort on the library's 
part.

Original comment by zvasv...@gmail.com on 14 Jul 2012 at 3:19

GoogleCodeExporter commented 9 years ago
I don't understand the advantage of doing this. Can you please provide an 
example?

Original comment by dandrome...@gmail.com on 15 Jan 2013 at 1:53

GoogleCodeExporter commented 9 years ago
As I mentioned -- it allows you to displayed styled text, using, for example a 
SpannedString.  SpannedString is not a String, but a CharSequence.

http://developer.android.com/reference/android/text/SpannedString.html

Original comment by android....@gmail.com on 16 Jan 2013 at 12:57

GoogleCodeExporter commented 9 years ago
A good example:

http://www.androidengineer.com/2010/08/easy-method-for-formatting-android.html

Original comment by williams...@gmail.com on 13 Feb 2014 at 4:40

GoogleCodeExporter commented 9 years ago
Needing to colorize the Y labels. I went ahead and checked out the code and 
updated the API to use CharSequence. I then passed in SpannableString with a 
ForegroundColorSpan. See problem here is that even if he did update the API, 
Android canvas does not support drawing text Spannables. I had to pull color 
from the spannable via getSpans(), assumign ForegroundColorSpan, and updated 
the canvas paint to the color that Span required. This however was a workaround 
that would not handle all the goodness of Spannables, and only handled my one 
scenario of wanting to colorize the labels.

Original comment by jschue...@digifit.com on 3 Apr 2015 at 10:08