Search in sources :

Example 1 with SimpleAxisValueFormatter

use of lecho.lib.hellocharts.formatter.SimpleAxisValueFormatter in project xDrip-plus by jamorham.

the class BasalChart method chartYAxis.

// TODO recalculate axis on every change
@NonNull
public static Axis chartYAxis(float max_height) {
    Axis yAxis = new Axis();
    yAxis.setAutoGenerated(false);
    yAxis.setHasLines(true);
    // max_height = max_height * 3;
    final float yStep = chooseClosestStep(max_height / 20f);
    // rounding???
    final List<AxisValue> axisValues = new ArrayList<>();
    // TODO autoscale this - rebuild on data change??
    for (float j = 0; j <= max_height + yStep; j += yStep) {
        axisValues.add(new AxisValue(j));
    }
    yAxis.setValues(axisValues);
    // yAxis.setHasLines(true);
    yAxis.setMaxLabelChars(5);
    yAxis.setInside(false);
    // yAxis.setTextSize(axisTextSize);
    AxisValueFormatter formatter = new SimpleAxisValueFormatter(2);
    yAxis.setFormatter(formatter);
    return yAxis;
}
Also used : AxisValue(lecho.lib.hellocharts.model.AxisValue) SimpleAxisValueFormatter(lecho.lib.hellocharts.formatter.SimpleAxisValueFormatter) ArrayList(java.util.ArrayList) Axis(lecho.lib.hellocharts.model.Axis) SimpleAxisValueFormatter(lecho.lib.hellocharts.formatter.SimpleAxisValueFormatter) AxisValueFormatter(lecho.lib.hellocharts.formatter.AxisValueFormatter) NonNull(android.support.annotation.NonNull)

Example 2 with SimpleAxisValueFormatter

use of lecho.lib.hellocharts.formatter.SimpleAxisValueFormatter in project xDrip by NightscoutFoundation.

the class BasalChart method chartYAxis.

// TODO recalculate axis on every change
@NonNull
public static Axis chartYAxis(float max_height) {
    Axis yAxis = new Axis();
    yAxis.setAutoGenerated(false);
    yAxis.setHasLines(true);
    // max_height = max_height * 3;
    final float yStep = chooseClosestStep(max_height / 20f);
    // rounding???
    final List<AxisValue> axisValues = new ArrayList<>();
    // TODO autoscale this - rebuild on data change??
    for (float j = 0; j <= max_height + yStep; j += yStep) {
        axisValues.add(new AxisValue(j));
    }
    yAxis.setValues(axisValues);
    // yAxis.setHasLines(true);
    yAxis.setMaxLabelChars(5);
    yAxis.setInside(false);
    // yAxis.setTextSize(axisTextSize);
    AxisValueFormatter formatter = new SimpleAxisValueFormatter(2);
    yAxis.setFormatter(formatter);
    return yAxis;
}
Also used : AxisValue(lecho.lib.hellocharts.model.AxisValue) SimpleAxisValueFormatter(lecho.lib.hellocharts.formatter.SimpleAxisValueFormatter) ArrayList(java.util.ArrayList) Axis(lecho.lib.hellocharts.model.Axis) SimpleAxisValueFormatter(lecho.lib.hellocharts.formatter.SimpleAxisValueFormatter) AxisValueFormatter(lecho.lib.hellocharts.formatter.AxisValueFormatter) NonNull(android.support.annotation.NonNull)

Aggregations

NonNull (android.support.annotation.NonNull)2 ArrayList (java.util.ArrayList)2 AxisValueFormatter (lecho.lib.hellocharts.formatter.AxisValueFormatter)2 SimpleAxisValueFormatter (lecho.lib.hellocharts.formatter.SimpleAxisValueFormatter)2 Axis (lecho.lib.hellocharts.model.Axis)2 AxisValue (lecho.lib.hellocharts.model.AxisValue)2