Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public void mouseDragged(MouseEvent e) {
// ignore
}


@Override
public void mouseMoved(MouseEvent e) {

Expand Down Expand Up @@ -89,6 +90,21 @@ else if (dataPoint != null) {
dataPoint = null;
e.getComponent().repaint(); // repaint the entire XChartPanel
}

/*This loop checks the X position of the mouse in the chart, and runs through
* the datapoints to determine if the user is hovering over anything. If so,
* a datapoints information can be displayed however a user sees fit.
* This could be built on in the future with a custom UI for the info
*
* chart.getStyler().setToolTipsEnabled(true); must be enabled in your chart. */
for (DataPoint dataPoint : dataPointList) {
Integer result = Integer.compare((int) dataPoint.x, e.getX());
if (result == 0) {
System.out.println(dataPoint.label);
//This is an execution point for when the mouse is over a datapoint.
}
}

}

void prepare(Graphics2D g) {
Expand Down