Skip to content

Commit 383fcd2

Browse files
committed
Import crosshair library, define function that draws crosshair
1 parent 7bf4ab5 commit 383fcd2

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

webapp/javascript/components/TimelineChart.jsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import "react-dom";
55
import ReactFlot from "react-flot";
66
import "react-flot/flot/jquery.flot.time.min";
77
import "react-flot/flot/jquery.flot.selection.min";
8+
import "react-flot/flot/jquery.flot.crosshair.min";
89
import { bindActionCreators } from "redux";
910
import { setDateRange, receiveJSON } from "../redux/actions";
1011

@@ -17,6 +18,17 @@ class TimelineChart extends ReactFlot {
1718
Math.round(ranges.xaxis.to / 1000)
1819
);
1920
});
21+
22+
$(`#${this.props.id}`).bind("plothover", (evt, position) => {
23+
if (position) {
24+
this.lockCrosshair({
25+
x: item.datapoint[0],
26+
y: item.datapoint[1],
27+
});
28+
} else {
29+
this.unlockCrosshair();
30+
}
31+
});
2032
}
2133
}
2234

0 commit comments

Comments
 (0)