Я очень новичок в achartengine (в программировании на Java/Android в целом), но мне нужно, чтобы он отображал две круговые диаграммы в одном действии. Я заставил его работать, вызвав следующий код, но теперь я хотел бы знать, как отобразить данные, которые я установил ранее в действии. Каждая диаграмма должна содержать свои данные (собственный массив строк).
Мой onCreate основного действия
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.rezultati);
...
db.open();
//here I get the values, which are then stored in test1, test2 and test3 for graph 1
//I also get the values for graph 2, which are called test4, test5 and test6
db.close();
//Now I'd like to assign those 'test' values to the pie chart
Вот мой класс PieGraph, который находится в том же файле .java, что и моя активность.
public class PieGraph{
public GraphicalView getView(Context context) {
int[] values; //I'd like to place my values for the first graph here, display the 1st graph and then do the same with the second
CategorySeries series = new CategorySeries("Pie Graph");
//I also need to replace my 'series' to "test1", "test2" and "test3" for the 1st graph
//and "test4", "test5" and "test6 for the 2nd graph
int[] colors = new int[] { Color.BLUE, Color.GREEN, Color.RED };
DefaultRenderer renderer = new DefaultRenderer();
for (int color : colors) {
SimpleSeriesRenderer r = new SimpleSeriesRenderer();
r.setColor(color);
renderer.addSeriesRenderer(r);
}
renderer.setZoomButtonsVisible(false);
renderer.setPanEnabled(false);
renderer.setDisplayValues(true);
renderer.setLabelsTextSize(35);
renderer.setShowLegend(false);
return ChartFactory.getPieChartView(context, series, renderer);
}
}
Теперь мне нужен метод, который будет получать данные «тестовые» значения, помещать их в график и выводить оба графика в макете (я уже добавил два LinearLayouts для графиков в свой .xml).