Java Code Examples for lecho.lib.hellocharts.view.LineChartView#getMaximumViewport()

The following examples show how to use lecho.lib.hellocharts.view.LineChartView#getMaximumViewport() . 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 vote down vote up
@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: ExampleChartPreferenceView.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
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 3
Source File: ExampleChartPreferenceView.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
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: MainActivity.java    From HAPP with GNU General Public License v3.0 5 votes vote down vote up
@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 5
Source File: MainActivity.java    From HAPP with GNU General Public License v3.0 5 votes vote down vote up
@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);
    }
}