问题
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