我有一个列表,其值将每15秒更新一次,我想重新绘制条形图但是在哪里调用它,这是我的代码请帮助我这样做。
public GraphicalView createIntentAll() {
String[] titles = new String[] { "Amount"};
double[] d= new double[a2.size()] ;
for(int i=0;i<a2.size();i++){
d[i] = a2.get(i);
}
List<double[]> values = new ArrayList<double[]>();
values.add(d);
System.out.println("=========="+values.get(0));
int[] colors = new int[] { Color.parseColor("#77c4d3")};
XYMultipleSeriesRenderer renderer = buildBarRenderer(colors);
renderer.setOrientation(Orientation.HORIZONTAL);
setChartSettings(renderer, "Monthly Details", "Months", "Earnings", 0.5,
12.5, 0, yaxis, Color.BLACK, Color.BLACK);
renderer.setXLabels(1);
renderer.setYLabels(10);
for(int i =0;i<y2.size();i++){
renderer.addXTextLabel(i+1, y2.get(i));
System.out.println("==y2==="+y2.get(i));
}
int length = renderer.getSeriesRendererCount();
for (int i = 0; i < length; i++) {
SimpleSeriesRenderer seriesRenderer = renderer.getSeriesRendererAt(i);
seriesRenderer.setDisplayChartValues(true);
}
gv = ChartFactory.getBarChartView(getActivity(), buildBarDataset(titles, values), renderer,Type.DEFAULT);
LinearLayout chartContainer = (LinearLayout)view.findViewById(
R.id.chart_container);
chartContainer.addView(gv);
gv.repaint();
return null;
}
感谢您的帮助
答案 0 :(得分:1)
每当您修改数据集的内容时,都必须调用gv.repaint()
才能更新图表。