Achart Engine Line chart - Display pop up on click

2019-08-04 15:45发布

问题:

I am using Achart Engine Line chart to display values, i am using point style CIRCLE.

I am trying to implementing the below :

1) Increase the point style width - i mean the circle should be bit bigger.

2) On click of each point i want a popup to be displayed on top of that which will display the values of X and Y.

I have done some research on this but was not able to find the solution.

I found this code but how to display the small popup with values ?

final LineChart chart = new LineChart(buildDataset(mTitles, data), mRenderer);
final GraphicalView view = new GraphicalView(mContext, chart);
view.setOnClickListener(new View.OnClickListener() {
  public void onClick(View v) {
     double[] xy = chart.toScreenPoint(view.toRealPoint(0));
     int[] location = new int[] {(int) xy[0], (int) xy[1]};
     SeriesSelection seriesSelection = view.getCurrentSeriesAndPoint();
     if (seriesSelection != null) {
         final Data d = mModel.getDiaryAt(seriesSelection.getSeriesIndex(), 
         seriesSelection.getPointIndex());
         //show popup at xy[0] xy[1]
     }
  }
});

It might have been not given in the SDK but still if anyone has tried this as was successful.

** EDIT **

Link 1 : achartengine toScreenPoint(double) always returns nullPointerException

In the image you can see a popup i want to implement like that.

回答1:

You can see an example here on how to display the clicked point in your chart, using AChartEngine.