lecho.lib.hellocharts.model.LineChartData Java Examples
The following examples show how to use
lecho.lib.hellocharts.model.LineChartData.
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: 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 #2
Source File: MainActivity.java From HAPP with GNU General Public License v3.0 | 6 votes |
@Override protected void onPostExecute(ArrayList<LineChartData> result) { //Write some code you want to execute on UI after doInBackground() completes bgChartLoading.setVisibility(View.GONE); //bgChart.setVisibility(View.VISIBLE); bgChart.setLineChartData(result.get(0)); bgPreviewChart.setLineChartData(result.get(1)); updateStuff = true; //refreshes data and sets viewpoint bgChart.setZoomType(ZoomType.HORIZONTAL); bgPreviewChart.setZoomType(ZoomType.HORIZONTAL); bgPreviewChart.setViewportCalculationEnabled(true); bgChart.setViewportCalculationEnabled(true); bgPreviewChart.setViewportChangeListener(new ViewportListener()); bgChart.setViewportChangeListener(new ChartViewPortListener()); setViewport(); Log.d(TAG, "bgGraph Updated"); }
Example #3
Source File: MainActivity.java From HAPP with GNU General Public License v3.0 | 6 votes |
@Override protected void onPostExecute(LineChartData result) { //Write some code you want to execute on UI after doInBackground() completes iobcobPastLoading.setVisibility(View.GONE); iobcobPastChart.setVisibility(View.VISIBLE); //refreshes data and sets viewpoint iobcobPastChart.setLineChartData(result); iobv = new Viewport(iobcobPastChart.getMaximumViewport()); //Sets the min and max for Top and Bottom of the viewpoint iobv.top = Float.parseFloat(iobcobLineGraph.yCOBMax.toString()); iobv.bottom = Float.parseFloat(iobcobLineGraph.yCOBMin.toString()); iobv.left = previewChart.getCurrentViewport().left; iobv.right = previewChart.getCurrentViewport().right; iobcobPastChart.setMaximumViewport(iobv); iobcobPastChart.setCurrentViewport(iobv); return ; }
Example #4
Source File: MetricGaugeFragment.java From hawkular-android-client with Apache License 2.0 | 6 votes |
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 #5
Source File: MetricCounterFragment.java From hawkular-android-client with Apache License 2.0 | 6 votes |
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 #6
Source File: MainActivity.java From HAPP with GNU General Public License v3.0 | 6 votes |
@Override protected void onPostExecute(LineChartData result) { //Write some code you want to execute on UI after doInBackground() completes basalvsTempBasalLoading.setVisibility(View.GONE); basalvsTempBasalChart.setVisibility(View.VISIBLE); basalvsTempBasalChart.setLineChartData(result); //Sets the min and max for Top and Bottom of the viewpoint iobv = new Viewport(basalvsTempBasalChart.getMaximumViewport()); iobv.top = basalVSTempBasalGraph.maxBasal.floatValue(); iobv.bottom = -(basalVSTempBasalGraph.maxBasal.floatValue() - 1); iobv.left = previewChart.getCurrentViewport().left; iobv.right = previewChart.getCurrentViewport().right; basalvsTempBasalChart.setMaximumViewport(iobv); basalvsTempBasalChart.setCurrentViewport(iobv); return ; }
Example #7
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 #8
Source File: LineChartRenderer.java From hellocharts-android with Apache License 2.0 | 6 votes |
private void calculateMaxViewport() { tempMaximumViewport.set(Float.MAX_VALUE, Float.MIN_VALUE, Float.MIN_VALUE, Float.MAX_VALUE); LineChartData data = dataProvider.getLineChartData(); for (Line line : data.getLines()) { // Calculate max and min for viewport. for (PointValue pointValue : line.getValues()) { if (pointValue.getX() < tempMaximumViewport.left) { tempMaximumViewport.left = pointValue.getX(); } if (pointValue.getX() > tempMaximumViewport.right) { tempMaximumViewport.right = pointValue.getX(); } if (pointValue.getY() < tempMaximumViewport.bottom) { tempMaximumViewport.bottom = pointValue.getY(); } if (pointValue.getY() > tempMaximumViewport.top) { tempMaximumViewport.top = pointValue.getY(); } } } }
Example #9
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 #10
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 #11
Source File: StatisticViewModel.java From OmniList with GNU Affero General Public License v3.0 | 6 votes |
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 #12
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 #13
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); }
Example #14
Source File: LineChartRenderer.java From hellocharts-android with Apache License 2.0 | 5 votes |
@Override public void drawUnclipped(Canvas canvas) { final LineChartData data = dataProvider.getLineChartData(); int lineIndex = 0; for (Line line : data.getLines()) { if (checkIfShouldDrawPoints(line)) { drawPoints(canvas, line, lineIndex, MODE_DRAW); } ++lineIndex; } if (isTouched()) { // Redraw touched point to bring it to the front highlightPoints(canvas); } }
Example #15
Source File: LineChartRenderer.java From hellocharts-android with Apache License 2.0 | 5 votes |
@Override public void draw(Canvas canvas) { final LineChartData data = dataProvider.getLineChartData(); final Canvas drawCanvas; // softwareBitmap can be null if chart is rendered in layout editor. In that case use default canvas and not // softwareCanvas. if (null != softwareBitmap) { drawCanvas = softwareCanvas; drawCanvas.drawColor(Color.TRANSPARENT, Mode.CLEAR); } else { drawCanvas = canvas; } for (Line line : data.getLines()) { if (line.hasLines()) { if (line.isCubic()) { drawSmoothPath(drawCanvas, line); } else if (line.isSquare()) { drawSquarePath(drawCanvas, line); } else { drawPath(drawCanvas, line); } } } if (null != softwareBitmap) { canvas.drawBitmap(softwareBitmap, 0, 0, null); } }
Example #16
Source File: PreviewLineChartView.java From hellocharts-android with Apache License 2.0 | 5 votes |
public PreviewLineChartView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); chartComputator = new PreviewChartComputator(); previewChartRenderer = new PreviewLineChartRenderer(context, this, this); touchHandler = new PreviewChartTouchHandler(context, this); setChartRenderer(previewChartRenderer); setLineChartData(LineChartData.generateDummyData()); }
Example #17
Source File: LineChartView.java From hellocharts-android with Apache License 2.0 | 5 votes |
@Override public void setLineChartData(LineChartData data) { if (BuildConfig.DEBUG) { Log.d(TAG, "Setting data for LineChartView"); } if (null == data) { this.data = LineChartData.generateDummyData(); } else { this.data = data; } super.onChartDataChange(); }
Example #18
Source File: BgSparklineBuilder.java From NightWatch with GNU General Public License v3.0 | 5 votes |
Bitmap build() { List<Line> lines = new ArrayList<>(); bgGraphBuilder.defaultLines(); lines.add(bgGraphBuilder.inRangeValuesLine()); lines.add(bgGraphBuilder.lowValuesLine()); lines.add(bgGraphBuilder.highValuesLine()); if (showLowLine) lines.add(bgGraphBuilder.lowLine()); if (showHighLine) lines.add(bgGraphBuilder.highLine()); if (useSmallDots) { for(Line line: lines) line.setPointRadius(1); } LineChartData lineData = new LineChartData(lines); if (showAxes) { lineData.setAxisYLeft(bgGraphBuilder.yAxis()); lineData.setAxisXBottom(bgGraphBuilder.xAxis()); } //lines.add(bgGraphBuilder.rawInterpretedLine()); chart.setLineChartData(lineData); Viewport viewport = chart.getMaximumViewport(); viewport.left = start; viewport.right = end; chart.setViewportCalculationEnabled(false); chart.setInteractive(false); chart.setCurrentViewport(viewport); chart.setPadding(0,0,0,0); chart.setLeft(0); chart.setTop(0); chart.setRight(width); chart.setBottom(height); return getViewBitmap(chart); }
Example #19
Source File: BgSparklineBuilder.java From NightWatch with GNU General Public License v3.0 | 5 votes |
public Bitmap build() { List<Line> lines = new ArrayList<>(); bgGraphBuilder.defaultLines(); lines.add(bgGraphBuilder.inRangeValuesLine()); lines.add(bgGraphBuilder.lowValuesLine()); lines.add(bgGraphBuilder.highValuesLine()); if (showLowLine) lines.add(bgGraphBuilder.lowLine()); if (showHighLine) lines.add(bgGraphBuilder.highLine()); if (useSmallDots) { for(Line line: lines) line.setPointRadius(2); } LineChartData lineData = new LineChartData(lines); if (showAxes) { lineData.setAxisYLeft(bgGraphBuilder.yAxis()); lineData.setAxisXBottom(bgGraphBuilder.xAxis()); } //lines.add(bgGraphBuilder.rawInterpretedLine()); chart.setLineChartData(lineData); Viewport viewport = chart.getMaximumViewport(); viewport.left = start; viewport.right = end; chart.setViewportCalculationEnabled(false); chart.setInteractive(false); chart.setCurrentViewport(viewport); chart.setPadding(0, 0, 0, 0); chart.setLeft(0); chart.setTop(0); chart.setRight(width); chart.setBottom(height); return getViewBitmap(chart); }
Example #20
Source File: BasalVSTempBasalGraph.java From HAPP with GNU General Public License v3.0 | 5 votes |
public LineChartData basalvsTempBasalData() { LineChartData lineData = new LineChartData(addBasalvsTempBasaLines()); lineData.setAxisYLeft(basalVsTempBasalyAxis()); //lineData.setAxisYRight(cobPastyAxis()); lineData.setAxisXBottom(xAxis()); return lineData; }
Example #21
Source File: IOBCOBLineGraph.java From HAPP with GNU General Public License v3.0 | 5 votes |
public LineChartData iobcobPastLineData() { LineChartData lineData = new LineChartData(iobcobPastdefaultLines()); lineData.setAxisYLeft(iobPastyAxis()); lineData.setAxisYRight(cobPastyAxis()); lineData.setAxisXBottom(xAxis()); Log.d(TAG, "Updated"); return lineData; }
Example #22
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 #23
Source File: MainActivity.java From HAPP with GNU General Public License v3.0 | 5 votes |
@Override protected LineChartData doInBackground(LineChartData... arg0) { Realm realm = new RealmManager().getRealm(); LineChartData lineChartData; try { basalVSTempBasalGraph = new BasalVSTempBasalGraph(realm); lineChartData = basalVSTempBasalGraph.basalvsTempBasalData(); } finally { realm.close(); } return lineChartData; }
Example #24
Source File: MainActivity.java From HAPP with GNU General Public License v3.0 | 5 votes |
@Override protected ArrayList<LineChartData> doInBackground(ArrayList<LineChartData>... arg0) { Realm realm = new RealmManager().getRealm(); ArrayList<LineChartData> lineChartDataList = new ArrayList<>(); try { bgGraph = new BgGraph(realm); lineChartDataList.add(bgGraph.lineData()); lineChartDataList.add(bgGraph.previewLineData()); } finally { realm.close(); } return lineChartDataList; }
Example #25
Source File: CheckableLineChartView.java From SoloPi with Apache License 2.0 | 5 votes |
@Override public void setLineChartData(LineChartData data) { super.setLineChartData(data); if (renderer != null) { renderer.setCheckedValue(null); } }
Example #26
Source File: LineCharts.java From MetalDetector with GNU General Public License v3.0 | 5 votes |
/** * 初始化图表数据 * */ protected LineChartData initData(List<Line> lines) { LineChartData data = new LineChartData(lines); data.setAxisYLeft(axisY); data.setAxisXBottom(axisX); return data; }
Example #27
Source File: StatisticViewModel.java From OmniList with GNU Affero General Public License v3.0 | 5 votes |
public LineChartData getDefaultAssignmentData(int lineColor) { List<Integer> defaultValues = new LinkedList<>(); for (int i=0; i<StatisticViewModel.DAYS_OF_ADDED_MODEL; i++) { defaultValues.add(DEFAULT_ADDED_VALUE); } return getLineChartData(Collections.singletonList(getLine(defaultValues, lineColor))); }
Example #28
Source File: MainActivity.java From HAPP with GNU General Public License v3.0 | 5 votes |
@Override protected LineChartData doInBackground(LineChartData... arg0) { Realm realm = new RealmManager().getRealm(); LineChartData lineChartData; try { iobcobLineGraph = new IOBCOBLineGraph(realm); lineChartData = iobcobLineGraph.iobcobPastLineData(); } finally { realm.close(); } return lineChartData; }
Example #29
Source File: BgSparklineBuilder.java From NightWatch with GNU General Public License v3.0 | 5 votes |
Bitmap build() { List<Line> lines = new ArrayList<>(); bgGraphBuilder.defaultLines(); lines.add(bgGraphBuilder.inRangeValuesLine()); lines.add(bgGraphBuilder.lowValuesLine()); lines.add(bgGraphBuilder.highValuesLine()); if (showLowLine) lines.add(bgGraphBuilder.lowLine()); if (showHighLine) lines.add(bgGraphBuilder.highLine()); if (useSmallDots) { for(Line line: lines) line.setPointRadius(1); } LineChartData lineData = new LineChartData(lines); if (showAxes) { lineData.setAxisYLeft(bgGraphBuilder.yAxis()); lineData.setAxisXBottom(bgGraphBuilder.xAxis()); } //lines.add(bgGraphBuilder.rawInterpretedLine()); chart.setLineChartData(lineData); Viewport viewport = chart.getMaximumViewport(); viewport.left = start; viewport.right = end; chart.setViewportCalculationEnabled(false); chart.setInteractive(false); chart.setCurrentViewport(viewport); chart.setPadding(0,0,0,0); chart.setLeft(0); chart.setTop(0); chart.setRight(width); chart.setBottom(height); return getViewBitmap(chart); }
Example #30
Source File: BgSparklineBuilder.java From NightWatch with GNU General Public License v3.0 | 5 votes |
public Bitmap build() { List<Line> lines = new ArrayList<>(); bgGraphBuilder.defaultLines(); lines.add(bgGraphBuilder.inRangeValuesLine()); lines.add(bgGraphBuilder.lowValuesLine()); lines.add(bgGraphBuilder.highValuesLine()); if (showLowLine) lines.add(bgGraphBuilder.lowLine()); if (showHighLine) lines.add(bgGraphBuilder.highLine()); if (useSmallDots) { for(Line line: lines) line.setPointRadius(2); } LineChartData lineData = new LineChartData(lines); if (showAxes) { lineData.setAxisYLeft(bgGraphBuilder.yAxis()); lineData.setAxisXBottom(bgGraphBuilder.xAxis()); } //lines.add(bgGraphBuilder.rawInterpretedLine()); chart.setLineChartData(lineData); Viewport viewport = chart.getMaximumViewport(); viewport.left = start; viewport.right = end; chart.setViewportCalculationEnabled(false); chart.setInteractive(false); chart.setCurrentViewport(viewport); chart.setPadding(0, 0, 0, 0); chart.setLeft(0); chart.setTop(0); chart.setRight(width); chart.setBottom(height); return getViewBitmap(chart); }