Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
40
DataChartView not Displaying anything
posted

Hi, I am developing android app in android studio in JAVA. And I am using DataChartView to display a chart the problem is I am unable to see anything plotted. There is just one grey line. Following is my code using the sample data from the documentation

public class CategoryDataSample extends CategoryDataCollection {


public CategoryDataSample() {
this.add(new CategoryDataPoint("A", 85, 80, 95));
...
this.add(new CategoryDataPoint("B", 50, 45, 65));
this.add(new CategoryDataPoint("Z", 100, 75, 95));
int i = 0;
for (CategoryDataPoint dataPoint : this) {
dataPoint.setIndex(i++);
}
}

public class CategoryDataPoint  {

private int _index;
private String _category;
private double _value;
private double _high;
private double _low;

public CategoryDataPoint(String category, double value, double high, double low) {
_category = category;
_value = value;
_high = high;
_low = low;
}

public CategoryDataPoint(String category, double value) {
_category = category;
_value = value;
}

public int getIndex() {
return _index;
}

public int setIndex(int value) {
_index = value;
return _index;
}

public String getCategory() {
return _category;
}

public String setCategory(String category) {
_category = category;
return category;
}

public double getValue() {
return _value;
}

public double setValue(double value) {
_value = value;
return _value;
}

public double getHigh() {
return _high;
}

public double setHigh(double value) {
_high = value;
return _high;
}

public double getLow() {
return _low;
}

public double setLow(double value) {
_low = value;
return _low;
}
}

and the 3rd class is following

class CategoryDataCollection extends ArrayList<CategoryDataPoint> {

}

And below is my usage in Fragment

CategoryDataSample data =
new CategoryDataSample();

DataChartView chart = new DataChartView(chartContainer.getContext());
chart.setHorizontalZoomable(true);
chart.setVerticalZoomable(false);

NumericYAxis yAxis = new NumericYAxis();
yAxis.setLabel("y");
yAxis.setLabelTextSize(10.0f);

CategoryXAxis xAxis = new CategoryXAxis();
xAxis.setDataSource(data);
xAxis.setLabel("x");
xAxis.setLabelTextSize(10.0f);

chart.addAxis(xAxis);
chart.addAxis(yAxis);

LineSeries series = new LineSeries();
series.setDataSource(data);
series.setValueMemberPath("");
series.setTitle("Coal");
series.setXAxis(xAxis);
series.setYAxis(yAxis);

chart.addSeries(series);

chartContainer.addView(chart);

chartContainer is a FrameLayout in my XML

the only output I get is a grey line which is so wierd as i am following the exact same code provided in the documentation. Please help.