我的应用程序需要图形库,我使用achartengine图形库。我的应用程序需要图形是只有50%的画面和另一部分用于显示一些其它信息。
My application requires graph library and I am using achartengine graph library. My app requires graph to be only 50% of the screen and other part is used to display some other information.
是否有可能对XML的资源文件achartengine的图形API以及如何做到这一点?
Is it possible have xml resource file for achartengine's graph APIs and how to do it?
我试图找到一个例子,但没有找到它。它是支持或不?
I tried to find an example but didn't find it. Is it supported or not?
这是一个常见问题AChartEngine。 该AChartEngine演示应用可以在这里下载: AChartEngine演示
This is a FAQ for AChartEngine. The AChartEngine demo application is available for download here: AChartEngine demo
在演示源$ C $ C,你可以看到如何将图表嵌入到现有的图的实例。
In the demo source code you can see an example on how to embed a chart into an existing view.
基本上,在活动描述符.xml文件,我们定义了以下内容作为一个占位符图。当然,其他用户界面组件用这个布局走在一起:
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:
ChartDemo /布局/ xy_chart.xml号线附近27
<LinearLayout
android:id="@+id/chart"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal" />
我们定义了一个局部变量:
We define a local variable:
ChartDemo / src目录/ org.achartengine.chartdemo.demo.chart / XYChartBuilder.java号线附近68 的
private GraphicalView mChartView;
我们将它实例上的活动的onResume()方法:
We instantiate it on the onResume() method of the activity:
ChartDemo / src目录/ org.achartengine.chartdemo.demo.chart / XYChartBuilder.java近163线的
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();
}
}
每当新数据添加在用户presses添加按钮,在我们的情况下,一个新的点被添加在当前系列(:
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:
ChartDemo / src目录/ org.achartengine.chartdemo.demo.chart / XYChartBuilder.java近147线的
if (mChartView != null) {
mChartView.repaint();
}