Java Code Examples for lecho.lib.hellocharts.view.LineChartView#setCurrentViewport()
The following examples show how to use
lecho.lib.hellocharts.view.LineChartView#setCurrentViewport() .
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: GoodBadChartActivity.java From hellocharts-android with Apache License 2.0 | 6 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_good_bad, container, false); chart = (LineChartView) rootView.findViewById(R.id.chart); generateDefaultData(); chart.setLineChartData(data); // Increase viewport height for better look Viewport v = chart.getMaximumViewport(); float dy = v.height() * 0.2f; v.inset(0, -dy); chart.setMaximumViewport(v); chart.setCurrentViewport(v); return rootView; }
Example 2
Source File: LineCharts.java From MetalDetector with GNU General Public License v3.0 | 5 votes |
protected void makeCharts(final LineChartView lineChartView,float uT){ //实时添加新的点 PointValue value1 = new PointValue(position * 5, uT); value1.setLabel("00:00"); pointValueList.add(value1); float x = value1.getX(); float y = uT; //根据新的点的集合画出新的线 Line line = new Line(pointValueList); line.setColor(Color.RED); line.setShape(ValueShape.CIRCLE); line.setCubic(true);//曲线是否平滑 line.setHasPoints(false);//设置折线是否含点 linesList.clear(); linesList.add(line); lineChartData = initData(linesList); lineChartView.setLineChartData(lineChartData); //根据点的横坐实时变换坐标的视图范围 Viewport port; if (x > 500) { port = initViewPort(x - 500, x, y); } else { port = initViewPort(0, 500 ,y); } lineChartView.setCurrentViewport(port);//当前窗口 Viewport maxPort = initMaxViewPort(x,y);//更新最大窗口设置 lineChartView.setMaximumViewport(maxPort);//最大窗口 position++; }
Example 3
Source File: ExampleChartPreferenceView.java From xDrip with GNU General Public License v3.0 | 5 votes |
protected void refreshView(View view) { LineChartView chart = (LineChartView) view.findViewById(R.id.example_linechart); BgGraphBuilder bgGraphBuilder = new BgGraphBuilder(getContext()); chart.setLineChartData(bgGraphBuilder.lineData()); Viewport viewport = chart.getMaximumViewport(); chart.setViewportCalculationEnabled(false); chart.setInteractive(false); chart.setCurrentViewport(viewport); chart.setPadding(0, 0, 0, 0); chart.setLeft(0); chart.setTop(0); Log.d(TAG, "onBindExampleChart: refreshview " + chart.getHeight()); }
Example 4
Source File: ExampleChartPreferenceView.java From xDrip-plus with GNU General Public License v3.0 | 5 votes |
protected void refreshView(View view) { LineChartView chart = (LineChartView) view.findViewById(R.id.example_linechart); BgGraphBuilder bgGraphBuilder = new BgGraphBuilder(getContext()); chart.setLineChartData(bgGraphBuilder.lineData()); Viewport viewport = chart.getMaximumViewport(); chart.setViewportCalculationEnabled(false); chart.setInteractive(false); chart.setCurrentViewport(viewport); chart.setPadding(0, 0, 0, 0); chart.setLeft(0); chart.setTop(0); Log.d(TAG, "onBindExampleChart: refreshview " + chart.getHeight()); }
Example 5
Source File: MainActivity.java From HAPP with GNU General Public License v3.0 | 5 votes |
@Override public void onViewportChanged(Viewport newViewport) { if (!updatingPreviewViewport) { updatingChartViewport = true; bgPreviewChart.setZoomType(ZoomType.HORIZONTAL); bgPreviewChart.setCurrentViewport(newViewport); updatingChartViewport = false; if (iobcobFragmentObject.getView() != null) { //Fragment is loaded LineChartView iobcobPastChart = (LineChartView) findViewById(R.id.iobcobPast); Viewport iobv = new Viewport(bgChart.getMaximumViewport()); //Update the IOB COB Line Chart Viewport to stay inline with the preview iobv.left = newViewport.left; iobv.right = newViewport.right; iobv.top = iobcobPastChart.getMaximumViewport().top; iobv.bottom = iobcobPastChart.getMaximumViewport().bottom; iobcobPastChart.setMaximumViewport(iobv); iobcobPastChart.setCurrentViewport(iobv); } if (basalvsTempBasalObject.getView() != null){ LineChartView bvbChart = (LineChartView) findViewById(R.id.basalvsTempBasal_LineChart); Viewport bvbv = new Viewport(bgChart.getMaximumViewport()); bvbv.left = newViewport.left; bvbv.right = newViewport.right; bvbv.top = bvbChart.getMaximumViewport().top; bvbv.bottom = bvbChart.getMaximumViewport().bottom; bvbChart.setMaximumViewport(bvbv); bvbChart.setCurrentViewport(bvbv); } } }
Example 6
Source File: MainActivity.java From HAPP with GNU General Public License v3.0 | 5 votes |
@Override public void onViewportChanged(Viewport newViewport) { if (!updatingChartViewport) { updatingPreviewViewport = true; bgChart.setZoomType(ZoomType.HORIZONTAL); bgChart.setCurrentViewport(newViewport); tempViewport = newViewport; updatingPreviewViewport = false; if (iobcobFragmentObject.getView() != null) { //Fragment is loaded LineChartView iobcobPastChart = (LineChartView) findViewById(R.id.iobcobPast); iobcobPastChart.setCurrentViewport(newViewport); Viewport iobv = new Viewport(iobcobPastChart.getMaximumViewport()); //Update the IOB COB Line Chart Viewport to stay inline with the preview iobv.left = newViewport.left; iobv.right = newViewport.right; iobv.top = iobcobPastChart.getMaximumViewport().top; iobv.bottom = iobcobPastChart.getMaximumViewport().bottom; iobcobPastChart.setMaximumViewport(iobv); iobcobPastChart.setCurrentViewport(iobv); } if (basalvsTempBasalObject.getView() != null){ LineChartView bvbChart = (LineChartView) findViewById(R.id.basalvsTempBasal_LineChart); Viewport bvbv = new Viewport(bgChart.getMaximumViewport()); bvbv.left = newViewport.left; bvbv.right = newViewport.right; bvbv.top = bvbChart.getMaximumViewport().top; bvbv.bottom = bvbChart.getMaximumViewport().bottom; bvbChart.setMaximumViewport(bvbv); bvbChart.setCurrentViewport(bvbv); } } if (updateStuff) { holdViewport.set(newViewport.left, newViewport.top, newViewport.right, newViewport.bottom); } }