achartengine chart will not zoom even though zoom is enabled

心不动则不痛 提交于 2019-12-24 17:31:38

问题


I am running a data request from a service on a thread. I cannot seem to get pan or zoom to work for this app. Here is the method where I am setting it to allow zoom. I have also checked that zoom is enabled.

private void getRPData2() 
{

    final ScadaDataList l = new ScadaDataList();
    final long value = new Date().getTime() - 3 * TimeChart.DAY;
    new Thread(new Runnable()
    {
        public void run()
        {
            try 
            {
                //System.out.println("made it");
                l.Load(Cookie);

                final Date d = new Date();

                runOnUiThread(new Runnable() {
                    public void run() {

                        /*for (int i = 0; i < 100; i++) {
                            time_series.add(new Date(value + i * TimeChart.DAY / 4), i);
                        }*/
                        for (ScadaData sd: l) 
                        {    
                            if (sd.getDataTS().compareTo(d) <= 0)
                            {
                                time_series.add(sd.getDataTS(),sd.getActualLoad() * 1000);
                                ProtectedLoadSeries.add(sd.getDataTS(),sd.getProtectedLoad() * 1000);
                            }

                        }
                        mRenderer.setXLabels(12);
                        mRenderer.setYLabels(8);
                        mRenderer.setXLabelsAngle(60);
                        mRenderer.setXLabelsAlign(Align.LEFT);
                        //mRenderer.setYLabelsAngle(-60);
                        mRenderer.setYLabelsAlign(Align.RIGHT);
                        mRenderer.setPanEnabled(true);
                        mRenderer.setShowGrid(true);
                        mRenderer.setGridColor(Color.argb(180, 66, 66, 66));

                        mRenderer.setZoomEnabled(true);

                        mChartView.repaint();
                        progress.dismiss();
                    }
                });
            } 
            catch (Exception e) 
            {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }).start();
}

回答1:


It looks like you are using the wrong version of the methods. Use these instead:

mRenderer.setPanEnabled(true, true
mRenderer.setZoomEnabled(true, true);


来源:https://stackoverflow.com/questions/15010644/achartengine-chart-will-not-zoom-even-though-zoom-is-enabled

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!