Search in sources :

Example 16 with AxisValue

use of lecho.lib.hellocharts.model.AxisValue 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)

Example 17 with AxisValue

use of lecho.lib.hellocharts.model.AxisValue in project xDrip by NightscoutFoundation.

the class BgGraphBuilder method yAxis.

// ///////AXIS RELATED//////////////
public Axis yAxis() {
    Axis yAxis = new Axis();
    yAxis.setAutoGenerated(false);
    List<AxisValue> axisValues = new ArrayList<AxisValue>();
    for (int j = 1; j <= 12; j += 1) {
        if (doMgdl) {
            axisValues.add(new AxisValue(j * 50));
        } else {
            axisValues.add(new AxisValue(j * 2));
        }
    }
    yAxis.setValues(axisValues);
    yAxis.setHasLines(true);
    yAxis.setMaxLabelChars(5);
    yAxis.setInside(true);
    yAxis.setTextSize(axisTextSize);
    return yAxis;
}
Also used : AxisValue(lecho.lib.hellocharts.model.AxisValue) ArrayList(java.util.ArrayList) Axis(lecho.lib.hellocharts.model.Axis)

Example 18 with AxisValue

use of lecho.lib.hellocharts.model.AxisValue in project xDrip by NightscoutFoundation.

the class BgGraphBuilder method yAxis.

// ///////AXIS RELATED//////////////
public Axis yAxis() {
    Axis yAxis = new Axis();
    yAxis.setAutoGenerated(true);
    List<AxisValue> axisValues = new ArrayList<AxisValue>();
    yAxis.setValues(axisValues);
    yAxis.setHasLines(false);
    return yAxis;
}
Also used : AxisValue(lecho.lib.hellocharts.model.AxisValue) ArrayList(java.util.ArrayList) Axis(lecho.lib.hellocharts.model.Axis)

Example 19 with AxisValue

use of lecho.lib.hellocharts.model.AxisValue in project xDrip-plus by jamorham.

the class BgGraphBuilder method yAxis.

// ///////AXIS RELATED//////////////
public Axis yAxis() {
    Axis yAxis = new Axis();
    yAxis.setAutoGenerated(false);
    List<AxisValue> axisValues = new ArrayList<AxisValue>();
    for (int j = 1; j <= 12; j += 1) {
        if (doMgdl) {
            axisValues.add(new AxisValue(j * 50));
        } else {
            axisValues.add(new AxisValue(j * 2));
        }
    }
    yAxis.setValues(axisValues);
    yAxis.setHasLines(true);
    yAxis.setMaxLabelChars(5);
    yAxis.setInside(true);
    yAxis.setTextSize(axisTextSize);
    return yAxis;
}
Also used : AxisValue(lecho.lib.hellocharts.model.AxisValue) ArrayList(java.util.ArrayList) Axis(lecho.lib.hellocharts.model.Axis)

Example 20 with AxisValue

use of lecho.lib.hellocharts.model.AxisValue in project xDrip-plus by jamorham.

the class BgGraphBuilder method xAxis.

@NonNull
private Axis xAxis() {
    List<AxisValue> axisValues = new ArrayList<AxisValue>();
    final java.text.DateFormat timeFormat = hourFormat();
    timeFormat.setTimeZone(TimeZone.getDefault());
    GregorianCalendar calendar = new GregorianCalendar();
    calendar.setTimeInMillis(start_time);
    calendar.set(Calendar.MINUTE, 0);
    calendar.set(Calendar.SECOND, 0);
    calendar.set(Calendar.MILLISECOND, 0);
    if (calendar.getTimeInMillis() < start_time) {
        calendar.add(Calendar.HOUR, 1);
    }
    while (calendar.getTimeInMillis() < end_time) {
        axisValues.add(new AxisValue((calendar.getTimeInMillis() / FUZZER), (timeFormat.format(calendar.getTimeInMillis())).toCharArray()));
        calendar.add(Calendar.HOUR, 1);
    }
    Axis axis = new Axis();
    axis.setValues(axisValues);
    axis.setHasLines(true);
    return axis;
}
Also used : AxisValue(lecho.lib.hellocharts.model.AxisValue) ArrayList(java.util.ArrayList) GregorianCalendar(java.util.GregorianCalendar) Context(android.content.Context) Axis(lecho.lib.hellocharts.model.Axis) NonNull(android.support.annotation.NonNull)

Aggregations

AxisValue (lecho.lib.hellocharts.model.AxisValue)20 ArrayList (java.util.ArrayList)18 Axis (lecho.lib.hellocharts.model.Axis)18 GregorianCalendar (java.util.GregorianCalendar)7 SimpleDateFormat (java.text.SimpleDateFormat)6 NonNull (android.support.annotation.NonNull)4 Calendar (java.util.Calendar)4 Column (lecho.lib.hellocharts.model.Column)3 ColumnChartData (lecho.lib.hellocharts.model.ColumnChartData)3 Line (lecho.lib.hellocharts.model.Line)3 LineChartData (lecho.lib.hellocharts.model.LineChartData)3 SelectedValue (lecho.lib.hellocharts.model.SelectedValue)3 SubcolumnValue (lecho.lib.hellocharts.model.SubcolumnValue)3 Context (android.content.Context)2 Paint (android.graphics.Paint)2 Rect (android.graphics.Rect)2 RecyclerView (android.support.v7.widget.RecyclerView)2 View (android.view.View)2 TextView (android.widget.TextView)2 InjectView (butterknife.InjectView)2