1 | /** |
---|
2 | * jqPlot |
---|
3 | * Pure JavaScript plotting plugin using jQuery |
---|
4 | * |
---|
5 | * Version: 1.0.0b2_r1012 |
---|
6 | * |
---|
7 | * Copyright (c) 2009-2011 Chris Leonello |
---|
8 | * jqPlot is currently available for use in all personal or commercial projects |
---|
9 | * under both the MIT (http://www.opensource.org/licenses/mit-license.php) and GPL |
---|
10 | * version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) licenses. This means that you can |
---|
11 | * choose the license that best suits your project and use it accordingly. |
---|
12 | * |
---|
13 | * Although not required, the author would appreciate an email letting him |
---|
14 | * know of any substantial use of jqPlot. You can reach the author at: |
---|
15 | * chris at jqplot dot com or see http://www.jqplot.com/info.php . |
---|
16 | * |
---|
17 | * If you are feeling kind and generous, consider supporting the project by |
---|
18 | * making a donation at: http://www.jqplot.com/donate.php . |
---|
19 | * |
---|
20 | * sprintf functions contained in jqplot.sprintf.js by Ash Searle: |
---|
21 | * |
---|
22 | * version 2007.04.27 |
---|
23 | * author Ash Searle |
---|
24 | * http://hexmen.com/blog/2007/03/printf-sprintf/ |
---|
25 | * http://hexmen.com/js/sprintf.js |
---|
26 | * The author (Ash Searle) has placed this code in the public domain: |
---|
27 | * "This code is unrestricted: you are free to use it however you like." |
---|
28 | * |
---|
29 | */ |
---|
30 | (function($) { |
---|
31 | $.jqplot.eventListenerHooks.push(['jqplotMouseMove', handleMove]); |
---|
32 | |
---|
33 | /** |
---|
34 | * Class: $.jqplot.Highlighter |
---|
35 | * Plugin which will highlight data points when they are moused over. |
---|
36 | * |
---|
37 | * To use this plugin, include the js |
---|
38 | * file in your source: |
---|
39 | * |
---|
40 | * > <script type="text/javascript" src="plugins/jqplot.highlighter.js"></script> |
---|
41 | * |
---|
42 | * A tooltip providing information about the data point is enabled by default. |
---|
43 | * To disable the tooltip, set "showTooltip" to false. |
---|
44 | * |
---|
45 | * You can control what data is displayed in the tooltip with various |
---|
46 | * options. The "tooltipAxes" option controls wether the x, y or both |
---|
47 | * data values are displayed. |
---|
48 | * |
---|
49 | * Some chart types (e.g. hi-low-close) have more than one y value per |
---|
50 | * data point. To display the additional values in the tooltip, set the |
---|
51 | * "yvalues" option to the desired number of y values present (3 for a hlc chart). |
---|
52 | * |
---|
53 | * By default, data values will be formatted with the same formatting |
---|
54 | * specifiers as used to format the axis ticks. A custom format code |
---|
55 | * can be supplied with the tooltipFormatString option. This will apply |
---|
56 | * to all values in the tooltip. |
---|
57 | * |
---|
58 | * For more complete control, the "formatString" option can be set. This |
---|
59 | * Allows conplete control over tooltip formatting. Values are passed to |
---|
60 | * the format string in an order determined by the "tooltipAxes" and "yvalues" |
---|
61 | * options. So, if you have a hi-low-close chart and you just want to display |
---|
62 | * the hi-low-close values in the tooltip, you could set a formatString like: |
---|
63 | * |
---|
64 | * > highlighter: { |
---|
65 | * > tooltipAxes: 'y', |
---|
66 | * > yvalues: 3, |
---|
67 | * > formatString:'<table class="jqplot-highlighter"> |
---|
68 | * > <tr><td>hi:</td><td>%s</td></tr> |
---|
69 | * > <tr><td>low:</td><td>%s</td></tr> |
---|
70 | * > <tr><td>close:</td><td>%s</td></tr></table>' |
---|
71 | * > } |
---|
72 | * |
---|
73 | */ |
---|
74 | $.jqplot.Highlighter = function(options) { |
---|
75 | // Group: Properties |
---|
76 | // |
---|
77 | //prop: show |
---|
78 | // true to show the highlight. |
---|
79 | this.show = $.jqplot.config.enablePlugins; |
---|
80 | // prop: markerRenderer |
---|
81 | // Renderer used to draw the marker of the highlighted point. |
---|
82 | // Renderer will assimilate attributes from the data point being highlighted, |
---|
83 | // so no attributes need set on the renderer directly. |
---|
84 | // Default is to turn off shadow drawing on the highlighted point. |
---|
85 | this.markerRenderer = new $.jqplot.MarkerRenderer({shadow:false}); |
---|
86 | // prop: showMarker |
---|
87 | // true to show the marker |
---|
88 | this.showMarker = true; |
---|
89 | // prop: lineWidthAdjust |
---|
90 | // Pixels to add to the lineWidth of the highlight. |
---|
91 | this.lineWidthAdjust = 2.5; |
---|
92 | // prop: sizeAdjust |
---|
93 | // Pixels to add to the overall size of the highlight. |
---|
94 | this.sizeAdjust = 5; |
---|
95 | // prop: showTooltip |
---|
96 | // Show a tooltip with data point values. |
---|
97 | this.showTooltip = true; |
---|
98 | // prop: tooltipLocation |
---|
99 | // Where to position tooltip, 'n', 'ne', 'e', 'se', 's', 'sw', 'w', 'nw' |
---|
100 | this.tooltipLocation = 'nw'; |
---|
101 | // prop: fadeTooltip |
---|
102 | // true = fade in/out tooltip, flase = show/hide tooltip |
---|
103 | this.fadeTooltip = true; |
---|
104 | // prop: tooltipFadeSpeed |
---|
105 | // 'slow', 'def', 'fast', or number of milliseconds. |
---|
106 | this.tooltipFadeSpeed = "fast"; |
---|
107 | // prop: tooltipOffset |
---|
108 | // Pixel offset of tooltip from the highlight. |
---|
109 | this.tooltipOffset = 2; |
---|
110 | // prop: tooltipAxes |
---|
111 | // Which axes to display in tooltip, 'x', 'y' or 'both', 'xy' or 'yx' |
---|
112 | // 'both' and 'xy' are equivalent, 'yx' reverses order of labels. |
---|
113 | this.tooltipAxes = 'both'; |
---|
114 | // prop; tooltipSeparator |
---|
115 | // String to use to separate x and y axes in tooltip. |
---|
116 | this.tooltipSeparator = ', '; |
---|
117 | // prop; tooltipContentEditor |
---|
118 | // Function used to edit/augment/replace the formatted tooltip contents. |
---|
119 | // Called as str = tooltipContentEditor(str, seriesIndex, pointIndex) |
---|
120 | // where str is the generated tooltip html and seriesIndex and pointIndex identify |
---|
121 | // the data point being highlighted. Should return the html for the tooltip contents. |
---|
122 | this.tooltipContentEditor = null; |
---|
123 | // prop: useAxesFormatters |
---|
124 | // Use the x and y axes formatters to format the text in the tooltip. |
---|
125 | this.useAxesFormatters = true; |
---|
126 | // prop: tooltipFormatString |
---|
127 | // sprintf format string for the tooltip. |
---|
128 | // Uses Ash Searle's javascript sprintf implementation |
---|
129 | // found here: http://hexmen.com/blog/2007/03/printf-sprintf/ |
---|
130 | // See http://perldoc.perl.org/functions/sprintf.html for reference. |
---|
131 | // Additional "p" and "P" format specifiers added by Chris Leonello. |
---|
132 | this.tooltipFormatString = '%.5P'; |
---|
133 | // prop: formatString |
---|
134 | // alternative to tooltipFormatString |
---|
135 | // will format the whole tooltip text, populating with x, y values as |
---|
136 | // indicated by tooltipAxes option. So, you could have a tooltip like: |
---|
137 | // 'Date: %s, number of cats: %d' to format the whole tooltip at one go. |
---|
138 | // If useAxesFormatters is true, values will be formatted according to |
---|
139 | // Axes formatters and you can populate your tooltip string with |
---|
140 | // %s placeholders. |
---|
141 | this.formatString = null; |
---|
142 | // prop: yvalues |
---|
143 | // Number of y values to expect in the data point array. |
---|
144 | // Typically this is 1. Certain plots, like OHLC, will |
---|
145 | // have more y values in each data point array. |
---|
146 | this.yvalues = 1; |
---|
147 | // prop: bringSeriesToFront |
---|
148 | // This option requires jQuery 1.4+ |
---|
149 | // True to bring the series of the highlighted point to the front |
---|
150 | // of other series. |
---|
151 | this.bringSeriesToFront = false; |
---|
152 | this._tooltipElem; |
---|
153 | this.isHighlighting = false; |
---|
154 | this.currentNeighbor = null; |
---|
155 | |
---|
156 | $.extend(true, this, options); |
---|
157 | }; |
---|
158 | |
---|
159 | var locations = ['nw', 'n', 'ne', 'e', 'se', 's', 'sw', 'w']; |
---|
160 | var locationIndicies = {'nw':0, 'n':1, 'ne':2, 'e':3, 'se':4, 's':5, 'sw':6, 'w':7}; |
---|
161 | var oppositeLocations = ['se', 's', 'sw', 'w', 'nw', 'n', 'ne', 'e']; |
---|
162 | |
---|
163 | // axis.renderer.tickrenderer.formatter |
---|
164 | |
---|
165 | // called with scope of plot |
---|
166 | $.jqplot.Highlighter.init = function (target, data, opts){ |
---|
167 | var options = opts || {}; |
---|
168 | // add a highlighter attribute to the plot |
---|
169 | this.plugins.highlighter = new $.jqplot.Highlighter(options.highlighter); |
---|
170 | }; |
---|
171 | |
---|
172 | // called within scope of series |
---|
173 | $.jqplot.Highlighter.parseOptions = function (defaults, options) { |
---|
174 | // Add a showHighlight option to the series |
---|
175 | // and set it to true by default. |
---|
176 | this.showHighlight = true; |
---|
177 | }; |
---|
178 | |
---|
179 | // called within context of plot |
---|
180 | // create a canvas which we can draw on. |
---|
181 | // insert it before the eventCanvas, so eventCanvas will still capture events. |
---|
182 | $.jqplot.Highlighter.postPlotDraw = function() { |
---|
183 | // Memory Leaks patch |
---|
184 | if (this.plugins.highlighter && this.plugins.highlighter.highlightCanvas) { |
---|
185 | this.plugins.highlighter.highlightCanvas.resetCanvas(); |
---|
186 | this.plugins.highlighter.highlightCanvas = null; |
---|
187 | } |
---|
188 | |
---|
189 | if (this.plugins.highlighter && this.plugins.highlighter._tooltipElem) { |
---|
190 | this.plugins.highlighter._tooltipElem.emptyForce(); |
---|
191 | this.plugins.highlighter._tooltipElem = null; |
---|
192 | } |
---|
193 | |
---|
194 | this.plugins.highlighter.highlightCanvas = new $.jqplot.GenericCanvas(); |
---|
195 | |
---|
196 | this.eventCanvas._elem.before(this.plugins.highlighter.highlightCanvas.createElement(this._gridPadding, 'jqplot-highlight-canvas', this._plotDimensions, this)); |
---|
197 | this.plugins.highlighter.highlightCanvas.setContext(); |
---|
198 | |
---|
199 | var elem = document.createElement('div'); |
---|
200 | this.plugins.highlighter._tooltipElem = $(elem); |
---|
201 | elem = null; |
---|
202 | this.plugins.highlighter._tooltipElem.addClass('jqplot-highlighter-tooltip'); |
---|
203 | this.plugins.highlighter._tooltipElem.css({position:'absolute', display:'none'}); |
---|
204 | |
---|
205 | this.eventCanvas._elem.before(this.plugins.highlighter._tooltipElem); |
---|
206 | }; |
---|
207 | |
---|
208 | $.jqplot.preInitHooks.push($.jqplot.Highlighter.init); |
---|
209 | $.jqplot.preParseSeriesOptionsHooks.push($.jqplot.Highlighter.parseOptions); |
---|
210 | $.jqplot.postDrawHooks.push($.jqplot.Highlighter.postPlotDraw); |
---|
211 | |
---|
212 | function draw(plot, neighbor) { |
---|
213 | var hl = plot.plugins.highlighter; |
---|
214 | var s = plot.series[neighbor.seriesIndex]; |
---|
215 | var smr = s.markerRenderer; |
---|
216 | var mr = hl.markerRenderer; |
---|
217 | mr.style = smr.style; |
---|
218 | mr.lineWidth = smr.lineWidth + hl.lineWidthAdjust; |
---|
219 | mr.size = smr.size + hl.sizeAdjust; |
---|
220 | var rgba = $.jqplot.getColorComponents(smr.color); |
---|
221 | var newrgb = [rgba[0], rgba[1], rgba[2]]; |
---|
222 | var alpha = (rgba[3] >= 0.6) ? rgba[3]*0.6 : rgba[3]*(2-rgba[3]); |
---|
223 | mr.color = 'rgba('+newrgb[0]+','+newrgb[1]+','+newrgb[2]+','+alpha+')'; |
---|
224 | mr.init(); |
---|
225 | mr.draw(s.gridData[neighbor.pointIndex][0], s.gridData[neighbor.pointIndex][1], hl.highlightCanvas._ctx); |
---|
226 | } |
---|
227 | |
---|
228 | function showTooltip(plot, series, neighbor) { |
---|
229 | // neighbor looks like: {seriesIndex: i, pointIndex:j, gridData:p, data:s.data[j]} |
---|
230 | // gridData should be x,y pixel coords on the grid. |
---|
231 | // add the plot._gridPadding to that to get x,y in the target. |
---|
232 | var hl = plot.plugins.highlighter; |
---|
233 | var elem = hl._tooltipElem; |
---|
234 | var serieshl = series.highlighter || {}; |
---|
235 | |
---|
236 | var opts = $.extend(true, {}, hl, serieshl); |
---|
237 | |
---|
238 | if (opts.useAxesFormatters) { |
---|
239 | var xf = series._xaxis._ticks[0].formatter; |
---|
240 | var yf = series._yaxis._ticks[0].formatter; |
---|
241 | var xfstr = series._xaxis._ticks[0].formatString; |
---|
242 | var yfstr = series._yaxis._ticks[0].formatString; |
---|
243 | var str; |
---|
244 | var xstr = xf(xfstr, neighbor.data[0]); |
---|
245 | var ystrs = []; |
---|
246 | for (var i=1; i<opts.yvalues+1; i++) { |
---|
247 | ystrs.push(yf(yfstr, neighbor.data[i])); |
---|
248 | } |
---|
249 | if (typeof opts.formatString === 'string') { |
---|
250 | switch (opts.tooltipAxes) { |
---|
251 | case 'both': |
---|
252 | case 'xy': |
---|
253 | ystrs.unshift(xstr); |
---|
254 | ystrs.unshift(opts.formatString); |
---|
255 | str = $.jqplot.sprintf.apply($.jqplot.sprintf, ystrs); |
---|
256 | break; |
---|
257 | case 'yx': |
---|
258 | ystrs.push(xstr); |
---|
259 | ystrs.unshift(opts.formatString); |
---|
260 | str = $.jqplot.sprintf.apply($.jqplot.sprintf, ystrs); |
---|
261 | break; |
---|
262 | case 'x': |
---|
263 | str = $.jqplot.sprintf.apply($.jqplot.sprintf, [opts.formatString, xstr]); |
---|
264 | break; |
---|
265 | case 'y': |
---|
266 | ystrs.unshift(opts.formatString); |
---|
267 | str = $.jqplot.sprintf.apply($.jqplot.sprintf, ystrs); |
---|
268 | break; |
---|
269 | default: // same as xy |
---|
270 | ystrs.unshift(xstr); |
---|
271 | ystrs.unshift(opts.formatString); |
---|
272 | str = $.jqplot.sprintf.apply($.jqplot.sprintf, ystrs); |
---|
273 | break; |
---|
274 | } |
---|
275 | } |
---|
276 | else { |
---|
277 | switch (opts.tooltipAxes) { |
---|
278 | case 'both': |
---|
279 | case 'xy': |
---|
280 | str = xstr; |
---|
281 | for (var i=0; i<ystrs.length; i++) { |
---|
282 | str += opts.tooltipSeparator + ystrs[i]; |
---|
283 | } |
---|
284 | break; |
---|
285 | case 'yx': |
---|
286 | str = ''; |
---|
287 | for (var i=0; i<ystrs.length; i++) { |
---|
288 | str += ystrs[i] + opts.tooltipSeparator; |
---|
289 | } |
---|
290 | str += xstr; |
---|
291 | break; |
---|
292 | case 'x': |
---|
293 | str = xstr; |
---|
294 | break; |
---|
295 | case 'y': |
---|
296 | str = ystrs.join(opts.tooltipSeparator); |
---|
297 | break; |
---|
298 | default: // same as 'xy' |
---|
299 | str = xstr; |
---|
300 | for (var i=0; i<ystrs.length; i++) { |
---|
301 | str += opts.tooltipSeparator + ystrs[i]; |
---|
302 | } |
---|
303 | break; |
---|
304 | |
---|
305 | } |
---|
306 | } |
---|
307 | } |
---|
308 | else { |
---|
309 | var str; |
---|
310 | if (typeof opts.formatString === 'string') { |
---|
311 | str = $.jqplot.sprintf.apply($.jqplot.sprintf, [opts.formatString].concat(neighbor.data)); |
---|
312 | } |
---|
313 | |
---|
314 | else { |
---|
315 | if (opts.tooltipAxes == 'both' || opts.tooltipAxes == 'xy') { |
---|
316 | str = $.jqplot.sprintf(opts.tooltipFormatString, neighbor.data[0]) + opts.tooltipSeparator + $.jqplot.sprintf(opts.tooltipFormatString, neighbor.data[1]); |
---|
317 | } |
---|
318 | else if (opts.tooltipAxes == 'yx') { |
---|
319 | str = $.jqplot.sprintf(opts.tooltipFormatString, neighbor.data[1]) + opts.tooltipSeparator + $.jqplot.sprintf(opts.tooltipFormatString, neighbor.data[0]); |
---|
320 | } |
---|
321 | else if (opts.tooltipAxes == 'x') { |
---|
322 | str = $.jqplot.sprintf(opts.tooltipFormatString, neighbor.data[0]); |
---|
323 | } |
---|
324 | else if (opts.tooltipAxes == 'y') { |
---|
325 | str = $.jqplot.sprintf(opts.tooltipFormatString, neighbor.data[1]); |
---|
326 | } |
---|
327 | } |
---|
328 | } |
---|
329 | if ($.isFunction(opts.tooltipContentEditor)) { |
---|
330 | // args str, seriesIndex, pointIndex are essential so the hook can look up |
---|
331 | // extra data for the point. |
---|
332 | str = opts.tooltipContentEditor(str, neighbor.seriesIndex, neighbor.pointIndex, plot); |
---|
333 | } |
---|
334 | elem.html(str); |
---|
335 | var gridpos = {x:neighbor.gridData[0], y:neighbor.gridData[1]}; |
---|
336 | var ms = 0; |
---|
337 | var fact = 0.707; |
---|
338 | if (series.markerRenderer.show == true) { |
---|
339 | ms = (series.markerRenderer.size + opts.sizeAdjust)/2; |
---|
340 | } |
---|
341 | |
---|
342 | var loc = locations; |
---|
343 | if (series.fillToZero && series.fill && neighbor.data[1] < 0) { |
---|
344 | loc = oppositeLocations; |
---|
345 | } |
---|
346 | |
---|
347 | switch (loc[locationIndicies[opts.tooltipLocation]]) { |
---|
348 | case 'nw': |
---|
349 | var x = gridpos.x + plot._gridPadding.left - elem.outerWidth(true) - opts.tooltipOffset - fact * ms; |
---|
350 | var y = gridpos.y + plot._gridPadding.top - opts.tooltipOffset - elem.outerHeight(true) - fact * ms; |
---|
351 | break; |
---|
352 | case 'n': |
---|
353 | var x = gridpos.x + plot._gridPadding.left - elem.outerWidth(true)/2; |
---|
354 | var y = gridpos.y + plot._gridPadding.top - opts.tooltipOffset - elem.outerHeight(true) - ms; |
---|
355 | break; |
---|
356 | case 'ne': |
---|
357 | var x = gridpos.x + plot._gridPadding.left + opts.tooltipOffset + fact * ms; |
---|
358 | var y = gridpos.y + plot._gridPadding.top - opts.tooltipOffset - elem.outerHeight(true) - fact * ms; |
---|
359 | break; |
---|
360 | case 'e': |
---|
361 | var x = gridpos.x + plot._gridPadding.left + opts.tooltipOffset + ms; |
---|
362 | var y = gridpos.y + plot._gridPadding.top - elem.outerHeight(true)/2; |
---|
363 | break; |
---|
364 | case 'se': |
---|
365 | var x = gridpos.x + plot._gridPadding.left + opts.tooltipOffset + fact * ms; |
---|
366 | var y = gridpos.y + plot._gridPadding.top + opts.tooltipOffset + fact * ms; |
---|
367 | break; |
---|
368 | case 's': |
---|
369 | var x = gridpos.x + plot._gridPadding.left - elem.outerWidth(true)/2; |
---|
370 | var y = gridpos.y + plot._gridPadding.top + opts.tooltipOffset + ms; |
---|
371 | break; |
---|
372 | case 'sw': |
---|
373 | var x = gridpos.x + plot._gridPadding.left - elem.outerWidth(true) - opts.tooltipOffset - fact * ms; |
---|
374 | var y = gridpos.y + plot._gridPadding.top + opts.tooltipOffset + fact * ms; |
---|
375 | break; |
---|
376 | case 'w': |
---|
377 | var x = gridpos.x + plot._gridPadding.left - elem.outerWidth(true) - opts.tooltipOffset - ms; |
---|
378 | var y = gridpos.y + plot._gridPadding.top - elem.outerHeight(true)/2; |
---|
379 | break; |
---|
380 | default: // same as 'nw' |
---|
381 | var x = gridpos.x + plot._gridPadding.left - elem.outerWidth(true) - opts.tooltipOffset - fact * ms; |
---|
382 | var y = gridpos.y + plot._gridPadding.top - opts.tooltipOffset - elem.outerHeight(true) - fact * ms; |
---|
383 | break; |
---|
384 | } |
---|
385 | elem.css('left', x); |
---|
386 | elem.css('top', y); |
---|
387 | if (opts.fadeTooltip) { |
---|
388 | // Fix for stacked up animations. Thnanks Trevor! |
---|
389 | elem.stop(true,true).fadeIn(opts.tooltipFadeSpeed); |
---|
390 | } |
---|
391 | else { |
---|
392 | elem.show(); |
---|
393 | } |
---|
394 | elem = null; |
---|
395 | |
---|
396 | } |
---|
397 | |
---|
398 | function handleMove(ev, gridpos, datapos, neighbor, plot) { |
---|
399 | var hl = plot.plugins.highlighter; |
---|
400 | var c = plot.plugins.cursor; |
---|
401 | if (hl.show) { |
---|
402 | if (neighbor == null && hl.isHighlighting) { |
---|
403 | var ctx = hl.highlightCanvas._ctx; |
---|
404 | ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height); |
---|
405 | if (hl.fadeTooltip) { |
---|
406 | hl._tooltipElem.fadeOut(hl.tooltipFadeSpeed); |
---|
407 | } |
---|
408 | else { |
---|
409 | hl._tooltipElem.hide(); |
---|
410 | } |
---|
411 | if (hl.bringSeriesToFront) { |
---|
412 | plot.restorePreviousSeriesOrder(); |
---|
413 | } |
---|
414 | hl.isHighlighting = false; |
---|
415 | hl.currentNeighbor = null; |
---|
416 | ctx = null; |
---|
417 | } |
---|
418 | else if (neighbor != null && plot.series[neighbor.seriesIndex].showHighlight && !hl.isHighlighting) { |
---|
419 | hl.isHighlighting = true; |
---|
420 | hl.currentNeighbor = neighbor; |
---|
421 | if (hl.showMarker) { |
---|
422 | draw(plot, neighbor); |
---|
423 | } |
---|
424 | if (hl.showTooltip && (!c || !c._zoom.started)) { |
---|
425 | showTooltip(plot, plot.series[neighbor.seriesIndex], neighbor); |
---|
426 | } |
---|
427 | if (hl.bringSeriesToFront) { |
---|
428 | plot.moveSeriesToFront(neighbor.seriesIndex); |
---|
429 | } |
---|
430 | } |
---|
431 | // check to see if we're highlighting the wrong point. |
---|
432 | else if (neighbor != null && hl.isHighlighting && hl.currentNeighbor != neighbor) { |
---|
433 | // highlighting the wrong point. |
---|
434 | |
---|
435 | // if new series allows highlighting, highlight new point. |
---|
436 | if (plot.series[neighbor.seriesIndex].showHighlight) { |
---|
437 | var ctx = hl.highlightCanvas._ctx; |
---|
438 | ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height); |
---|
439 | hl.isHighlighting = true; |
---|
440 | hl.currentNeighbor = neighbor; |
---|
441 | if (hl.showMarker) { |
---|
442 | draw(plot, neighbor); |
---|
443 | } |
---|
444 | if (hl.showTooltip && (!c || !c._zoom.started)) { |
---|
445 | showTooltip(plot, plot.series[neighbor.seriesIndex], neighbor); |
---|
446 | } |
---|
447 | if (hl.bringSeriesToFront) { |
---|
448 | plot.moveSeriesToFront(neighbor.seriesIndex); |
---|
449 | } |
---|
450 | } |
---|
451 | } |
---|
452 | } |
---|
453 | } |
---|
454 | })(jQuery); |
---|