Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I had same problem in two weeks ago. But I had pieChart in xml layer combine other views. Anyway, I create an activity for each tab and chart, and call the activities instead of charts. In one of my activity I have this snipped code:</p> <pre><code>public class FirstChartActivity extends Activity{ // other code protected void onResume() { super.onResume(); if (hChartView == null) { // first time pie chart is empty renderer = buildCategoryRenderer(colors); renderer.setLabelsTextSize(14); categorySeries = setCategorySeries("First PieChart", myList); // draw pie chart with initialized values (myList and colors) hChartView = ChartFactory.getPieChartView(this, categorySeries, renderer); LinearLayout layout = (LinearLayout) findViewById(R.id.pch_chart); layout.addView(hChartView, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); } else { hChartView.repaint(); } } protected DefaultRenderer buildCategoryRenderer(int[] colors) { DefaultRenderer renderer = new DefaultRenderer(); for (int color : colors) { SimpleSeriesRenderer r = new SimpleSeriesRenderer(); r.setColor(color); renderer.addSeriesRenderer(r); } return renderer; } protected CategorySeries setCategorySeries(String chartTitle, HashMap&lt;String, Double&gt; hashMap) { CategorySeries cs = new CategorySeries(chartTitle); Iterator&lt;String&gt; iter = hashMap.keySet().iterator(); while (iter.hasNext()) { String key = iter.next(); Double val = hashMap.get(key); cs.add(key, val); } return cs; } } </code></pre> <p>I hope this code help you.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload