5

I am having an issue getting the onclicklistener to work with achartengine1.0.0 for android. Specifically I am not able to return anything from the ".getCurrentSeriesAndPoint" (always null).

SeriesSelection seriesSelection = gView.getCurrentSeriesAndPoint();

So I have a class which create my chart view as follows...

public class xyScatter extends Application {
    public GraphicalView getGView(Context context) {

         ...(STUFF)...

          mRenderer.setClickEnabled(true);
          mRenderer.setSelectableBuffer(100);

         ...(STUFF)...

          return ChartFactory.getScatterChartView(context, dataset, mRenderer);
    }
}

Then in my activity I have the following method

private void displayXY() {

   xyScatter xyScat = new xyScatter();
   final GraphicalView gView = xyScat.getGView(this);
   glayout.removeAllViews();
   glayout.addView(gView);

   gView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            SeriesSelection seriesSelection = gView.getCurrentSeriesAndPoint();

            Log.d("seriesSelection", String.valueOf(seriesSelection));

            if (seriesSelection == null) {
                Log.d("OnClickXY", "Nothing Selected");
            } else {
                Log.d("OnClickXY", "Something Selected");
            }
        }
    });

}

Does this have something to do with me adding the chart as a GraphicalView within a linearLayout?

I tried searching several sites with no avail. Example

Community
  • 1
  • 1
nate
  • 51
  • 2
  • EDIT: Ok so I found the issue. So I had multiple series in the chart and sometime the series were blank. For some reason when they are blank the entire chart will not allow you to select points. If someone has a solution I would be open to suggestions. I think that I am going to just add a check to see if the series should be added to the multiple renderer. I am not sure if I should delete this post, but will leave it up for now in case anyone else runs into this. – nate Oct 13 '12 at 00:10

1 Answers1

0

In case somebody will be interested to check even more examples of doing this, I suggest taking a look at the official AChartEngine demo code, especially at this example that relates to your question.

Dan D.
  • 32,246
  • 5
  • 63
  • 79