Search in sources :

Example 6 with Line

use of lecho.lib.hellocharts.model.Line in project dobby-android by InceptAi.

the class RtGraphViewHolder method setupLineChart.

private void setupLineChart() {
    List<Line> lineList = new ArrayList<>(1);
    List<Float> rawPoints = graphData.getData();
    List<PointValue> pointList = new ArrayList<>(rawPoints.size());
    for (int i = 0; i < rawPoints.size(); i++) {
        pointList.add(new PointValue(i, rawPoints.get(i)));
    }
    Line line = new Line(pointList);
    line.setColor(ChartUtils.COLOR_ORANGE);
    line.setHasPoints(false);
    lineList.add(line);
    lineChartData.setLines(lineList);
    Axis axisX = new Axis();
    axisX.setLineColor(ChartUtils.COLOR_GREEN);
    axisX.setName("Time");
    Axis axisY = new Axis();
    axisY.setLineColor(ChartUtils.COLOR_GREEN);
    axisY.setName("Bandwidth");
    lineChartData.setAxisYLeft(axisY);
    lineChartData.setAxisXBottom(axisX);
    lineChartView.setLineChartData(lineChartData);
    resetViewport();
}
Also used : Line(lecho.lib.hellocharts.model.Line) PointValue(lecho.lib.hellocharts.model.PointValue) ArrayList(java.util.ArrayList) Axis(lecho.lib.hellocharts.model.Axis)

Example 7 with Line

use of lecho.lib.hellocharts.model.Line in project hellocharts-android by lecho.

the class LineChartRenderer method calculateMaxViewport.

private void calculateMaxViewport() {
    tempMaximumViewport.set(Float.MAX_VALUE, Float.MIN_VALUE, Float.MIN_VALUE, Float.MAX_VALUE);
    LineChartData data = dataProvider.getLineChartData();
    for (Line line : data.getLines()) {
        // Calculate max and min for viewport.
        for (PointValue pointValue : line.getValues()) {
            if (pointValue.getX() < tempMaximumViewport.left) {
                tempMaximumViewport.left = pointValue.getX();
            }
            if (pointValue.getX() > tempMaximumViewport.right) {
                tempMaximumViewport.right = pointValue.getX();
            }
            if (pointValue.getY() < tempMaximumViewport.bottom) {
                tempMaximumViewport.bottom = pointValue.getY();
            }
            if (pointValue.getY() > tempMaximumViewport.top) {
                tempMaximumViewport.top = pointValue.getY();
            }
        }
    }
}
Also used : Line(lecho.lib.hellocharts.model.Line) PointValue(lecho.lib.hellocharts.model.PointValue) LineChartData(lecho.lib.hellocharts.model.LineChartData)

Example 8 with Line

use of lecho.lib.hellocharts.model.Line in project hellocharts-android by lecho.

the class LineChartRenderer method drawUnclipped.

@Override
public void drawUnclipped(Canvas canvas) {
    final LineChartData data = dataProvider.getLineChartData();
    int lineIndex = 0;
    for (Line line : data.getLines()) {
        if (checkIfShouldDrawPoints(line)) {
            drawPoints(canvas, line, lineIndex, MODE_DRAW);
        }
        ++lineIndex;
    }
    if (isTouched()) {
        // Redraw touched point to bring it to the front
        highlightPoints(canvas);
    }
}
Also used : Line(lecho.lib.hellocharts.model.Line) LineChartData(lecho.lib.hellocharts.model.LineChartData) Paint(android.graphics.Paint)

Example 9 with Line

use of lecho.lib.hellocharts.model.Line in project CoCoin by Nightonke.

the class SplashActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash);
    mContext = this;
    chart = (LineChartView) findViewById(R.id.chart);
    List<Line> lines = new ArrayList<Line>();
    for (int i = 0; i < NUMBER_OF_LINES; ++i) {
        List<PointValue> values = new ArrayList<PointValue>();
        values.add(new PointValue(0, 0));
        values.add(new PointValue(1, 15));
        values.add(new PointValue(2, 10));
        values.add(new PointValue(3, 23));
        values.add(new PointValue(3.5f, 48));
        values.add(new PointValue(5, 60));
        Line line = new Line(values);
        line.setColor(Color.WHITE);
        line.setShape(ValueShape.CIRCLE);
        line.setCubic(false);
        line.setFilled(false);
        line.setHasLabels(false);
        line.setHasLabelsOnlyForSelected(false);
        line.setHasLines(true);
        line.setHasPoints(true);
        lines.add(line);
    }
    data = new LineChartData(lines);
    data.setBaseValue(Float.NEGATIVE_INFINITY);
    chart.setLineChartData(data);
    image = (ImageView) findViewById(R.id.image);
    appName = (TextView) findViewById(R.id.app_name);
    appName.setTypeface(CoCoinUtil.getInstance().typefaceLatoLight);
    loadingText = (TextView) findViewById(R.id.loading_text);
    loadingText.setTypeface(CoCoinUtil.getInstance().typefaceLatoLight);
    reveal = (RevealFrameLayout) findViewById(R.id.reveal);
    ly = (LinearLayout) findViewById(R.id.ly);
    new InitData().execute();
}
Also used : Line(lecho.lib.hellocharts.model.Line) PointValue(lecho.lib.hellocharts.model.PointValue) ArrayList(java.util.ArrayList) LineChartData(lecho.lib.hellocharts.model.LineChartData)

Aggregations

Line (lecho.lib.hellocharts.model.Line)9 LineChartData (lecho.lib.hellocharts.model.LineChartData)7 PointValue (lecho.lib.hellocharts.model.PointValue)5 Paint (android.graphics.Paint)4 ArrayList (java.util.ArrayList)3 Canvas (android.graphics.Canvas)1 Point (android.graphics.Point)1 ViewPager (android.support.v4.view.ViewPager)1 DisplayMetrics (android.util.DisplayMetrics)1 View (android.view.View)1 ViewTreeObserver (android.view.ViewTreeObserver)1 AdapterView (android.widget.AdapterView)1 ImageView (android.widget.ImageView)1 RelativeLayout (android.widget.RelativeLayout)1 TextView (android.widget.TextView)1 DotsView (com.dev.sacot41.scviewpager.DotsView)1 SCPositionAnimation (com.dev.sacot41.scviewpager.SCPositionAnimation)1 SCViewAnimation (com.dev.sacot41.scviewpager.SCViewAnimation)1 SCViewPager (com.dev.sacot41.scviewpager.SCViewPager)1 SCViewPagerAdapter (com.dev.sacot41.scviewpager.SCViewPagerAdapter)1