achartengine chart will not zoom even though zoom

2019-08-06 00:02发布

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条回答
叼着烟拽天下
2楼-- · 2019-08-06 00:59

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

mRenderer.setPanEnabled(true, true
mRenderer.setZoomEnabled(true, true);
查看更多
登录 后发表回答