Java Code Examples for lecho.lib.hellocharts.model.ColumnChartData#getColumns()

The following examples show how to use lecho.lib.hellocharts.model.ColumnChartData#getColumns() . 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: ColumnChartRenderer.java    From hellocharts-android with Apache License 2.0 6 votes vote down vote up
private void calculateMaxViewportForStacked(ColumnChartData data) {
    for (Column column : data.getColumns()) {
        float sumPositive = baseValue;
        float sumNegative = baseValue;
        for (SubcolumnValue columnValue : column.getValues()) {
            if (columnValue.getValue() >= baseValue) {
                sumPositive += columnValue.getValue();
            } else {
                sumNegative += columnValue.getValue();
            }
        }
        if (sumPositive > tempMaximumViewport.top) {
            tempMaximumViewport.top = sumPositive;
        }
        if (sumNegative < tempMaximumViewport.bottom) {
            tempMaximumViewport.bottom = sumNegative;
        }
    }
}
 
Example 2
Source File: BasalChart.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
public static float getTotalBasal(final ColumnChartData columnChartData) {
    float total = 0;
    for (final Column column : columnChartData.getColumns()) {
        total += column.getValues().get(0).getValue();
    }
    return total;
}
 
Example 3
Source File: BasalChart.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
public static float getTotalImmutableBasal(final ColumnChartData columnChartData) {
    float total = 0;
    for (final Column column : columnChartData.getColumns()) {
        total += column.getValues().get(0).getImmutableOriginValue();
    }
    return total;
}
 
Example 4
Source File: BasalChart.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
public static float getMaxYvalue(ColumnChartData lineData) {
    float max_height = 0.2f;
    for (Column col : lineData.getColumns()) {
        final SubcolumnValue sub = col.getValues().get(0);
        final float val = Math.max(sub.getValue(), sub.getImmutableOriginValue());
        if (val > max_height) {
            max_height = val;
        }
    }
    return max_height;
}
 
Example 5
Source File: BasalChart.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public static float getTotalBasal(final ColumnChartData columnChartData) {
    float total = 0;
    for (final Column column : columnChartData.getColumns()) {
        total += column.getValues().get(0).getValue();
    }
    return total;
}
 
Example 6
Source File: BasalChart.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public static float getTotalImmutableBasal(final ColumnChartData columnChartData) {
    float total = 0;
    for (final Column column : columnChartData.getColumns()) {
        total += column.getValues().get(0).getImmutableOriginValue();
    }
    return total;
}
 
Example 7
Source File: BasalChart.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public static float getMaxYvalue(ColumnChartData lineData) {
    float max_height = 0.2f;
    for (Column col : lineData.getColumns()) {
        final SubcolumnValue sub = col.getValues().get(0);
        final float val = Math.max(sub.getValue(), sub.getImmutableOriginValue());
        if (val > max_height) {
            max_height = val;
        }
    }
    return max_height;
}
 
Example 8
Source File: ColumnChartRenderer.java    From hellocharts-android with Apache License 2.0 5 votes vote down vote up
private void calculateMaxViewportForSubcolumns(ColumnChartData data) {
    for (Column column : data.getColumns()) {
        for (SubcolumnValue columnValue : column.getValues()) {
            if (columnValue.getValue() >= baseValue && columnValue.getValue() > tempMaximumViewport.top) {
                tempMaximumViewport.top = columnValue.getValue();
            }
            if (columnValue.getValue() < baseValue && columnValue.getValue() < tempMaximumViewport.bottom) {
                tempMaximumViewport.bottom = columnValue.getValue();
            }
        }
    }
}
 
Example 9
Source File: ColumnChartRenderer.java    From hellocharts-android with Apache License 2.0 5 votes vote down vote up
private void drawColumnsForSubcolumns(Canvas canvas) {
    final ColumnChartData data = dataProvider.getColumnChartData();
    final float columnWidth = calculateColumnWidth();
    int columnIndex = 0;
    for (Column column : data.getColumns()) {
        processColumnForSubcolumns(canvas, column, columnWidth, columnIndex, MODE_DRAW);
        ++columnIndex;
    }
}
 
Example 10
Source File: ColumnChartRenderer.java    From hellocharts-android with Apache License 2.0 5 votes vote down vote up
private void checkTouchForSubcolumns(float touchX, float touchY) {
    // Using member variable to hold touch point to avoid too much parameters in methods.
    touchedPoint.x = touchX;
    touchedPoint.y = touchY;
    final ColumnChartData data = dataProvider.getColumnChartData();
    final float columnWidth = calculateColumnWidth();
    int columnIndex = 0;
    for (Column column : data.getColumns()) {
        // canvas is not needed for checking touch
        processColumnForSubcolumns(null, column, columnWidth, columnIndex, MODE_CHECK_TOUCH);
        ++columnIndex;
    }
}
 
Example 11
Source File: ColumnChartRenderer.java    From hellocharts-android with Apache License 2.0 5 votes vote down vote up
private void drawColumnForStacked(Canvas canvas) {
    final ColumnChartData data = dataProvider.getColumnChartData();
    final float columnWidth = calculateColumnWidth();
    // Columns are indexes from 0 to n, column index is also column X value
    int columnIndex = 0;
    for (Column column : data.getColumns()) {
        processColumnForStacked(canvas, column, columnWidth, columnIndex, MODE_DRAW);
        ++columnIndex;
    }
}
 
Example 12
Source File: ColumnChartRenderer.java    From hellocharts-android with Apache License 2.0 5 votes vote down vote up
private void checkTouchForStacked(float touchX, float touchY) {
    touchedPoint.x = touchX;
    touchedPoint.y = touchY;
    final ColumnChartData data = dataProvider.getColumnChartData();
    final float columnWidth = calculateColumnWidth();
    int columnIndex = 0;
    for (Column column : data.getColumns()) {
        // canvas is not needed for checking touch
        processColumnForStacked(null, column, columnWidth, columnIndex, MODE_CHECK_TOUCH);
        ++columnIndex;
    }
}
 
Example 13
Source File: PreviewColumnChartActivity.java    From hellocharts-android with Apache License 2.0 5 votes vote down vote up
private void generateDefaultData() {
    int numSubcolumns = 1;
    int numColumns = 50;
    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));
    }

    data = new ColumnChartData(columns);
    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 ColumnChartData(data);
    for (Column column : previewData.getColumns()) {
        for (SubcolumnValue value : column.getValues()) {
            value.setColor(ChartUtils.DEFAULT_DARKEN_COLOR);
        }
    }

}