Closed cavega closed 10 years ago
The crash comes from the setLineWidth(float width)
method. The reason therefore is that this method internally uses the chartlibs Utils
class to convert the line width you set into density pixels.
In order to use the Utils
, they need to be initialized once with a Resources
object.
By default, this is done in the constructor of each chart class.
If data for the chart is created before the charts constructor is called, the Utils
are not initialized.
In that case, you need to call Utils.initialize(getResources())
just once somewhere before creating the data for your chart.
I know that this is quite inconvenient and will work on a solution as soon as possible.
Regards, Phil
Following the example shown on LineChartActivity.java I'm using the following statements to modify each line in my Line Chart:
LineDataSet set1 = new LineDataSet(yVals.get(0), labels.get(0)); set1.disableDashedLine(); set1.setColor(context.getResources().getColor(Color.RED);
When I start the app and the fragment that displays the graph is been created I get the following Exception:
The above error occurs while using either (or both) setLineWidth() and enableDashLine(). As a workaround I modified my local copy of the library to change the default values set by these methods. I'll appreciate some feedback as to what is causing the exception since I'm not doing anything that different from the sample code.