lecho.lib.hellocharts.model.ValueShape Java Examples

The following examples show how to use lecho.lib.hellocharts.model.ValueShape. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StatisticViewModel.java    From OmniList with GNU Affero General Public License v3.0 6 votes vote down vote up
private Line getLine(List<Integer> lineStatistics, int color) {
    List<PointValue> values = new LinkedList<>();
    int length = lineStatistics.size();
    for (int j = 0; j < length; ++j) {
        values.add(new PointValue(j, lineStatistics.get(j)));
    }
    LogUtils.d("getLineChartData: " + lineStatistics);

    Line line = new Line(values);
    line.setColor(color);
    line.setShape(ValueShape.CIRCLE);
    line.setCubic(false);
    line.setFilled(true);
    line.setHasLabels(true);
    line.setHasLines(true);
    line.setHasPoints(true);
    line.setPointRadius(3);

    return line;
}
 
Example #2
Source File: LineChartActivity.java    From hellocharts-android with Apache License 2.0 6 votes vote down vote up
private void reset() {
    numberOfLines = 1;

    hasAxes = true;
    hasAxesNames = true;
    hasLines = true;
    hasPoints = true;
    shape = ValueShape.CIRCLE;
    isFilled = false;
    hasLabels = false;
    isCubic = false;
    hasLabelForSelected = false;
    pointsHaveDifferentColor = false;

    chart.setValueSelectionEnabled(hasLabelForSelected);
    resetViewport();
}
 
Example #3
Source File: BgGraphBuilder.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
public List<Line> extraLines()
{
    final List<Line> lines = new ArrayList<>();
    Line bloodtest = new Line(bloodTestValues);
    bloodtest.setHasLines(false);
    bloodtest.setPointRadius(pointSize * 5 / 3);//3 / 2
    bloodtest.setHasPoints(true);
    bloodtest.setColor(highColor);//ChartUtils.darkenColor(getCol(X.color_calibration_dot_background))
    bloodtest.setShape(ValueShape.SQUARE);
    lines.add(bloodtest);

    Line bloodtesti = new Line(bloodTestValues);
    bloodtesti.setHasLines(false);
    bloodtesti.setPointRadius(pointSize * 5 / 4);//3 / 4
    bloodtesti.setHasPoints(true);
    bloodtesti.setColor(lowColor);//ChartUtils.darkenColor(getCol(X.color_calibration_dot_foreground))
    bloodtesti.setShape(ValueShape.SQUARE);
    lines.add(bloodtesti);

    return lines;
}
 
Example #4
Source File: LineChartRenderer.java    From hellocharts-android with Apache License 2.0 6 votes vote down vote up
private void drawPoint(Canvas canvas, Line line, PointValue pointValue, float rawX, float rawY,
                       float pointRadius) {
    if (ValueShape.SQUARE.equals(line.getShape())) {
        canvas.drawRect(rawX - pointRadius, rawY - pointRadius, rawX + pointRadius, rawY + pointRadius,
                pointPaint);
    } else if (ValueShape.CIRCLE.equals(line.getShape())) {
        canvas.drawCircle(rawX, rawY, pointRadius, pointPaint);
    } else if (ValueShape.DIAMOND.equals(line.getShape())) {
        canvas.save();
        canvas.rotate(45, rawX, rawY);
        canvas.drawRect(rawX - pointRadius, rawY - pointRadius, rawX + pointRadius, rawY + pointRadius,
                pointPaint);
        canvas.restore();
    } else {
        throw new IllegalArgumentException("Invalid point shape: " + line.getShape());
    }
}
 
Example #5
Source File: BubbleChartRenderer.java    From hellocharts-android with Apache License 2.0 6 votes vote down vote up
/**
 * Calculate bubble radius and center x and y coordinates. Center x and x will be stored in point parameter, radius
 * will be returned as float value.
 */
private float processBubble(BubbleValue bubbleValue, PointF point) {
    final float rawX = computator.computeRawX(bubbleValue.getX());
    final float rawY = computator.computeRawY(bubbleValue.getY());
    float radius = (float) Math.sqrt(Math.abs(bubbleValue.getZ()) / Math.PI);
    float rawRadius;
    if (isBubbleScaledByX) {
        radius *= bubbleScaleX;
        rawRadius = computator.computeRawDistanceX(radius);
    } else {
        radius *= bubbleScaleY;
        rawRadius = computator.computeRawDistanceY(radius);
    }

    if (rawRadius < minRawRadius + touchAdditional) {
        rawRadius = minRawRadius + touchAdditional;
    }

    bubbleCenter.set(rawX, rawY);
    if (ValueShape.SQUARE.equals(bubbleValue.getShape())) {
        bubbleRect.set(rawX - rawRadius, rawY - rawRadius, rawX + rawRadius, rawY + rawRadius);
    }
    return rawRadius;
}
 
Example #6
Source File: BgGraphBuilder.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
public List<Line> extraLines()
{
    final List<Line> lines = new ArrayList<>();
    Line bloodtest = new Line(bloodTestValues);
    bloodtest.setHasLines(false);
    bloodtest.setPointRadius(pointSize * 5 / 3);//3 / 2
    bloodtest.setHasPoints(true);
    bloodtest.setColor(highColor);//ChartUtils.darkenColor(getCol(X.color_calibration_dot_background))
    bloodtest.setShape(ValueShape.SQUARE);
    lines.add(bloodtest);

    Line bloodtesti = new Line(bloodTestValues);
    bloodtesti.setHasLines(false);
    bloodtesti.setPointRadius(pointSize * 5 / 4);//3 / 4
    bloodtesti.setHasPoints(true);
    bloodtesti.setColor(lowColor);//ChartUtils.darkenColor(getCol(X.color_calibration_dot_foreground))
    bloodtesti.setShape(ValueShape.SQUARE);
    lines.add(bloodtesti);

    return lines;
}
 
Example #7
Source File: BubbleChartRenderer.java    From hellocharts-android with Apache License 2.0 6 votes vote down vote up
private void drawBubbleShapeAndLabel(Canvas canvas, BubbleValue bubbleValue, float rawRadius, int mode) {
    if (ValueShape.SQUARE.equals(bubbleValue.getShape())) {
        canvas.drawRect(bubbleRect, bubblePaint);
    } else if (ValueShape.CIRCLE.equals(bubbleValue.getShape())) {
        canvas.drawCircle(bubbleCenter.x, bubbleCenter.y, rawRadius, bubblePaint);
    } else {
        throw new IllegalArgumentException("Invalid bubble shape: " + bubbleValue.getShape());
    }

    if (MODE_HIGHLIGHT == mode) {
        if (hasLabels || hasLabelsOnlyForSelected) {
            drawLabel(canvas, bubbleValue, bubbleCenter.x, bubbleCenter.y);
        }
    } else if (MODE_DRAW == mode) {
        if (hasLabels) {
            drawLabel(canvas, bubbleValue, bubbleCenter.x, bubbleCenter.y);
        }
    } else {
        throw new IllegalStateException("Cannot process bubble in mode: " + mode);
    }
}
 
Example #8
Source File: BubbleChartRenderer.java    From hellocharts-android with Apache License 2.0 5 votes vote down vote up
@Override
public boolean checkTouch(float touchX, float touchY) {
    selectedValue.clear();
    final BubbleChartData data = dataProvider.getBubbleChartData();
    int valueIndex = 0;
    for (BubbleValue bubbleValue : data.getValues()) {
        float rawRadius = processBubble(bubbleValue, bubbleCenter);

        if (ValueShape.SQUARE.equals(bubbleValue.getShape())) {
            if (bubbleRect.contains(touchX, touchY)) {
                selectedValue.set(valueIndex, valueIndex, SelectedValueType.NONE);
            }
        } else if (ValueShape.CIRCLE.equals(bubbleValue.getShape())) {
            final float diffX = touchX - bubbleCenter.x;
            final float diffY = touchY - bubbleCenter.y;
            final float touchDistance = (float) Math.sqrt((diffX * diffX) + (diffY * diffY));

            if (touchDistance <= rawRadius) {
                selectedValue.set(valueIndex, valueIndex, SelectedValueType.NONE);
            }
        } else {
            throw new IllegalArgumentException("Invalid bubble shape: " + bubbleValue.getShape());
        }

        ++valueIndex;
    }

    return isTouched();
}
 
Example #9
Source File: BubbleChartActivity.java    From hellocharts-android with Apache License 2.0 5 votes vote down vote up
private void reset() {
    hasAxes = true;
    hasAxesNames = true;
    shape = ValueShape.CIRCLE;
    hasLabels = false;
    hasLabelForSelected = false;

    chart.setValueSelectionEnabled(hasLabelForSelected);
}
 
Example #10
Source File: LineCharts.java    From MetalDetector with GNU General Public License v3.0 5 votes vote down vote up
protected void makeCharts(final LineChartView lineChartView,float uT){
    //实时添加新的点
    PointValue value1 = new PointValue(position * 5, uT);
    value1.setLabel("00:00");
    pointValueList.add(value1);
    float x = value1.getX();
    float y = uT;
    //根据新的点的集合画出新的线
    Line line = new Line(pointValueList);
    line.setColor(Color.RED);
    line.setShape(ValueShape.CIRCLE);
    line.setCubic(true);//曲线是否平滑
    line.setHasPoints(false);//设置折线是否含点
    linesList.clear();
    linesList.add(line);
    lineChartData = initData(linesList);
    lineChartView.setLineChartData(lineChartData);
    //根据点的横坐实时变换坐标的视图范围
    Viewport port;
    if (x > 500) {
            port = initViewPort(x - 500, x, y);
    } else {
        port = initViewPort(0, 500 ,y);
    }
    lineChartView.setCurrentViewport(port);//当前窗口

    Viewport maxPort = initMaxViewPort(x,y);//更新最大窗口设置
    lineChartView.setMaximumViewport(maxPort);//最大窗口
    position++;
}
 
Example #11
Source File: BgGraphBuilder.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public List<Line> extraLines()
{
    final List<Line> lines = new ArrayList<>();
    Line line = new Line(pluginValues);
    line.setHasLines(false);
    line.setPointRadius(pluginSize);
    line.setHasPoints(true);
    line.setColor(getCol(X.color_secondary_glucose_value));
    lines.add(line);

    Line bloodtest = new Line(bloodTestValues);
    bloodtest.setHasLines(false);
    bloodtest.setPointRadius(pointSize * 3 / 2);
    bloodtest.setHasPoints(true);
    bloodtest.setColor(ChartUtils.darkenColor(getCol(X.color_calibration_dot_background)));
    bloodtest.setShape(ValueShape.SQUARE);
    lines.add(bloodtest);

    Line bloodtesti = new Line(bloodTestValues);
    bloodtesti.setHasLines(false);
    bloodtesti.setPointRadius(pointSize * 3 / 4);
    bloodtesti.setHasPoints(true);
    bloodtesti.setColor(ChartUtils.darkenColor(getCol(X.color_calibration_dot_foreground)));
    bloodtesti.setShape(ValueShape.SQUARE);
    lines.add(bloodtesti);

    return lines;
}
 
Example #12
Source File: BgGraphBuilder.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public Line[] treatmentValuesLine() {
    Line[] lines = new Line[2];
    try {

        lines[0] = new Line(treatmentValues);
        lines[0].setColor(highColor);//getCol(X.color_treatment_dot_background) 0xFFFFFF
        lines[0].setHasLines(false);
        lines[0].setPointRadius(pointSize * 5 / 3);//pointSize * 5 / 2
        lines[0].setHasPoints(true);
        lines[0].setShape(ValueShape.DIAMOND);//KS

        lines[1] = new Line(treatmentValues);
        lines[1].setColor(Color.GREEN);//getCol(X.color_treatment_dot_foreground)//0x77aa00 //lowColor
        lines[1].setHasLines(false);
        lines[1].setPointRadius(pointSize * 5 / 4);//pointSize * 5 / 4
        lines[1].setHasPoints(true);
        lines[1].setShape(ValueShape.DIAMOND);
        //lines[1].setHasLabels(true);

        LineChartValueFormatter formatter = new SimpleLineChartValueFormatter(1);
        lines[1].setFormatter(formatter);

    } catch (Exception e) {
        if (d) UserError.Log.i(TAG, "Exception making treatment lines: " + e.toString());
    }
    return lines;
}
 
Example #13
Source File: BgGraphBuilder.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
public List<Line> extraLines()
{
    final List<Line> lines = new ArrayList<>();
    Line line = new Line(pluginValues);
    line.setHasLines(false);
    line.setPointRadius(pluginSize);
    line.setHasPoints(true);
    line.setColor(getCol(X.color_secondary_glucose_value));
    lines.add(line);

    Line bloodtest = new Line(bloodTestValues);
    bloodtest.setHasLines(false);
    bloodtest.setPointRadius(pointSize * 3 / 2);
    bloodtest.setHasPoints(true);
    bloodtest.setColor(ChartUtils.darkenColor(getCol(X.color_calibration_dot_background)));
    bloodtest.setShape(ValueShape.SQUARE);
    lines.add(bloodtest);

    Line bloodtesti = new Line(bloodTestValues);
    bloodtesti.setHasLines(false);
    bloodtesti.setPointRadius(pointSize * 3 / 4);
    bloodtesti.setHasPoints(true);
    bloodtesti.setColor(ChartUtils.darkenColor(getCol(X.color_calibration_dot_foreground)));
    bloodtesti.setShape(ValueShape.SQUARE);
    lines.add(bloodtesti);

    return lines;
}
 
Example #14
Source File: BgGraphBuilder.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
public Line[] treatmentValuesLine() {
    Line[] lines = new Line[2];
    try {

        lines[0] = new Line(treatmentValues);
        lines[0].setColor(highColor);//getCol(X.color_treatment_dot_background) 0xFFFFFF
        lines[0].setHasLines(false);
        lines[0].setPointRadius(pointSize * 5 / 3);//pointSize * 5 / 2
        lines[0].setHasPoints(true);
        lines[0].setShape(ValueShape.DIAMOND);//KS

        lines[1] = new Line(treatmentValues);
        lines[1].setColor(Color.GREEN);//getCol(X.color_treatment_dot_foreground)//0x77aa00 //lowColor
        lines[1].setHasLines(false);
        lines[1].setPointRadius(pointSize * 5 / 4);//pointSize * 5 / 4
        lines[1].setHasPoints(true);
        lines[1].setShape(ValueShape.DIAMOND);
        //lines[1].setHasLabels(true);

        LineChartValueFormatter formatter = new SimpleLineChartValueFormatter(1);
        lines[1].setFormatter(formatter);

    } catch (Exception e) {
        if (d) UserError.Log.i(TAG, "Exception making treatment lines: " + e.toString());
    }
    return lines;
}
 
Example #15
Source File: BgGraphBuilder.java    From xDrip-plus with GNU General Public License v3.0 4 votes vote down vote up
public Line[] treatmentValuesLine() {
    Line[] lines = new Line[9];
    try {

        lines[0] = new Line(treatmentValues);
        lines[0].setColor(getCol(X.color_treatment_dot_background));
        lines[0].setHasLines(false);
        lines[0].setPointRadius(pointSize * 5 / 2);
        lines[0].setHasPoints(true);

        lines[1] = new Line(treatmentValues);
        lines[1].setColor(getCol(X.color_treatment_dot_foreground));
        lines[1].setHasLines(false);
        lines[1].setPointRadius(pointSize * 5 / 4);
        lines[1].setHasPoints(true);
        lines[1].setShape(ValueShape.DIAMOND);
        lines[1].setHasLabels(true);

        LineChartValueFormatter formatter = new SimpleLineChartValueFormatter(1);
        lines[1].setFormatter(formatter);

        // insulin on board
        lines[2] = new Line(iobValues);
        lines[2].setColor(getCol(X.color_treatment));
        // need splitter for cubics
        lines[2].setHasLines(true);
        lines[2].setCubic(false);
        lines[2].setFilled(true);
        lines[2].setAreaTransparency(35);
        lines[2].setFilled(true);
        lines[2].setPointRadius(1);
        lines[2].setHasPoints(true);
        // lines[2].setShape(ValueShape.DIAMOND);
        // lines[2].setHasLabels(true);

        // iactivity on board
        lines[3] = new Line(activityValues);
        lines[3].setColor(getCol(X.color_treatment_dark));
        lines[3].setHasLines(false);
        lines[3].setCubic(false);
        lines[3].setFilled(false);

        lines[3].setFilled(false);
        lines[3].setPointRadius(1);
        lines[3].setHasPoints(true);

        // annotations
        lines[4] = new Line(annotationValues);
        lines[4].setColor(getCol(X.color_treatment_dot_foreground));
        lines[4].setHasLines(false);
        lines[4].setCubic(false);
        lines[4].setFilled(false);
        lines[4].setPointRadius(0);
        lines[4].setHasPoints(true);
        lines[4].setHasLabels(true);

        lines[5] = new Line(predictedBgValues);
        lines[5].setColor(getCol(X.color_predictive));
        lines[5].setHasLines(false);
        lines[5].setCubic(false);
        lines[5].setStrokeWidth(1);
        lines[5].setFilled(false);
        lines[5].setPointRadius(2);
        lines[5].setHasPoints(true);
        lines[5].setHasLabels(false);

        lines[6] = new Line(cobValues);
        lines[6].setColor(getCol(X.color_predictive_dark));
        lines[6].setHasLines(false);
        lines[6].setCubic(false);
        lines[6].setFilled(false);
        lines[6].setPointRadius(1);
        lines[6].setHasPoints(true);
        lines[6].setHasLabels(false);

        lines[7] = new Line(polyBgValues);
        lines[7].setColor(ChartUtils.COLOR_RED);
        lines[7].setHasLines(false);
        lines[7].setCubic(false);
        lines[7].setStrokeWidth(1);
        lines[7].setFilled(false);
        lines[7].setPointRadius(1);
        lines[7].setHasPoints(true);
        lines[7].setHasLabels(false);

        lines[8] = new Line(noisePolyBgValues);
        lines[8].setColor(ChartUtils.COLOR_ORANGE);
        lines[8].setHasLines(true);
        lines[8].setCubic(false);
        lines[8].setStrokeWidth(1);
        lines[8].setFilled(false);
        lines[8].setPointRadius(1);
        lines[8].setHasPoints(true);
        lines[8].setHasLabels(false);


    } catch (Exception e) {
        if (d) Log.i(TAG, "Exception making treatment lines: " + e.toString());
    }
    return lines;
}
 
Example #16
Source File: BgGraphBuilder.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
public Line[] treatmentValuesLine() {
    Line[] lines = new Line[9];
    try {

        lines[0] = new Line(treatmentValues);
        lines[0].setColor(getCol(X.color_treatment_dot_background));
        lines[0].setHasLines(false);
        lines[0].setPointRadius(pointSize * 5 / 2);
        lines[0].setHasPoints(true);

        lines[1] = new Line(treatmentValues);
        lines[1].setColor(getCol(X.color_treatment_dot_foreground));
        lines[1].setHasLines(false);
        lines[1].setPointRadius(pointSize * 5 / 4);
        lines[1].setHasPoints(true);
        lines[1].setShape(ValueShape.DIAMOND);
        lines[1].setHasLabels(true);

        LineChartValueFormatter formatter = new SimpleLineChartValueFormatter(1);
        lines[1].setFormatter(formatter);

        // insulin on board
        lines[2] = new Line(iobValues);
        lines[2].setColor(getCol(X.color_treatment));
        // need splitter for cubics
        lines[2].setHasLines(true);
        lines[2].setCubic(false);
        lines[2].setFilled(true);
        lines[2].setAreaTransparency(35);
        lines[2].setFilled(true);
        lines[2].setPointRadius(1);
        lines[2].setHasPoints(true);
        // lines[2].setShape(ValueShape.DIAMOND);
        // lines[2].setHasLabels(true);

        // iactivity on board
        lines[3] = new Line(activityValues);
        lines[3].setColor(getCol(X.color_treatment_dark));
        lines[3].setHasLines(false);
        lines[3].setCubic(false);
        lines[3].setFilled(false);

        lines[3].setFilled(false);
        lines[3].setPointRadius(1);
        lines[3].setHasPoints(true);

        // annotations
        lines[4] = new Line(annotationValues);
        lines[4].setColor(getCol(X.color_treatment_dot_foreground));
        lines[4].setHasLines(false);
        lines[4].setCubic(false);
        lines[4].setFilled(false);
        lines[4].setPointRadius(0);
        lines[4].setHasPoints(true);
        lines[4].setHasLabels(true);

        lines[5] = new Line(predictedBgValues);
        lines[5].setColor(getCol(X.color_predictive));
        lines[5].setHasLines(false);
        lines[5].setCubic(false);
        lines[5].setStrokeWidth(1);
        lines[5].setFilled(false);
        lines[5].setPointRadius(2);
        lines[5].setHasPoints(true);
        lines[5].setHasLabels(false);

        lines[6] = new Line(cobValues);
        lines[6].setColor(getCol(X.color_predictive_dark));
        lines[6].setHasLines(false);
        lines[6].setCubic(false);
        lines[6].setFilled(false);
        lines[6].setPointRadius(1);
        lines[6].setHasPoints(true);
        lines[6].setHasLabels(false);

        lines[7] = new Line(polyBgValues);
        lines[7].setColor(ChartUtils.COLOR_RED);
        lines[7].setHasLines(false);
        lines[7].setCubic(false);
        lines[7].setStrokeWidth(1);
        lines[7].setFilled(false);
        lines[7].setPointRadius(1);
        lines[7].setHasPoints(true);
        lines[7].setHasLabels(false);

        lines[8] = new Line(noisePolyBgValues);
        lines[8].setColor(ChartUtils.COLOR_ORANGE);
        lines[8].setHasLines(true);
        lines[8].setCubic(false);
        lines[8].setStrokeWidth(1);
        lines[8].setFilled(false);
        lines[8].setPointRadius(1);
        lines[8].setHasPoints(true);
        lines[8].setHasLabels(false);


    } catch (Exception e) {
        if (d) Log.i(TAG, "Exception making treatment lines: " + e.toString());
    }
    return lines;
}
 
Example #17
Source File: BubbleChartActivity.java    From hellocharts-android with Apache License 2.0 4 votes vote down vote up
private void setCircles() {
    shape = ValueShape.CIRCLE;
    generateData();
}
 
Example #18
Source File: BubbleChartActivity.java    From hellocharts-android with Apache License 2.0 4 votes vote down vote up
private void setSquares() {
    shape = ValueShape.SQUARE;
    generateData();
}
 
Example #19
Source File: MainActivity.java    From healthgo with GNU General Public License v3.0 4 votes vote down vote up
private void initLineChart() {
        Line line = new Line(mPointValues).setColor(Color.parseColor("#FFFAFA"));  //折线的颜色(橙色)
        List<Line> lines = new ArrayList<>();
        line.setShape(ValueShape.CIRCLE);//折线图上每个数据点的形状  这里是圆形 (有三种 :ValueShape.SQUARE  ValueShape.CIRCLE  ValueShape.DIAMOND)
        line.setCubic(false);//曲线是否平滑,即是曲线还是折线
        line.setFilled(false);//是否填充曲线的面积
        line.setHasLabels(true);//曲线的数据坐标是否加上备注
//      line.setHasLabelsOnlyForSelected(true);//点击数据坐标提示数据(设置了这个line.setHasLabels(true);就无效)
        line.setHasLines(true);//是否用线显示。如果为false 则没有曲线只有点显示
        line.setHasPoints(true);//是否显示圆点 如果为false 则没有原点只有点显示(每个数据点都是个大的圆点)
        lines.add(line);
        LineChartData data = new LineChartData();
        data.setLines(lines);

        //坐标轴
        Axis axisX = new Axis(); //X轴
        axisX.setHasTiltedLabels(true);  //X坐标轴字体是斜的显示还是直的,true是斜的显示
        axisX.setTextColor(Color.WHITE);  //设置字体颜色
        //axisX.setName("date");  //表格名称
        axisX.setTextSize(10);//设置字体大小
        axisX.setMaxLabelChars(8); //最多几个X轴坐标,意思就是你的缩放让X轴上数据的个数7<=x<=mAxisXValues.length
        axisX.setValues(mAxisXValues);  //填充X轴的坐标名称
        data.setAxisXBottom(axisX); //x 轴在底部
        //data.setAxisXTop(axisX);  //x 轴在顶部
        axisX.setHasLines(true); //x 轴分割线

        // Y轴是根据数据的大小自动设置Y轴上限(在下面我会给出固定Y轴数据个数的解决方案)
        Axis axisY = new Axis();

        axisY.setName("");//y轴标注
        // axisY.setTextSize(10);//设置字体大小
        axisY.setTextColor(Color.parseColor("#ffffff"));
        data.setAxisYLeft(axisY);  //Y轴设置在左边
        //data.setAxisYRight(axisY);  //y轴设置在右边


        //设置行为属性,支持缩放、滑动以及平移
        lineChart.setInteractive(true);
        lineChart.setZoomType(ZoomType.HORIZONTAL);
        lineChart.setMaxZoom((float) 2);//最大方法比例
        lineChart.setContainerScrollEnabled(true, ContainerScrollType.HORIZONTAL);
        lineChart.setLineChartData(data);
        lineChart.setVisibility(View.VISIBLE);
        /**注:下面的7,10只是代表一个数字去类比而已
         * 当时是为了解决X轴固定数据个数。见(http://forum.xda-developers.com/tools/programming/library-hellocharts-charting-library-t2904456/page2);
         */
//        Viewport v = new Viewport(lineChart.getMaximumViewport());
//        v.left = 0;
//        v.right= 7;
//        lineChart.setCurrentViewport(v);
    }
 
Example #20
Source File: LineChartActivity.java    From hellocharts-android with Apache License 2.0 4 votes vote down vote up
private void setCircles() {
    shape = ValueShape.CIRCLE;

    generateData();
}
 
Example #21
Source File: LineChartActivity.java    From hellocharts-android with Apache License 2.0 4 votes vote down vote up
private void setSquares() {
    shape = ValueShape.SQUARE;

    generateData();
}
 
Example #22
Source File: LineChartActivity.java    From hellocharts-android with Apache License 2.0 4 votes vote down vote up
private void setDiamonds() {
    shape = ValueShape.DIAMOND;

    generateData();
}