Hello,
I started using HelloCharts library and found some difficulties with adding two sets of data into my LineChartView. This is how I'm doing it:
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
rootView = inflater.inflate(R.layout.fragment_user_details, container, false);
performanceChart = (LineChartView)rootView.findViewById(R.id.performanceChart);
performanceChart.setInteractive(false);
addScoreEntriesToChart();
addRankEntriesToChart();
return rootView;
}
private void addScoreEntriesToChart() {
List<PointValue> values = new ArrayList<PointValue>();
ArrayList<Double> latestScores = currentPlayer.getLatestScores();
for(int i = 0; i < latestScores.size(); i++){
values.add(new PointValue(i+1, Float.valueOf(String.valueOf(latestScores.get(i)))));
}
performanceChart.setLineChartData(getLineSettings(values, Color.parseColor("#0036D9")));
}
private void addRankEntriesToChart() {
List<PointValue> values = new ArrayList<PointValue>();
ArrayList<Integer> latestRanks = currentPlayer.getLatestRanks();
for(int i = 0; i < latestRanks.size(); i++){
values.add(new PointValue(i+1, Float.valueOf(latestRanks.get(i))));
}
performanceChart.setLineChartData(getLineSettings(values, Color.parseColor("#84BE67")));
}
@NonNull
private LineChartData getLineSettings(List<PointValue> values, int lineColor) {
Line line = new Line(values).setColor(lineColor).setCubic(true);
line.setStrokeWidth(2);
line.setPointRadius(0);
List<Line> lines = new ArrayList<Line>();
lines.add(line);
LineChartData data = new LineChartData();
data.setLines(lines);
return data;
}
I'm probably doing something wrong because i end up seeing only one line on the LineChartView (RankEntries - the last one added).
Trying to Google the issues didn't get me the answer.
Any help would be appreciated :)
Hello, I started using HelloCharts library and found some difficulties with adding two sets of data into my LineChartView. This is how I'm doing it:
I'm probably doing something wrong because i end up seeing only one line on the LineChartView (
RankEntries
- the last one added). Trying to Google the issues didn't get me the answer. Any help would be appreciated :)