lecho.lib.hellocharts.util.ChartUtils Java Examples
The following examples show how to use
lecho.lib.hellocharts.util.ChartUtils.
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: IOBCOBLineGraph.java From HAPP with GNU General Public License v3.0 | 6 votes |
public Line iobFutureLine() { List<PointValue> listValues = new ArrayList<>(); for (int c = 0; c < iobFutureValues.length(); c++) { try { if (iobFutureValues.getJSONObject(c).getDouble("iob") > yIOBMax) { listValues.add(new PointValue((float) (iobFutureValues.getJSONObject(c).getDouble("as_of")), (float) fitIOB2COBRange(yIOBMax))); //Do not go above Max IOB } else if (iobFutureValues.getJSONObject(c).getDouble("iob") < yIOBMin) { listValues.add(new PointValue((float) (iobFutureValues.getJSONObject(c).getDouble("as_of")), (float) fitIOB2COBRange(yIOBMin))); //Do not go below Min IOB } else { listValues.add(new PointValue((float) (iobFutureValues.getJSONObject(c).getDouble("as_of")), (float) fitIOB2COBRange(iobFutureValues.getJSONObject(c).getDouble("iob")))); } } catch (JSONException e) { Crashlytics.logException(e); e.printStackTrace(); } } Line cobValuesLine = new Line(listValues); cobValuesLine.setColor(ChartUtils.COLOR_BLUE); cobValuesLine.setHasLines(false); cobValuesLine.setHasPoints(true); cobValuesLine.setFilled(false); cobValuesLine.setCubic(false); cobValuesLine.setPointRadius(2); return cobValuesLine; }
Example #2
Source File: ViewPagerChartsActivity.java From hellocharts-android with Apache License 2.0 | 6 votes |
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 #3
Source File: ViewPagerChartsActivity.java From hellocharts-android with Apache License 2.0 | 6 votes |
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 #4
Source File: ViewPagerChartsActivity.java From hellocharts-android with Apache License 2.0 | 6 votes |
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 #5
Source File: ComboLineColumnChartActivity.java From hellocharts-android with Apache License 2.0 | 6 votes |
private LineChartData generateLineData() { List<Line> lines = new ArrayList<Line>(); for (int i = 0; i < numberOfLines; ++i) { List<PointValue> values = new ArrayList<PointValue>(); for (int j = 0; j < numberOfPoints; ++j) { values.add(new PointValue(j, randomNumbersTab[i][j])); } Line line = new Line(values); line.setColor(ChartUtils.COLORS[i]); line.setCubic(isCubic); line.setHasLabels(hasLabels); line.setHasLines(hasLines); line.setHasPoints(hasPoints); lines.add(line); } LineChartData lineChartData = new LineChartData(lines); return lineChartData; }
Example #6
Source File: ViewPagerChartsActivity.java From hellocharts-android with Apache License 2.0 | 6 votes |
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 #7
Source File: ComboLineColumnChartActivity.java From hellocharts-android with Apache License 2.0 | 6 votes |
private ColumnChartData generateColumnData() { 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() * 50 + 5, ChartUtils.COLOR_GREEN)); } columns.add(new Column(values)); } ColumnChartData columnChartData = new ColumnChartData(columns); return columnChartData; }
Example #8
Source File: PreviewLineChartActivity.java From hellocharts-android with Apache License 2.0 | 6 votes |
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 #9
Source File: AxesRenderer.java From hellocharts-android with Apache License 2.0 | 6 votes |
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 #10
Source File: PieChartRenderer.java From hellocharts-android with Apache License 2.0 | 6 votes |
@Override public void onChartDataChanged() { super.onChartDataChanged(); final PieChartData data = dataProvider.getPieChartData(); hasLabelsOutside = data.hasLabelsOutside(); hasLabels = data.hasLabels(); hasLabelsOnlyForSelected = data.hasLabelsOnlyForSelected(); valueFormatter = data.getFormatter(); hasCenterCircle = data.hasCenterCircle(); centerCircleScale = data.getCenterCircleScale(); centerCirclePaint.setColor(data.getCenterCircleColor()); if (null != data.getCenterText1Typeface()) { centerCircleText1Paint.setTypeface(data.getCenterText1Typeface()); } centerCircleText1Paint.setTextSize(ChartUtils.sp2px(scaledDensity, data.getCenterText1FontSize())); centerCircleText1Paint.setColor(data.getCenterText1Color()); centerCircleText1Paint.getFontMetricsInt(centerCircleText1FontMetrics); if (null != data.getCenterText2Typeface()) { centerCircleText2Paint.setTypeface(data.getCenterText2Typeface()); } centerCircleText2Paint.setTextSize(ChartUtils.sp2px(scaledDensity, data.getCenterText2FontSize())); centerCircleText2Paint.setColor(data.getCenterText2Color()); centerCircleText2Paint.getFontMetricsInt(centerCircleText2FontMetrics); onChartViewportChanged(); }
Example #11
Source File: CommonChartSupport.java From HAPP with GNU General Public License v3.0 | 6 votes |
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 #12
Source File: CommonChartSupport.java From HAPP with GNU General Public License v3.0 | 6 votes |
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 #13
Source File: AbstractChartView.java From hellocharts-android with Apache License 2.0 | 6 votes |
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (isEnabled()) { axesRenderer.drawInBackground(canvas); int clipRestoreCount = canvas.save(); canvas.clipRect(chartComputator.getContentRectMinusAllMargins()); chartRenderer.draw(canvas); canvas.restoreToCount(clipRestoreCount); chartRenderer.drawUnclipped(canvas); axesRenderer.drawInForeground(canvas); } else { canvas.drawColor(ChartUtils.DEFAULT_COLOR); } }
Example #14
Source File: PieChartRenderer.java From hellocharts-android with Apache License 2.0 | 6 votes |
public PieChartRenderer(Context context, Chart chart, PieChartDataProvider dataProvider) { super(context, chart); this.dataProvider = dataProvider; touchAdditional = ChartUtils.dp2px(density, DEFAULT_TOUCH_ADDITIONAL_DP); slicePaint.setAntiAlias(true); slicePaint.setStyle(Paint.Style.FILL); centerCirclePaint.setAntiAlias(true); centerCirclePaint.setStyle(Paint.Style.FILL); centerCirclePaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC)); centerCircleText1Paint.setAntiAlias(true); centerCircleText1Paint.setTextAlign(Align.CENTER); centerCircleText2Paint.setAntiAlias(true); centerCircleText2Paint.setTextAlign(Align.CENTER); separationLinesPaint.setAntiAlias(true); separationLinesPaint.setStyle(Paint.Style.STROKE); separationLinesPaint.setStrokeCap(Paint.Cap.ROUND); separationLinesPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR)); separationLinesPaint.setColor(Color.TRANSPARENT); }
Example #15
Source File: LineChartRenderer.java From hellocharts-android with Apache License 2.0 | 6 votes |
private void drawPoints(Canvas canvas, Line line, int lineIndex, int mode) { pointPaint.setColor(line.getPointColor()); int valueIndex = 0; for (PointValue pointValue : line.getValues()) { int pointRadius = ChartUtils.dp2px(density, line.getPointRadius()); final float rawX = computator.computeRawX(pointValue.getX()); final float rawY = computator.computeRawY(pointValue.getY()); if (computator.isWithinContentRect(rawX, rawY, checkPrecision)) { // Draw points only if they are within contentRectMinusAllMargins, using contentRectMinusAllMargins // instead of viewport to avoid some // float rounding problems. if (MODE_DRAW == mode) { drawPoint(canvas, line, pointValue, rawX, rawY, pointRadius); if (line.hasLabels()) { drawLabel(canvas, line, pointValue, rawX, rawY, pointRadius + labelOffset); } } else if (MODE_HIGHLIGHT == mode) { highlightPoint(canvas, line, pointValue, rawX, rawY, lineIndex, valueIndex); } else { throw new IllegalStateException("Cannot process points in mode: " + mode); } } ++valueIndex; } }
Example #16
Source File: AbstractChartRenderer.java From hellocharts-android with Apache License 2.0 | 6 votes |
public AbstractChartRenderer(Context context, Chart chart) { this.density = context.getResources().getDisplayMetrics().density; this.scaledDensity = context.getResources().getDisplayMetrics().scaledDensity; this.chart = chart; this.computator = chart.getChartComputator(); labelMargin = ChartUtils.dp2px(density, DEFAULT_LABEL_MARGIN_DP); labelOffset = labelMargin; labelPaint.setAntiAlias(true); labelPaint.setStyle(Paint.Style.FILL); labelPaint.setTextAlign(Align.LEFT); labelPaint.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); labelPaint.setColor(Color.WHITE); labelBackgroundPaint.setAntiAlias(true); labelBackgroundPaint.setStyle(Paint.Style.FILL); }
Example #17
Source File: AbstractChartRenderer.java From hellocharts-android with Apache License 2.0 | 6 votes |
@Override public void onChartDataChanged() { final ChartData data = chart.getChartData(); Typeface typeface = chart.getChartData().getValueLabelTypeface(); if (null != typeface) { labelPaint.setTypeface(typeface); } labelPaint.setColor(data.getValueLabelTextColor()); labelPaint.setTextSize(ChartUtils.sp2px(scaledDensity, data.getValueLabelTextSize())); labelPaint.getFontMetricsInt(fontMetrics); this.isValueLabelBackgroundEnabled = data.isValueLabelBackgroundEnabled(); this.isValueLabelBackgroundAuto = data.isValueLabelBackgroundAuto(); this.labelBackgroundPaint.setColor(data.getValueLabelBackgroundColor()); // Important - clear selection when data changed. selectedValue.clear(); }
Example #18
Source File: LineChartRenderer.java From hellocharts-android with Apache License 2.0 | 6 votes |
public LineChartRenderer(Context context, Chart chart, LineChartDataProvider dataProvider) { super(context, chart); this.dataProvider = dataProvider; touchToleranceMargin = ChartUtils.dp2px(density, DEFAULT_TOUCH_TOLERANCE_MARGIN_DP); linePaint.setAntiAlias(true); linePaint.setStyle(Paint.Style.STROKE); linePaint.setStrokeCap(Cap.ROUND); linePaint.setStrokeWidth(ChartUtils.dp2px(density, DEFAULT_LINE_STROKE_WIDTH_DP)); pointPaint.setAntiAlias(true); pointPaint.setStyle(Paint.Style.FILL); checkPrecision = ChartUtils.dp2px(density, 2); }
Example #19
Source File: LineChartRenderer.java From hellocharts-android with Apache License 2.0 | 6 votes |
@Override public boolean checkTouch(float touchX, float touchY) { selectedValue.clear(); final LineChartData data = dataProvider.getLineChartData(); int lineIndex = 0; for (Line line : data.getLines()) { if (checkIfShouldDrawPoints(line)) { int pointRadius = ChartUtils.dp2px(density, line.getPointRadius()); int valueIndex = 0; for (PointValue pointValue : line.getValues()) { final float rawValueX = computator.computeRawX(pointValue.getX()); final float rawValueY = computator.computeRawY(pointValue.getY()); if (isInArea(rawValueX, rawValueY, touchX, touchY, pointRadius + touchToleranceMargin)) { selectedValue.set(lineIndex, valueIndex, SelectedValueType.LINE); } ++valueIndex; } } ++lineIndex; } return isTouched(); }
Example #20
Source File: Line.java From hellocharts-android with Apache License 2.0 | 5 votes |
public Line setColor(int color) { this.color = color; if (pointColor == UNINITIALIZED) { this.darkenColor = ChartUtils.darkenColor(color); } return this; }
Example #21
Source File: PreviewColumnChartActivity.java From hellocharts-android with Apache License 2.0 | 5 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if (id == R.id.action_reset) { generateDefaultData(); chart.setColumnChartData(data); previewChart.setColumnChartData(previewData); previewX(true); return true; } if (id == R.id.action_preview_both) { previewXY(); previewChart.setZoomType(ZoomType.HORIZONTAL_AND_VERTICAL); return true; } if (id == R.id.action_preview_horizontal) { previewX(true); return true; } if (id == R.id.action_preview_vertical) { previewY(); return true; } if (id == R.id.action_change_color) { int color = ChartUtils.pickColor(); while (color == previewChart.getPreviewColor()) { color = ChartUtils.pickColor(); } previewChart.setPreviewColor(color); return true; } return super.onOptionsItemSelected(item); }
Example #22
Source File: Line.java From hellocharts-android with Apache License 2.0 | 5 votes |
public Line setPointColor(int pointColor) { this.pointColor = pointColor; if (pointColor == UNINITIALIZED) { this.darkenColor = ChartUtils.darkenColor(color); } else { this.darkenColor = ChartUtils.darkenColor(pointColor); } return this; }
Example #23
Source File: PreviewColumnChartActivity.java From hellocharts-android with Apache License 2.0 | 5 votes |
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); } } }
Example #24
Source File: ViewPagerChartsActivity.java From hellocharts-android with Apache License 2.0 | 5 votes |
private PieChartData generatePieChartData() { int numValues = 6; List<SliceValue> values = new ArrayList<SliceValue>(); for (int i = 0; i < numValues; ++i) { values.add(new SliceValue((float) Math.random() * 30 + 15, ChartUtils.pickColor())); } PieChartData data = new PieChartData(values); return data; }
Example #25
Source File: LineChartRenderer.java From hellocharts-android with Apache License 2.0 | 5 votes |
private void highlightPoint(Canvas canvas, Line line, PointValue pointValue, float rawX, float rawY, int lineIndex, int valueIndex) { if (selectedValue.getFirstIndex() == lineIndex && selectedValue.getSecondIndex() == valueIndex) { int pointRadius = ChartUtils.dp2px(density, line.getPointRadius()); pointPaint.setColor(line.getDarkenColor()); drawPoint(canvas, line, pointValue, rawX, rawY, pointRadius + touchToleranceMargin); if (line.hasLabels() || line.hasLabelsOnlyForSelected()) { drawLabel(canvas, line, pointValue, rawX, rawY, pointRadius + labelOffset); } } }
Example #26
Source File: CheckableLineChartRenderer.java From SoloPi with Apache License 2.0 | 5 votes |
private void drawChecked(Canvas canvas) { if (checkedValue == null){ return; } int lineIndex = checkedValue.getFirstIndex(); Line line = dataProvider.getLineChartData().getLines().get(lineIndex); PointValue pointValue = line.getValues().get(checkedValue.getSecondIndex()); int pointRadius = ChartUtils.dp2px(density, line.getPointRadius()); float rawX = computator.computeRawX(pointValue.getX()); float rawY = computator.computeRawY(pointValue.getY()); canvas.drawCircle(rawX, rawY, pointRadius, checkedPaint); }
Example #27
Source File: LineColumnDependencyActivity.java From hellocharts-android with Apache License 2.0 | 5 votes |
/** * Generates initial data for line chart. At the begining all Y values are equals 0. That will change when user * will select value on column chart. */ private void generateInitialLineData() { int numValues = 7; List<AxisValue> axisValues = new ArrayList<AxisValue>(); List<PointValue> values = new ArrayList<PointValue>(); for (int i = 0; i < numValues; ++i) { values.add(new PointValue(i, 0)); axisValues.add(new AxisValue(i).setLabel(days[i])); } Line line = new Line(values); line.setColor(ChartUtils.COLOR_GREEN).setCubic(true); List<Line> lines = new ArrayList<Line>(); lines.add(line); lineData = new LineChartData(lines); lineData.setAxisXBottom(new Axis(axisValues).setHasLines(true)); lineData.setAxisYLeft(new Axis().setHasLines(true).setMaxLabelChars(3)); chartTop.setLineChartData(lineData); // For build-up animation you have to disable viewport recalculation. chartTop.setViewportCalculationEnabled(false); // And set initial max viewport and current viewport- remember to set viewports after data. Viewport v = new Viewport(0, 110, 6, 0); chartTop.setMaximumViewport(v); chartTop.setCurrentViewport(v); chartTop.setZoomType(ZoomType.HORIZONTAL); }
Example #28
Source File: PreviewLineChartActivity.java From hellocharts-android with Apache License 2.0 | 5 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if (id == R.id.action_reset) { generateDefaultData(); chart.setLineChartData(data); previewChart.setLineChartData(previewData); previewX(true); return true; } if (id == R.id.action_preview_both) { previewXY(); previewChart.setZoomType(ZoomType.HORIZONTAL_AND_VERTICAL); return true; } if (id == R.id.action_preview_horizontal) { previewX(true); return true; } if (id == R.id.action_preview_vertical) { previewY(); return true; } if (id == R.id.action_change_color) { int color = ChartUtils.pickColor(); while (color == previewChart.getPreviewColor()) { color = ChartUtils.pickColor(); } previewChart.setPreviewColor(color); return true; } return super.onOptionsItemSelected(item); }
Example #29
Source File: ColumnChartActivity.java From hellocharts-android with Apache License 2.0 | 5 votes |
/** * Generates columns with subcolumns, columns have larger separation than subcolumns. */ private void generateSubcolumnsData() { int numSubcolumns = 4; int numColumns = 4; // Column can have many subcolumns, here I use 4 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())); } Column column = new Column(values); column.setHasLabels(hasLabels); column.setHasLabelsOnlyForSelected(hasLabelForSelected); columns.add(column); } data = new ColumnChartData(columns); 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.setColumnChartData(data); }
Example #30
Source File: LineChartRenderer.java From hellocharts-android with Apache License 2.0 | 5 votes |
private int calculateContentRectInternalMargin() { int contentAreaMargin = 0; final LineChartData data = dataProvider.getLineChartData(); for (Line line : data.getLines()) { if (checkIfShouldDrawPoints(line)) { int margin = line.getPointRadius() + DEFAULT_TOUCH_TOLERANCE_MARGIN_DP; if (margin > contentAreaMargin) { contentAreaMargin = margin; } } } return ChartUtils.dp2px(density, contentAreaMargin); }