Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This is a FAQ for AChartEngine. The AChartEngine demo application is available for download here: <a href="http://www.achartengine.org/content/goodies.html">AChartEngine demo</a></p> <p>In the demo source code you can see an example on how to embed a chart into an existing view.</p> <p>Basically, in the activity descriptor .xml file, we have defined the following as a placeholder for the chart. Of course, other user interface components go together with this layout:</p> <p><i>ChartDemo/layout/xy_chart.xml near Line 27</i></p> <pre><code>&lt;LinearLayout android:id="@+id/chart" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:orientation="horizontal" /&gt; </code></pre> <p>We define a local variable:</p> <p><em>ChartDemo/src/org.achartengine.chartdemo.demo.chart/XYChartBuilder.java near Line 68</em></p> <pre><code>private GraphicalView mChartView; </code></pre> <p>We instantiate it on the onResume() method of the activity:</p> <p><em>ChartDemo/src/org.achartengine.chartdemo.demo.chart/XYChartBuilder.java near Line 163</em></p> <pre><code>protected void onResume() { super.onResume(); if (mChartView == null) { LinearLayout layout = (LinearLayout) findViewById(R.id.chart); mChartView = ChartFactory.getLineChartView(this, mDataset, mRenderer); layout.addView(mChartView, new LayoutParams (LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); ... } else { mChartView.repaint(); } } </code></pre> <p>Whenever new data is added (when the user presses the "Add" button in our case, a new point is added in the current series and:</p> <p><em>ChartDemo/src/org.achartengine.chartdemo.demo.chart/XYChartBuilder.java near Line 147</em></p> <pre><code>if (mChartView != null) { mChartView.repaint(); } </code></pre>
 

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