问题
I have a workable tooltip system set-up with my normal graphing options (not using dashes) by using the plothover event, but the plot is not hoverable when I switch to my "black and white" mode (using dashes). Is there any way to keep the graph hoverable and clickable when using dashes? Or a way to make a decent looking plot in black and white without dashes?
Example series: {data: data, dashes:{show: true, dashLength: 2}, color: "black", label: "Series 1"}
My current graphing options:
options = {
yaxis: {max: maxValue, min: minValue},
grid: {hoverable: true, clickable: true},
legend: {show: false},
xaxis: {tickFormatter: null}
};
I use plothover event for tooltips like this:
$(this).bind("plotclick", function (event, pos, item){
//tooltip code here
}
回答1:
See this issue filled against the jQuery.flot.dashes
plugin.
Regarding the hover issue, there's a function called "findNearbyItem" in jquery.flot.js that performs the search only if the plot is showing lines, points or bars. If you only have "dashes" showing, then it won't perform the search.
Two choices:
- Modify the jquery.flot.js file in the following line:if (s.lines.show || s.points.show)
to something likeif (s.lines.show || s.points.show || s.dashes.show)
- Show points with 0 radius in the series you show dashes: (from the example in comment #41){ label: "sin(x)", data: d1, dashes: { show: true, steps:true }, points: {show: true, radius:0 }}
I agree with the poster that the second solution is a better idea. I've also tried it out in this fiddle and is works well.
来源:https://stackoverflow.com/questions/24593077/does-jquery-flot-dashes-js-support-plothover-and-plotclick