lecho.lib.hellocharts.model.Axis Java Examples

The following examples show how to use lecho.lib.hellocharts.model.Axis. 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: BasalVSTempBasalGraph.java    From HAPP with GNU General Public License v3.0 6 votes vote down vote up
public Axis basalVsTempBasalyAxis() {
    Axis yAxis = new Axis();
    yAxis.setAutoGenerated(false);
    List<AxisValue> axisValues = new ArrayList<>();

    for(double j = -maxBasal.intValue(); j <= maxBasal.intValue(); j += 1) {
        //axisValues.add(new AxisValue((float)fitIOB2COBRange(j)));
        AxisValue value = new AxisValue((float)j);
        if (j==0){
            value.setLabel("Basal");
        } else if (j>0){
            value.setLabel("+" + String.valueOf(j) + "u");
        } else {
            value.setLabel(String.valueOf(j) + "u");
        }
        axisValues.add(value);
    }
    yAxis.setValues(axisValues);
    yAxis.setHasLines(true);
    yAxis.setMaxLabelChars(5);
    yAxis.setInside(true);
    return yAxis;
}
 
Example #2
Source File: StatisticViewModel.java    From OmniList with GNU Affero General Public License v3.0 6 votes vote down vote up
public ColumnChartData getDefaultAttachmentData() {
    ColumnChartData data = new ColumnChartData(Arrays.asList(
            getColumn(DEFAULT_TOTAL_VALUE, PalmApp.getColorCompact(R.color.md_lime_600)),
            getColumn(DEFAULT_TOTAL_VALUE, PalmApp.getColorCompact(R.color.md_light_blue_500)),
            getColumn(DEFAULT_TOTAL_VALUE, PalmApp.getColorCompact(R.color.md_pink_500)),
            getColumn(DEFAULT_TOTAL_VALUE, PalmApp.getColorCompact(R.color.md_green_600)),
            getColumn(DEFAULT_TOTAL_VALUE, PalmApp.getColorCompact(R.color.md_red_500))));

    Axis axisX = Axis.generateAxisFromCollection(Arrays.asList(0.0f, 1.0f, 2.0f, 3.0f, 4.0f),
            Arrays.asList(PalmApp.getStringCompact(R.string.attachment_type_files),
                    PalmApp.getStringCompact(R.string.attachment_type_images),
                    PalmApp.getStringCompact(R.string.attachment_type_sketches),
                    PalmApp.getStringCompact(R.string.attachment_type_videos),
                    PalmApp.getStringCompact(R.string.attachment_type_recordings)));

    data.setAxisXBottom(axisX);
    data.setAxisYLeft(null);

    return data;
}
 
Example #3
Source File: StatisticViewModel.java    From OmniList with GNU Affero General Public License v3.0 6 votes vote down vote up
private LineChartData getLineChartData(List<Line> lines) {
    DateTime daysAgo = new DateTime().withTimeAtStartOfDay().minusDays(StatisticViewModel.DAYS_OF_ADDED_MODEL - 1);
    List<String> days = new ArrayList<>();
    SimpleDateFormat sdf = new SimpleDateFormat("dd", Locale.getDefault());
    for (int i=0; i<StatisticViewModel.DAYS_OF_ADDED_MODEL; i++){
        days.add(sdf.format(daysAgo.toDate()));
        daysAgo = daysAgo.plusDays(1);
    }

    LineChartData data = new LineChartData();
    data.setLines(lines);
    data.setAxisXBottom(null);
    data.setAxisYLeft(null);
    data.setBaseValue(-0.1f);
    data.setValueLabelBackgroundColor(Color.TRANSPARENT);
    Axis axis = Axis.generateAxisFromCollection(Arrays.asList(0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f), days);
    data.setAxisXBottom(axis);
    return data;
}
 
Example #4
Source File: BgGraphBuilder.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
@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;
}
 
Example #5
Source File: StatisticViewModel.java    From OmniList with GNU Affero General Public License v3.0 6 votes vote down vote up
public ColumnChartData getDefaultModelsData() {
    ColumnChartData data = new ColumnChartData(Arrays.asList(
            getColumn(DEFAULT_TOTAL_VALUE, PalmApp.getColorCompact(R.color.md_lime_600)),
            getColumn(DEFAULT_TOTAL_VALUE, PalmApp.getColorCompact(R.color.md_light_blue_500)),
            getColumn(DEFAULT_TOTAL_VALUE, PalmApp.getColorCompact(R.color.md_green_600)),
            getColumn(DEFAULT_TOTAL_VALUE, PalmApp.getColorCompact(R.color.md_pink_500)),
            getColumn(DEFAULT_TOTAL_VALUE, PalmApp.getColorCompact(R.color.md_red_500))));

    Axis axisX = Axis.generateAxisFromCollection(Arrays.asList(0.0f, 1.0f, 2.0f, 3.0f, 4.0f),
            Arrays.asList(PalmApp.getStringCompact(R.string.model_name_category),
                    PalmApp.getStringCompact(R.string.model_name_assignment),
                    PalmApp.getStringCompact(R.string.model_name_sub_assignment),
                    PalmApp.getStringCompact(R.string.model_name_attachment),
                    PalmApp.getStringCompact(R.string.model_name_location)));

    data.setAxisXBottom(axisX);
    data.setAxisYLeft(null);

    return data;
}
 
Example #6
Source File: ComboLineColumnChartActivity.java    From hellocharts-android with Apache License 2.0 6 votes vote down vote up
private void generateData() {
    // Chart looks the best when line data and column data have similar maximum viewports.
    data = new ComboLineColumnChartData(generateColumnData(), generateLineData());

    if (hasAxes) {
        Axis axisX = new Axis();
        Axis axisY = new Axis().setHasLines(true);
        if (hasAxesNames) {
            axisX.setName("Axis X");
            axisY.setName("Axis Y");
        }
        data.setAxisXBottom(axisX);
        data.setAxisYLeft(axisY);
    } else {
        data.setAxisXBottom(null);
        data.setAxisYLeft(null);
    }

    chart.setComboLineColumnChartData(data);
}
 
Example #7
Source File: ViewPagerChartsActivity.java    From hellocharts-android with Apache License 2.0 6 votes vote down vote up
private LineChartData generatePreviewLineChartData() {
    int numValues = 50;

    List<PointValue> values = new ArrayList<PointValue>();
    for (int i = 0; i < numValues; ++i) {
        values.add(new PointValue(i, (float) Math.random() * 100f));
    }

    Line line = new Line(values);
    line.setColor(ChartUtils.DEFAULT_DARKEN_COLOR);
    line.setHasPoints(false);// too many values so don't draw points.

    List<Line> lines = new ArrayList<Line>();
    lines.add(line);

    LineChartData data = new LineChartData(lines);
    data.setAxisXBottom(new Axis());
    data.setAxisYLeft(new Axis().setHasLines(true));

    return data;

}
 
Example #8
Source File: ViewPagerChartsActivity.java    From hellocharts-android with Apache License 2.0 6 votes vote down vote up
private LineChartData generateLineChartData() {
    int numValues = 20;

    List<PointValue> values = new ArrayList<PointValue>();
    for (int i = 0; i < numValues; ++i) {
        values.add(new PointValue(i, (float) Math.random() * 100f));
    }

    Line line = new Line(values);
    line.setColor(ChartUtils.COLOR_GREEN);

    List<Line> lines = new ArrayList<Line>();
    lines.add(line);

    LineChartData data = new LineChartData(lines);
    data.setAxisXBottom(new Axis().setName("Axis X"));
    data.setAxisYLeft(new Axis().setName("Axis Y").setHasLines(true));
    return data;

}
 
Example #9
Source File: BgGraphBuilder.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
public BgGraphBuilder(Context context, long start, long end, int numValues){
    end_time = end;
    start_time = start;
    bgReadings = BgReading.latestForGraph( numValues, start, end);
    calibrations = Calibration.latestForGraph( numValues, start, end);
    this.context = context;
    this.prefs = PreferenceManager.getDefaultSharedPreferences(context);
    this.highMark = Double.parseDouble(prefs.getString("highValue", "170"));
    this.lowMark = Double.parseDouble(prefs.getString("lowValue", "70"));
    this.doMgdl = (prefs.getString("units", "mgdl").equals("mgdl"));
    defaultMinY = unitized(40);
    defaultMaxY = unitized(250);
    pointSize = isXLargeTablet(context) ? 5 : 3;
    axisTextSize = isXLargeTablet(context) ? 20 : Axis.DEFAULT_TEXT_SIZE_SP;
    previewAxisTextSize = isXLargeTablet(context) ? 12 : 5;
    hoursPreviewStep = isXLargeTablet(context) ? 2 : 1;
}
 
Example #10
Source File: ViewPagerChartsActivity.java    From hellocharts-android with Apache License 2.0 6 votes vote down vote up
private ColumnChartData generateColumnChartData() {
    int numSubcolumns = 1;
    int numColumns = 12;
    // Column can have many subcolumns, here by default I use 1 subcolumn in each of 8 columns.
    List<Column> columns = new ArrayList<Column>();
    List<SubcolumnValue> values;
    for (int i = 0; i < numColumns; ++i) {

        values = new ArrayList<SubcolumnValue>();
        for (int j = 0; j < numSubcolumns; ++j) {
            values.add(new SubcolumnValue((float) Math.random() * 50f + 5, ChartUtils.pickColor()));
        }

        columns.add(new Column(values));
    }

    ColumnChartData data = new ColumnChartData(columns);

    data.setAxisXBottom(new Axis().setName("Axis X"));
    data.setAxisYLeft(new Axis().setName("Axis Y").setHasLines(true));
    return data;

}
 
Example #11
Source File: ViewPagerChartsActivity.java    From hellocharts-android with Apache License 2.0 6 votes vote down vote up
private BubbleChartData generateBubbleChartData() {
    int numBubbles = 10;

    List<BubbleValue> values = new ArrayList<BubbleValue>();
    for (int i = 0; i < numBubbles; ++i) {
        BubbleValue value = new BubbleValue(i, (float) Math.random() * 100, (float) Math.random() * 1000);
        value.setColor(ChartUtils.pickColor());
        values.add(value);
    }

    BubbleChartData data = new BubbleChartData(values);

    data.setAxisXBottom(new Axis().setName("Axis X"));
    data.setAxisYLeft(new Axis().setName("Axis Y").setHasLines(true));
    return data;
}
 
Example #12
Source File: LineCharts.java    From MetalDetector with GNU General Public License v3.0 6 votes vote down vote up
/**
* 初始化视图
* */
protected void initView(LineChartView lineChartView) {
    pointValueList = new ArrayList<>();
    linesList = new ArrayList<>();
    //初始化坐标轴
    axisY = new Axis();
    axisX = new Axis();
    lineChartData = initData(null);
    lineChartView.setLineChartData(lineChartData);
    Viewport port = initViewPort(0, 50,150);
    lineChartView.setCurrentViewportWithAnimation(port);
    lineChartView.setInteractive(false);
    lineChartView.setScrollEnabled(true);
    lineChartView.setValueTouchEnabled(true);
    lineChartView.setFocusableInTouchMode(true);
    lineChartView.setViewportCalculationEnabled(false);
    lineChartView.setContainerScrollEnabled(true, ContainerScrollType.HORIZONTAL);
    lineChartView.startDataAnimation();
    points = new ArrayList<>();
}
 
Example #13
Source File: AxesRenderer.java    From hellocharts-android with Apache License 2.0 6 votes vote down vote up
/**
 * Draw axes labels and names in the foreground.
 *
 * @param canvas
 */
public void drawInForeground(Canvas canvas) {
    Axis axis = chart.getChartData().getAxisYLeft();
    if (null != axis) {
        drawAxisLabelsAndName(canvas, axis, LEFT);
    }

    axis = chart.getChartData().getAxisYRight();
    if (null != axis) {
        drawAxisLabelsAndName(canvas, axis, RIGHT);
    }

    axis = chart.getChartData().getAxisXBottom();
    if (null != axis) {
        drawAxisLabelsAndName(canvas, axis, BOTTOM);
    }

    axis = chart.getChartData().getAxisXTop();
    if (null != axis) {
        drawAxisLabelsAndName(canvas, axis, TOP);
    }
}
 
Example #14
Source File: BgGraphBuilder.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
public BgGraphBuilder(Context context, long start, long end, int numValues){
    end_time = end;
    start_time = start;
    bgReadings = BgReading.latestForGraph( numValues, start, end);
    calibrations = Calibration.latestForGraph( numValues, start, end);
    this.context = context;
    this.prefs = PreferenceManager.getDefaultSharedPreferences(context);
    this.highMark = Double.parseDouble(prefs.getString("highValue", "170"));
    this.lowMark = Double.parseDouble(prefs.getString("lowValue", "70"));
    this.doMgdl = (prefs.getString("units", "mgdl").equals("mgdl"));
    defaultMinY = unitized(40);
    defaultMaxY = unitized(250);
    pointSize = isXLargeTablet(context) ? 5 : 3;
    axisTextSize = isXLargeTablet(context) ? 20 : Axis.DEFAULT_TEXT_SIZE_SP;
    previewAxisTextSize = isXLargeTablet(context) ? 12 : 5;
    hoursPreviewStep = isXLargeTablet(context) ? 2 : 1;
}
 
Example #15
Source File: BgGraphBuilder.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
@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;
}
 
Example #16
Source File: AxesRenderer.java    From hellocharts-android with Apache License 2.0 6 votes vote down vote up
private void initAxisTextAlignment(Axis axis, int position) {
    namePaintTab[position].setTextAlign(Align.CENTER);
    if (TOP == position || BOTTOM == position) {
        labelPaintTab[position].setTextAlign(Align.CENTER);
    } else if (LEFT == position) {
        if (axis.isInside()) {
            labelPaintTab[position].setTextAlign(Align.LEFT);
        } else {
            labelPaintTab[position].setTextAlign(Align.RIGHT);
        }
    } else if (RIGHT == position) {
        if (axis.isInside()) {
            labelPaintTab[position].setTextAlign(Align.RIGHT);
        } else {
            labelPaintTab[position].setTextAlign(Align.LEFT);
        }
    }
}
 
Example #17
Source File: AxesRenderer.java    From hellocharts-android with Apache License 2.0 6 votes vote down vote up
private void initAxisPaints(Axis axis, int position) {
    Typeface typeface = axis.getTypeface();
    if (null != typeface) {
        labelPaintTab[position].setTypeface(typeface);
        namePaintTab[position].setTypeface(typeface);
    }
    labelPaintTab[position].setColor(axis.getTextColor());
    labelPaintTab[position].setTextSize(ChartUtils.sp2px(scaledDensity, axis.getTextSize()));
    labelPaintTab[position].getFontMetricsInt(fontMetricsTab[position]);
    namePaintTab[position].setColor(axis.getTextColor());
    namePaintTab[position].setTextSize(ChartUtils.sp2px(scaledDensity, axis.getTextSize()));
    linePaintTab[position].setColor(axis.getLineColor());

    labelTextAscentTab[position] = Math.abs(fontMetricsTab[position].ascent);
    labelTextDescentTab[position] = Math.abs(fontMetricsTab[position].descent);
    labelWidthTab[position] = (int) labelPaintTab[position].measureText(labelWidthChars, 0,
            axis.getMaxLabelChars());
}
 
Example #18
Source File: BasalChart.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
@NonNull
static public 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;
}
 
Example #19
Source File: BgGraphBuilder.java    From xDrip-Experimental with GNU General Public License v3.0 6 votes vote down vote up
public BgGraphBuilder(Context context, long start, long end, int numValues){
    end_time = end;
    start_time = start;
    bgReadings = BgReading.latestForGraph( numValues, start, end);
    calibrations = Calibration.latestForGraph( numValues, start, end);
    this.context = context;
    this.prefs = PreferenceManager.getDefaultSharedPreferences(context);
    this.highMark = Double.parseDouble(prefs.getString("highValue", "170"));
    this.lowMark = Double.parseDouble(prefs.getString("lowValue", "70"));
    this.doMgdl = (prefs.getString("units", "mgdl").equals("mgdl"));
    defaultMinY = unitized(40);
    defaultMaxY = unitized(250);
    pointSize = isXLargeTablet(context) ? 5 : 3;
    axisTextSize = isXLargeTablet(context) ? 20 : Axis.DEFAULT_TEXT_SIZE_SP;
    previewAxisTextSize = isXLargeTablet(context) ? 12 : 5;
    hoursPreviewStep = isXLargeTablet(context) ? 2 : 1;
}
 
Example #20
Source File: BgGraphBuilder.java    From xDrip-Experimental with GNU General Public License v3.0 6 votes vote down vote up
@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;
}
 
Example #21
Source File: BasalChart.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
@NonNull
static public 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;
}
 
Example #22
Source File: CommonChartSupport.java    From HAPP with GNU General Public License v3.0 6 votes vote down vote up
public Axis cobPastyAxis() {
    Axis yAxis = new Axis();
    yAxis.setAutoGenerated(false);
    List<AxisValue> axisValues = new ArrayList<AxisValue>();

    for(int j = 1; j <= 8; j += 1) {
        AxisValue value = new AxisValue(j*10);
        value.setLabel(String.valueOf(j*10) + "g");
        axisValues.add(value);
    }
    yAxis.setTextColor(ChartUtils.COLOR_ORANGE);
    yAxis.setValues(axisValues);
    yAxis.setHasLines(true);
    yAxis.setMaxLabelChars(5);
    yAxis.setInside(true);
    return yAxis;
}
 
Example #23
Source File: MetricCounterFragment.java    From hawkular-android-client with Apache License 2.0 6 votes vote down vote up
private void setUpChartLine() {
    List<PointValue> chartPoints = getChartPoints();
    List<AxisValue> chartAxisPoints = getChartAxisPoints();

    Line chartLine = new Line(chartPoints)
            .setColor(getResources().getColor(R.color.background_primary_dark))
            .setCubic(true)
            .setHasPoints(false);

    LineChartData chartData = new LineChartData()
            .setLines(Collections.singletonList(chartLine));
    chartData.setAxisXBottom(new Axis()
            .setValues(chartAxisPoints));
    chartData.setAxisYLeft(new Axis()
            .setHasLines(true));

    chart.setLineChartData(chartData);
}
 
Example #24
Source File: CommonChartSupport.java    From HAPP with GNU General Public License v3.0 6 votes vote down vote up
public Axis iobPastyAxis() {
    Axis yAxis = new Axis();
    yAxis.setAutoGenerated(false);
    List<AxisValue> axisValues = new ArrayList<AxisValue>();

    for(int j = 1; j <= 8; j += 1) {
        //axisValues.add(new AxisValue((float)fitIOB2COBRange(j)));
        AxisValue value = new AxisValue(j*10);
        value.setLabel(String.valueOf(j*2) + "u");
        axisValues.add(value);
    }
    yAxis.setTextColor(ChartUtils.COLOR_BLUE);
    yAxis.setValues(axisValues);
    yAxis.setHasLines(true);
    yAxis.setMaxLabelChars(5);
    yAxis.setInside(true);
    return yAxis;
}
 
Example #25
Source File: MetricGaugeFragment.java    From hawkular-android-client with Apache License 2.0 6 votes vote down vote up
private void setUpChartLine() {
    List<PointValue> chartPoints = getChartPoints();
    List<AxisValue> chartAxisPoints = getChartAxisPoints();

    Line chartLine = new Line(chartPoints)
        .setColor(getResources().getColor(R.color.background_primary_dark))
        .setCubic(true)
        .setHasPoints(false);

    LineChartData chartData = new LineChartData()
        .setLines(Collections.singletonList(chartLine));
    chartData.setAxisXBottom(new Axis()
        .setValues(chartAxisPoints));
    chartData.setAxisYLeft(new Axis()
        .setHasLines(true));

    chart.setLineChartData(chartData);
}
 
Example #26
Source File: PreviewLineChartActivity.java    From hellocharts-android with Apache License 2.0 6 votes vote down vote up
private void generateDefaultData() {
    int numValues = 50;

    List<PointValue> values = new ArrayList<PointValue>();
    for (int i = 0; i < numValues; ++i) {
        values.add(new PointValue(i, (float) Math.random() * 100f));
    }

    Line line = new Line(values);
    line.setColor(ChartUtils.COLOR_GREEN);
    line.setHasPoints(false);// too many values so don't draw points.

    List<Line> lines = new ArrayList<Line>();
    lines.add(line);

    data = new LineChartData(lines);
    data.setAxisXBottom(new Axis());
    data.setAxisYLeft(new Axis().setHasLines(true));

    // prepare preview data, is better to use separate deep copy for preview chart.
    // Set color to grey to make preview area more visible.
    previewData = new LineChartData(data);
    previewData.getLines().get(0).setColor(ChartUtils.DEFAULT_DARKEN_COLOR);

}
 
Example #27
Source File: BgGraphBuilder.java    From NightWatch with GNU General Public License v3.0 5 votes vote down vote up
public Axis previewXAxis(){
    List<AxisValue> previewXaxisValues = new ArrayList<AxisValue>();
    final java.text.DateFormat timeFormat = hourFormat();
    timeFormat.setTimeZone(TimeZone.getDefault());
    for(int l=0; l<=24; l+=hoursPreviewStep) {
        double timestamp = (endHour - (60000 * 60 * l));
        previewXaxisValues.add(new AxisValue((long)(timestamp/fuzz), (timeFormat.format(timestamp)).toCharArray()));
    }
    Axis previewXaxis = new Axis();
    previewXaxis.setValues(previewXaxisValues);
    previewXaxis.setHasLines(true);
    previewXaxis.setTextSize(previewAxisTextSize);
    return previewXaxis;
}
 
Example #28
Source File: BgGraphBuilder.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
public BgGraphBuilder(Context context){
    this.context = context;
    this.prefs = PreferenceManager.getDefaultSharedPreferences(context);
    this.highMark = Double.parseDouble(prefs.getString("highValue", "170"));
    this.lowMark = Double.parseDouble(prefs.getString("lowValue", "70"));
    this.doMgdl = (prefs.getString("units", "mgdl").compareTo("mgdl") == 0);
    defaultMinY = unitized(40);
    defaultMaxY = unitized(250);
    pointSize = isXLargeTablet() ? 5 : 3;
    axisTextSize = isXLargeTablet() ? 20 : Axis.DEFAULT_TEXT_SIZE_SP;
    previewAxisTextSize = isXLargeTablet() ? 12 : 5;
    hoursPreviewStep = isXLargeTablet() ? 2 : 1;
}
 
Example #29
Source File: BgGraphBuilder.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
public Axis previewXAxis(){
    List<AxisValue> previewXaxisValues = new ArrayList<AxisValue>();
    final java.text.DateFormat timeFormat = hourFormat();
    timeFormat.setTimeZone(TimeZone.getDefault());
    for(int l=0; l<=24; l+=hoursPreviewStep) {
        double timestamp = (endHour - (60000 * 60 * l));
        previewXaxisValues.add(new AxisValue((long)(timestamp/fuzzer), (timeFormat.format(timestamp)).toCharArray()));
    }
    Axis previewXaxis = new Axis();
    previewXaxis.setValues(previewXaxisValues);
    previewXaxis.setHasLines(true);
    previewXaxis.setTextSize(previewAxisTextSize);
    return previewXaxis;
}
 
Example #30
Source File: AxesRenderer.java    From hellocharts-android with Apache License 2.0 5 votes vote down vote up
private void initAxisAttributes(Axis axis, int position) {
    initAxisPaints(axis, position);
    initAxisTextAlignment(axis, position);
    if (axis.hasTiltedLabels()) {
        initAxisDimensionForTiltedLabels(position);
        intiTiltedLabelsTranslation(axis, position);
    } else {
        initAxisDimension(position);
    }
}