Issue #891 new

Cursor Plugin Takes Over jqplotDataClick

Anonymous created an issue

I have 3 charts on one page. A vertical bar chart, a horizontal bar chart and a line graph. I have cursor: {show: false} on both bar charts, but show : true on the line graph. The charts are grabbing live data from AJAX calls to a SQL server. When they redraw, which i do by with a plot.destroy(). the cursor plugin adds a click handler to every chart. Which in and of itself isn't so bad except that it has: ev.preventDefault(); ev.stopImmediatePropagation(); as its first 2 lines of codes preventing the other click handlers from working. The reason i noticed it was because during development i started with the bar charts with jqplotDataClick events and all went as planned, then when i added the 3rd chart, the clicks only worked until the data refreshed.

Comments (4)

  1. don_dowdle

    seems to be the fix:
    this.eventListenerHooks.addOnce('jqplotMouseEnter', handleMouseEnter); this.eventListenerHooks.addOnce('jqplotMouseLeave', handleMouseLeave); this.eventListenerHooks.addOnce('jqplotMouseMove', handleMouseMove); / $.jqplot.eventListenerHooks.push(['jqplotMouseEnter', handleMouseEnter]); $.jqplot.eventListenerHooks.push(['jqplotMouseLeave', handleMouseLeave]); $.jqplot.eventListenerHooks.push(['jqplotMouseMove', handleMouseMove]); / if (c.showCursorLegend) {
    opts.legend = opts.legend || {}; opts.legend.renderer = $.jqplot.CursorLegendRenderer; opts.legend.formatString = this.plugins.cursor.cursorLegendFormatString; opts.legend.show = true; }

            if (c.zoom) {
                this.eventListenerHooks.addOnce('jqplotMouseDown', handleMouseDown);
                //$.jqplot.eventListenerHooks.push(['jqplotMouseDown', handleMouseDown]);
    
                if (c.clickReset) {
                    this.eventListenerHooks.addOnce('jqplotClick', handleClick);
                    //$.jqplot.eventListenerHooks.push(['jqplotClick', handleClick]);
                }
    
                if (c.dblClickReset) {
                    this.eventListenerHooks.addOnce('jqplotDblClick', handleDblClick);
                    //$.jqplot.eventListenerHooks.push(['jqplotDblClick', handleDblClick]);
                }             
            }
    
  2. Sandor Fulop

    I had a strange problem with a line graph until I found this Issue. I have a line graph and the cursor: {show: true, zoom: true}. After I redraw the chart and click on it, I cannot focus anything on the page (e.g. input, select) with mouse click. I think that was caused by return false; in the handleMouseDown function in the following line:

    document.onmousedown = function () { return false; };
    

    The fix posted above (link to pull request) is a solution for my problem too.

  3. Fluffy Fel

    I'm having the exact same issue. I've patched my local copy of jqplot.cursor.js to use this.eventListenerHooks.addOnce instead of $.jqplot.eventListenerHooks.push and it's fixed my issues.

    I don't really know enough about the internals of jqplot to understand what kind of side effects this may cause.

  4. Log in to comment