IBM Support

When using the nearest point picking mode for IlvChartPickInteractor, performing a mouse click on a polyline chart does not select the nearest data point

Technote (troubleshooting)


Why the nearest data point is not selected when clicking on a polyline chart with IlvChartPickInteractor in the nearest point picking mode?


By default the pick distance is set to 5. As the API documentation states for IlvChartDataPicker.getPickDistance():

"This distance specifies the maximum distance from the picking point beyond which data points are not considered."

Therefore, if you are using the nearest point picking mode, your mouse click must be no more than 5 pixels away from a point for the nearest point to be found.

Resolving the problem

You can set a new pick distance by subclassing IlvChartPickInteractor and overriding its createDataPicker method. Inside the createDataPicker method you will return a new DataPicker in which you pass in the pick distance as the third argument.

Here is a code snippet that sets the pick distance to 300 pixels:

public class NearestInteractor extends IlvChartPickInteractor {

    private int _minDist = 300;
    public void setMinDist(int minDist) {
        _minDist = minDist;
    public int getMinDist() {
        return _minDist;
    protected IlvChartDataPicker createDataPicker(MouseEvent event)
      return new DataPicker(event.getX(), event.getY(), _minDist);

Cross reference information
Segment Product Component Platform Version Edition
Business Integration IBM ILOG JViews Enterprise SDK Linux, Windows, Solaris, Mac OS X 8.8, 8.7, 8.6 All Editions

Document information

More support for: IBM ILOG JViews Charts

Software version: 8.6, 8.7, 8.8

Operating system(s): Linux, OS X, Solaris, Windows

Reference #: 1600346

Modified date: 31 May 2013