Android Open Source - line-chart-view Line Chart Activity






From Project

Back to project page line-chart-view.

License

The source code is released under:

MIT License

If you think the Android project line-chart-view listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package org.hogel.android.linechartviewdemo;
//from   www .j a  v  a  2  s  . co m
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import org.hogel.android.linechartview.LineChartView;

import java.util.ArrayList;
import java.util.List;

public class LineChartActivity extends Activity {
    private static final double MAX_Y = 100;
    private LineChartView chartView;

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

        setContentView(R.layout.activity_chart);

        chartView  = (LineChartView) findViewById(R.id.chart_view);
        chartView.setManualMinY(0);

        View nextButton = findViewById(R.id.next_data);
        nextButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                nextChartData();
            }
        });
    }

    private void nextChartData() {
        List<LineChartView.Point> points = new ArrayList<>();
        for (int i = 0; i < 5; i++) {
            int y = (int) (Math.random() * MAX_Y);
            points.add(new LineChartView.Point(i, y));
        }
        chartView.setPoints(points);
    }
}




Java Source Code List

org.hogel.android.linechartview.DateLineChartView.java
org.hogel.android.linechartview.LineChartStyle.java
org.hogel.android.linechartview.LineChartViewTest.java
org.hogel.android.linechartview.LineChartView.java
org.hogel.android.linechartview.ViewTestBase.java
org.hogel.android.linechartviewdemo.DateLineChartActivity.java
org.hogel.android.linechartviewdemo.LineChartActivity.java
org.hogel.android.linechartviewdemo.MainActivity.java