Java Code Examples for lecho.lib.hellocharts.model.Viewport#inset()
The following examples show how to use
lecho.lib.hellocharts.model.Viewport#inset() .
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: BubbleChartRenderer.java From hellocharts-android with Apache License 2.0 | 6 votes |
/** * Removes empty spaces on sides of chart(left-right for landscape, top-bottom for portrait). *This method should be * called after layout had been drawn*. Because most often chart is drawn as rectangle with proportions other than * 1:1 and bubbles have to be drawn as circles not ellipses I am unable to calculate correct margins based on chart * data only. I need to know chart dimension to remove extra empty spaces, that bad because viewport depends a * little on contentRectMinusAllMargins. */ public void removeMargins() { final Rect contentRect = computator.getContentRectMinusAllMargins(); if (contentRect.height() == 0 || contentRect.width() == 0) { // View probably not yet measured, skip removing margins. return; } final float pxX = computator.computeRawDistanceX(maxRadius * bubbleScaleX); final float pxY = computator.computeRawDistanceY(maxRadius * bubbleScaleY); final float scaleX = computator.getMaximumViewport().width() / contentRect.width(); final float scaleY = computator.getMaximumViewport().height() / contentRect.height(); float dx = 0; float dy = 0; if (isBubbleScaledByX) { dy = (pxY - pxX) * scaleY * 0.75f; } else { dx = (pxX - pxY) * scaleX * 0.75f; } Viewport maxViewport = computator.getMaximumViewport(); maxViewport.inset(dx, dy); Viewport currentViewport = computator.getCurrentViewport(); currentViewport.inset(dx, dy); computator.setMaxViewport(maxViewport); computator.setCurrentViewport(currentViewport); }
Example 3
Source File: BgGraphBuilder.java From xDrip with GNU General Public License v3.0 | 5 votes |
public Viewport advanceViewport(Chart chart, Chart previewChart) { viewport = new Viewport(previewChart.getMaximumViewport()); viewport.inset((float)((86400000 / 2.5)/fuzzer), 0); double distance_to_move = ((new Date().getTime())/fuzzer) - viewport.left - (((viewport.right - viewport.left) /2)); viewport.offset((float) distance_to_move, 0); return viewport; }
Example 4
Source File: PreviewLineChartActivity.java From hellocharts-android with Apache License 2.0 | 5 votes |
private void previewXY() { // Better to not modify viewport of any chart directly so create a copy. Viewport tempViewport = new Viewport(chart.getMaximumViewport()); // Make temp viewport smaller. float dx = tempViewport.width() / 4; float dy = tempViewport.height() / 4; tempViewport.inset(dx, dy); previewChart.setCurrentViewportWithAnimation(tempViewport); }
Example 5
Source File: PreviewLineChartActivity.java From hellocharts-android with Apache License 2.0 | 5 votes |
private void previewX(boolean animate) { Viewport tempViewport = new Viewport(chart.getMaximumViewport()); float dx = tempViewport.width() / 4; tempViewport.inset(dx, 0); if (animate) { previewChart.setCurrentViewportWithAnimation(tempViewport); } else { previewChart.setCurrentViewport(tempViewport); } previewChart.setZoomType(ZoomType.HORIZONTAL); }
Example 6
Source File: PreviewLineChartActivity.java From hellocharts-android with Apache License 2.0 | 5 votes |
private void previewY() { Viewport tempViewport = new Viewport(chart.getMaximumViewport()); float dy = tempViewport.height() / 4; tempViewport.inset(0, dy); previewChart.setCurrentViewportWithAnimation(tempViewport); previewChart.setZoomType(ZoomType.VERTICAL); }
Example 7
Source File: PreviewColumnChartActivity.java From hellocharts-android with Apache License 2.0 | 5 votes |
private void previewXY() { // Better to not modify viewport of any chart directly so create a copy. Viewport tempViewport = new Viewport(chart.getMaximumViewport()); // Make temp viewport smaller. float dx = tempViewport.width() / 4; float dy = tempViewport.height() / 4; tempViewport.inset(dx, dy); previewChart.setCurrentViewportWithAnimation(tempViewport); }
Example 8
Source File: PreviewColumnChartActivity.java From hellocharts-android with Apache License 2.0 | 5 votes |
private void previewX(boolean animate) { Viewport tempViewport = new Viewport(chart.getMaximumViewport()); float dx = tempViewport.width() / 4; tempViewport.inset(dx, 0); if (animate) { previewChart.setCurrentViewportWithAnimation(tempViewport); } else { previewChart.setCurrentViewport(tempViewport); } previewChart.setZoomType(ZoomType.HORIZONTAL); }
Example 9
Source File: PreviewColumnChartActivity.java From hellocharts-android with Apache License 2.0 | 5 votes |
private void previewY() { Viewport tempViewport = new Viewport(chart.getMaximumViewport()); float dy = tempViewport.height() / 4; tempViewport.inset(0, dy); previewChart.setCurrentViewportWithAnimation(tempViewport); previewChart.setZoomType(ZoomType.VERTICAL); }
Example 10
Source File: BgGraphBuilder.java From xDrip with GNU General Public License v3.0 | 5 votes |
public Viewport advanceViewport(Chart chart, Chart previewChart) { viewport = new Viewport(previewChart.getMaximumViewport()); viewport.inset((float) ((86400000 / 2.5) / FUZZER), 0); double distance_to_move = ((new Date().getTime())/ FUZZER) - viewport.left - (((viewport.right - viewport.left) /2)); viewport.offset((float) distance_to_move, 0); return viewport; }
Example 11
Source File: BgGraphBuilder.java From NightWatch with GNU General Public License v3.0 | 5 votes |
public Viewport advanceViewport(Chart chart, Chart previewChart) { viewport = new Viewport(previewChart.getMaximumViewport()); viewport.inset((float)((86400000 / 2.5)/fuzz), 0); double distance_to_move = ((new Date().getTime())/fuzz) - viewport.left - (((viewport.right - viewport.left) /2)); viewport.offset((float) distance_to_move, 0); return viewport; }
Example 12
Source File: BgGraph.java From HAPP with GNU General Public License v3.0 | 5 votes |
public Viewport advanceViewport(Chart chart, Chart previewChart) { viewport = new Viewport(previewChart.getMaximumViewport()); viewport.inset((float) (86400000 / 2.5), 0); double distance_to_move = (new Date().getTime()) - viewport.left - (((viewport.right - viewport.left) / 2)); viewport.offset((float) distance_to_move, 0); return viewport; }
Example 13
Source File: BgGraphBuilder.java From NightWatch with GNU General Public License v3.0 | 5 votes |
public Viewport advanceViewport(Chart chart, Chart previewChart) { viewport = new Viewport(previewChart.getMaximumViewport()); viewport.inset((float)((86400000 / 2.5)/fuzz), 0); double distance_to_move = ((new Date().getTime())/fuzz) - viewport.left - (((viewport.right - viewport.left) /2)); viewport.offset((float) distance_to_move, 0); return viewport; }
Example 14
Source File: BgGraphBuilder.java From xDrip-Experimental with GNU General Public License v3.0 | 5 votes |
public Viewport advanceViewport(Chart chart, Chart previewChart) { viewport = new Viewport(previewChart.getMaximumViewport()); viewport.inset((float) ((86400000 / 2.5) / FUZZER), 0); double distance_to_move = ((new Date().getTime())/ FUZZER) - viewport.left - (((viewport.right - viewport.left) /2)); viewport.offset((float) distance_to_move, 0); return viewport; }
Example 15
Source File: BgGraphBuilder.java From xDrip-plus with GNU General Public License v3.0 | 5 votes |
public Viewport advanceViewport(Chart chart, Chart previewChart, float hours) { viewport = new Viewport(previewChart.getMaximumViewport()); viewport.inset((float) ((86400000 / hours) / FUZZER), 0); double distance_to_move = ((new Date().getTime()) / FUZZER) - viewport.left - (((viewport.right - viewport.left) / 2)); viewport.offset((float) distance_to_move, 0); return viewport; }
Example 16
Source File: BgGraphBuilder.java From xDrip-plus with GNU General Public License v3.0 | 5 votes |
public Viewport advanceViewport(Chart chart, Chart previewChart) { viewport = new Viewport(previewChart.getMaximumViewport()); viewport.inset((float) ((86400000 / 2.5) / FUZZER), 0); double distance_to_move = ((new Date().getTime())/ FUZZER) - viewport.left - (((viewport.right - viewport.left) /2)); viewport.offset((float) distance_to_move, 0); return viewport; }
Example 17
Source File: BgGraphBuilder.java From xDrip with GNU General Public License v3.0 | 5 votes |
public Viewport advanceViewport(Chart chart, Chart previewChart, float hours) { viewport = new Viewport(previewChart.getMaximumViewport()); viewport.inset((float) ((86400000 / hours) / FUZZER), 0); double distance_to_move = ((new Date().getTime()) / FUZZER) - viewport.left - (((viewport.right - viewport.left) / 2)); viewport.offset((float) distance_to_move, 0); return viewport; }