1

我正在使用 achartengine-1.0.0 以图表的形式表示我的数据。在 Properties Build path 中,我给出了 jar 文件的路径。在 Order and Import 选项卡中,我检查了 achartengine-1.0.0.jar 选项。但是在调试我的应用程序时,它仍然显示“源附件不包含文件 ChartFactory.class 的源”。这是代码,

 import org.achartengine.ChartFactory;
 import org.achartengine.GraphicalView;
 import org.achartengine.chart.PointStyle;
 import org.achartengine.chart.BarChart.Type;
 import org.achartengine.model.XYMultipleSeriesDataset;
 import org.achartengine.model.XYSeries;
 import org.achartengine.renderer.XYMultipleSeriesRenderer;
 import org.achartengine.renderer.XYSeriesRenderer;


public class MainActivity extends Activity {

  private static final int SERIES_NR = 2;
  public final android.content.Context Context = MainActivity.this;    


  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
   Button ReportGraph=(Button)findViewById(R.id.ReportGraph);
   ReportGraph.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            RelativeLayout relChartView=(RelativeLayout)findViewById(R.id.ChartView);
            GraphicalView GraphChartView = ChartFactory.getBarChartView(getApplicationContext(), getDemoDataset(), getDemoRenderer(),Type.DEFAULT);
            //ChartFactory.getLineChartIntent(this, getDemoDataset(), getDemoRenderer());
            relChartView.addView(GraphChartView);
        }
    });

}

  private XYMultipleSeriesDataset getDemoDataset() {
    XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
    final int nr = 7;
    Random r = new Random();
    for (int i = 0; i < SERIES_NR; i++) {
        XYSeries series = new XYSeries("Demo series " + (i + 1));
        for (int k = 0; k < nr; k++) {
            series.add(k, 20 + r.nextInt() % 100);
        }
        dataset.addSeries(series);
    }
    return dataset;
}

private XYMultipleSeriesRenderer getDemoRenderer() {
    XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer();
    renderer.setAxisTitleTextSize(12);
    renderer.setChartTitleTextSize(12);
    renderer.setLabelsTextSize(15);
    renderer.setLegendTextSize(15);
    renderer.setPointSize(5f);
    renderer.setMargins(new int[] { 20, 30, 15, 0 });
    XYSeriesRenderer r = new XYSeriesRenderer();
    r.setColor(Color.BLUE);
    r.setPointStyle(PointStyle.DIAMOND);
    r.setFillBelowLine(false);
    r.setFillPoints(true);
    renderer.addSeriesRenderer(r);
    setChartSettings(renderer);
    return renderer;
}

private void setChartSettings(XYMultipleSeriesRenderer renderer) {
    renderer.setChartTitle("Chart demo");
    renderer.setXTitle("x values");
    renderer.setYTitle("y values");
    renderer.setApplyBackgroundColor(false);
    renderer.setRange(new double[] {0,6,-70,40});
    renderer.setFitLegend(false);
    renderer.setAxesColor(Color.BLACK);
    renderer.setShowGrid(true);
    renderer.setXAxisMin(0.5);
    renderer.setXAxisMax(10.5);
    renderer.setYAxisMin(0);
    renderer.setZoomEnabled(false);
    renderer.setYAxisMax(100);
  }
}

请任何人帮助我。任何帮助将不胜感激!!!谢谢。

4

1 回答 1

0

您可以按照此处的说明获取整个 AChartEngine 源代码。您无需费心反编译它。

于 2013-03-20T07:07:17.833 回答