面积图,面积图示例

时间:2013-12-10 06:29:27

标签: android

区域图表有一个很好的例子或教程吗?我已经在iOS中轻松完成了,但在android上遇到了麻烦。就像这里显示的那样:

screenshot area chart

3 个答案:

答案 0 :(得分:1)

  You can use achartengine library. 

有关详细信息,请参阅此链接 -

http://www.achartengine.org/content/demo.html

答案 1 :(得分:0)

我认为this link可以帮助您 - 尝试本教程。它将创建一个简单的XYPlot

package com.androidplot.demos;
import android.app.Activity;
import android.os.Bundle;
import android.view.WindowManager;
import com.androidplot.xy.SimpleXYSeries;
import com.androidplot.xy.XYSeries;
import com.androidplot.xy.*;
import java.util.Arrays;

/**
 * A straightforward example of using AndroidPlot to plot some data.
 */
public class SimpleXYPlotActivity extends Activity
{

    private XYPlot plot;

    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);

        // fun little snippet that prevents users from taking screenshots
        // on ICS+ devices :-)
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE,
                                 WindowManager.LayoutParams.FLAG_SECURE);

        setContentView(R.layout.simple_xy_plot_example);

        // initialize our XYPlot reference:
        plot = (XYPlot) findViewById(R.id.mySimpleXYPlot);

        // Create a couple arrays of y-values to plot:
        Number[] series1Numbers = {1, 8, 5, 2, 7, 4};
        Number[] series2Numbers = {4, 6, 3, 8, 2, 10};

        // Turn the above arrays into XYSeries':
        XYSeries series1 = new SimpleXYSeries(
                Arrays.asList(series1Numbers),          // SimpleXYSeries takes a List so turn our array into a List
                SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, // Y_VALS_ONLY means use the element index as the x value
                "Series1");                             // Set the display title of the series

        // same as above
        XYSeries series2 = new SimpleXYSeries(Arrays.asList(series2Numbers), SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "Series2");

        // Create a formatter to use for drawing a series using LineAndPointRenderer
        // and configure it from xml:
        LineAndPointFormatter series1Format = new LineAndPointFormatter();
        series1Format.setPointLabelFormatter(new PointLabelFormatter());
        series1Format.configure(getApplicationContext(),
                R.xml.line_point_formatter_with_plf1);

        // add a new series' to the xyplot:
        plot.addSeries(series1, series1Format);

        // same as above:
        LineAndPointFormatter series2Format = new LineAndPointFormatter();
        series2Format.setPointLabelFormatter(new PointLabelFormatter());
        series2Format.configure(getApplicationContext(),
                R.xml.line_point_formatter_with_plf2);
        plot.addSeries(series2, series2Format);

        // reduce the number of range labels
        plot.setTicksPerRangeLabel(3);
        plot.getGraphWidget().setDomainLabelOrientation(-45);

    }
}

答案 2 :(得分:0)

试试此链接:Creating the Area Chart

有一个示例程序,可以创建一个简单的区域图表:

  

为了创建一个简单的区域图表,需要创建一个实例   图表系列,将ChartType设置为Area并用一些数据填充系列,   如下例所示:

package com.artfulbits.aiCharts.areasample;

import com.artfulbits.aiCharts.ChartView;
import com.artfulbits.aiCharts.Base.*;

import android.app.Activity;
import android.os.Bundle;

public class MainActivity extends Activity
{
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        ChartView chartView = (ChartView) findViewById(R.id.chartView);
        ChartSeries series1 = chartView.getSeries().get("Series1");
        ChartSeries series2 = chartView.getSeries().get("Series2");
        double[] data1 = { 82, 75, 96, 65, 87 };
        double[] data2 = { 37, 28, 43, 48, 56 };
        series1.getPoints().setData(data1);
        series2.getPoints().setData(data2);
    }
}