AnyChart / AnyChart-Android

AnyChart Android Chart is an amazing data visualization library for easily creating interactive charts in Android apps. It runs on API 19+ (Android 4.4) and features dozens of built-in chart types.
2.31k stars 369 forks source link

Can we have Zoom/Scroll feature in line chart? #61

Open krishnamurthy12 opened 5 years ago

Shestac92 commented 5 years ago

@krishnamurthy12 Yes, you can add xScroller to the basic charts. Here is the sample code:

     AnyChartView anyChartView = findViewById(R.id.any_chart_view);

        Cartesian cartesian = AnyChart.line();

        cartesian.xScroller(true);

        OrdinalZoom xZoom = cartesian.xZoom();

        xZoom.setToPointsCount(6, false, null);

        xZoom.getStartRatio();
        xZoom.getEndRatio();

        List<DataEntry> data = new ArrayList<>();
        data.add(new ValueDataEntry("00:00", 10));
        data.add(new ValueDataEntry("01:00", 4));
        data.add(new ValueDataEntry("02:00", 17));
        data.add(new ValueDataEntry("03:00", 20));
        data.add(new ValueDataEntry("04:00", 20));
        data.add(new ValueDataEntry("05:00", 16));
        data.add(new ValueDataEntry("06:00", 35));
        data.add(new ValueDataEntry("07:00", 6));
        data.add(new ValueDataEntry("08:00", 15));
        data.add(new ValueDataEntry("09:00", 19));
        data.add(new ValueDataEntry("10:00", 25));
        data.add(new ValueDataEntry("11:00", 34));
        data.add(new ValueDataEntry("12:00", 42));
        data.add(new ValueDataEntry("13:00", 14));
        data.add(new ValueDataEntry("14:00", 50));
        data.add(new ValueDataEntry("15:00", 25));
        data.add(new ValueDataEntry("16:00", 34));
        data.add(new ValueDataEntry("17:00", 40));
        data.add(new ValueDataEntry("18:00", 64));
        data.add(new ValueDataEntry("19:00", 48));
        data.add(new ValueDataEntry("20:00", 22));
        data.add(new ValueDataEntry("21:00", 37));
        data.add(new ValueDataEntry("22:00", 53));
        data.add(new ValueDataEntry("23:00", 62));

        Line series1 = cartesian.line(data);
        series1.name("Total support requests");

        cartesian.xAxis(0).title("Hours");
        cartesian.yAxis(0).title("Support requests");

        anyChartView.setChart(cartesian);
kishantaretiya commented 4 years ago

Can we have Zoombutton feature in candle chart

Shestac92 commented 4 years ago

@kishantaretiya Do you mean in AnyChart.stock() chart or AnyChart.cartesian() with candlestick series? The stock chart provides a scroller with zooming as out-of-the-box. Here is the sample of a Stock chart.

kishantaretiya commented 4 years ago

@Shestac92 thanks for response but i mean zooming button only not scroller

Shestac92 commented 4 years ago

@kishantaretiya It's possible too! You can create in UI buttons and in listeners call AnyChart API to manage chart settings. For example, for the Stock chart, you can call selectRange() method from the chart instance to apply a new visible range. You can calculate the new range from the current range and desired logic. To know the current range use getMaximum() and getMinimum() methods of the chart xScale.

kishantaretiya commented 4 years ago

thanku sir

kishantaretiya commented 4 years ago

can we hide the icon of collapse/expand plot in chart

Shestac92 commented 4 years ago

@krishnamurthy12 Unfortunately, it's not possible to disable the plot controls in the current version of the library.