Highcharts Scrollbar向上箭头在点击时抛出错误

问题描述 投票:0回答:1

单击yAxis上带有滚动条的高图xrange图上的向上箭头(xAxis上也有一个但是当我使用它的箭头按钮时它不会抛出错误)返回的错误是

Uncaught TypeError: Cannot read property 'call' of undefined
at SVGGElement.<anonymous> (highcharts.src.js:5182)

到目前为止,我还没有在互联网上找到任何有关此错误的具体信息,但如果我这样做,我将更新此票

这可能与X和Y滚动条有关吗?我根本没有计划使用按钮,因为我们已经为触控板/滚轮实现了一个监听器 - 是否有一种方法可以完全移除箭头按钮(而不是让它透明,我目前已经实现了包括一个难看的悬停我无法摆脱)

如果你可以帮助我A)完全删除/隐藏按钮B)听取点击并扔掉事件以避免此错误或C)修复此错误的根本原因是...我非常感谢它

{
    'chart': {
      'renderTo': graphId,
      'type': 'xrange',
      'zoomType': 'xy',
      'panning': true,
      'panKey': 'shift',
      'marginRight': 40,
      'marginLeft': 150,
      'resetZoomButton': {
        'position': {
          'x': -150,
          'y': -10
        }
      }
    },
    'exporting': {
      'enabled': true,
      'buttons': {
        'enabled': true,
        'contextButton': {
          'enabled': false
        },
        'resetScopeButton': {
          'y': -10,
          'x': -25,
          'symbolX': 20,
          'symbolY': 20,
          'enabled': true,
          'onclick': context['LiAnalytics']['resetScopeButton'],
          'symbol': 'url(../images/refresh.png)'
        },
        'hourButton': {
          'enabled': true,
          'text': 'H',
          'y': -10,
          'x': -50,
          'onclick': context['LiAnalytics']['hourButton']
        },
        'dayButton': {
          'text': 'D',
          'y': -10,
          'x': -75,
          'enabled': endTS - startTS > 86400000,
          'onclick': context['LiAnalytics']['dayButton']
        },
        'weekButton': {
          'text': 'W',
          'y': -10,
          'x': -100,
          'enabled': endTS - startTS >= 604800000,
          'onclick': context['LiAnalytics']['weekButton']
        },
        'monthButton': {
          'text': 'M',
          'y': -10,
          'x': -125,
          'enabled': endTS - startTS >= 2419000000,
          'onclick': context['LiAnalytics']['monthButton']
        }
      }
    },
    'legend': {
      'enabled': false
    },
    'xAxis': {
      'type': 'datetime',
      'dateTimeLabelFormats': {
        ...
      },
      'events': {
        'setExtremes': new js.JsFunction.withThis(_handleRedraw)
      },
      'min': (endTS - startTS) > initialZoom ? endTS - initialZoom : startTS,
      'max': endTS,
      'scrollbar': {
        'enabled': true,
        'showFull': false,
        'barBackgroundColor': '#ccc',
        'barBorderRadius': 7,
        'barBorderWidth': 0,
        'buttonBorderWidth': 0,
        'buttonArrowColor': 'transparent',
        'buttonBackgroundColor': 'transparent',
        'rifleColor': 'transparent',
        'trackBackgroundColor': '#F3F3F3',
        'trackBorderColor': 'transparent',
        'height': 10,
        'minWidth': 25
      }
    },
    'yAxis': {
      'categories': agents,
      'min': 0,
      'max': agents.length < maxY ? agents.length - 1 : maxY,
      'scrollbar': { /* Why you throw err on click ? */
        'enabled': true,
        'showFull': false,
        'barBackgroundColor': '#ccc',
        'barBorderRadius': 7,
        'barBorderWidth': 0,
        'buttonBorderWidth': 0,
        'buttonArrowColor': 'transparent', /* Remove entirely ? */
        'buttonBackgroundColor': 'transparent',
        'rifleColor': 'transparent',
        'trackBackgroundColor': '#F3F3F3',
        'trackBorderColor': 'transparent',
        'height': 10,
        'minWidth': 25
      },
      'reversed': true,
      'tickmarkPlacement': 'on',
      'gridLineColor': 'transparent'
    },
    'plotOptions': {
      'series': {
        'animation': {
          'duration': 2000
        },
        'point': {
          'events': { /* can i do something similar for scrollbar? */
            'mouseOver': new js.JsFunction.withThis(_mouseOver),
            'mouseOut': new js.JsFunction.withThis(_mouseOut)
          }
        },
        'pointWidth': 20,
        'pointPlacement': 0,
        'minPointLength': 10,
        'borderRadius': 0
      }
    },
    'series': series,
    'tooltip': {
      ...
    }
  }

(C)当前代码块

(function() {
    //internal functions
    function stopEvent(e) {
        if (e) {
            if (e.preventDefault) {
                e.preventDefault();
            }
            if (e.stopPropagation) {
                e.stopPropagation();
            }
            e.cancelBubble = true;
        }
    }
    /* Wrap allows us to override the behavior of render while not interrupting the normal rendering procedure */
    Highcharts.wrap(Highcharts.Chart.prototype, 'render', function(proceed) {
        var chart = this;

        proceed.call(chart);
        /* When a chart has a scrollbar and is xrange our PM/UX has requested the touchpad be abled to control the scrollbar */
        if (chart.options['chart']['type'] === "xrange" && chart.options['yAxis'][0]['scrollbar']['enabled']) {
            // Add the mousewheel event
            Highcharts.addEvent(chart.container, document.onmousewheel === undefined ? 'DOMMouseScroll' : 'mousewheel', function (event) {

                var delta, diff, extr, newMax, newMin, step, axis = chart.yAxis[0];
                e = chart.pointer.normalize(event);
                // Firefox uses e.detail, WebKit and IE uses wheelDelta
                delta = e.detail || -(e.wheelDelta / 120);
                delta = delta < 0 ? 1 : -1;
                /* Up or Down */
                if (chart.isInsidePlot(e.chartX - chart.plotLeft, e.chartY - chart.plotTop)) {
                    extr = axis.getExtremes();
                    if (extr.dataMax !== extr.dataMin) {
                        diff = extr.max - extr.min;
                        step = diff / 5;
                        /* move by fifths */
                        step = step > 1 ? Math.ceil(step) : 1;
                        /* Min step is 1, Move by whole numbers */
                        step = step * delta;
                        /* Up/Down */
                        if (step > 0) {
                            /* UP */
                            if (extr.max + step > extr.dataMax) {
                                newMax = extr.dataMax;
                                newMin = extr.dataMax - diff;
                                /* Enforce window not getting too small */
                            } else {
                                newMin = extr.min + step;
                                newMax = extr.max + step;
                            }
                        } else {
                            /* DOWN */
                            if (extr.min + step < 0) {
                                newMin = 0;
                                newMax = diff;
                            } else {
                                newMin = extr.min + step;
                                newMax = extr.max + step;
                            }
                        }
                        axis.setExtremes(newMin, newMax, true, false);
                    }
                }
                stopEvent(event);
                return false;
            });
        }
    });

    Highcharts.Scrollbar.prototype.addEvents = function() {
        var chart = this;

        var buttonsOrder = chart.options.inverted ? [1, 0] : [0, 1],
            buttons = chart.scrollbarButtons,
            bar = chart.scrollbarGroup.element,
            track = chart.track.element,
            mouseDownHandler = chart.mouseDownHandler,
            mouseMoveHandler = chart.mouseMoveHandler,
            mouseUpHandler = chart.mouseUpHandler,
            _events;

        // Mouse events
        _events = [
            /*    [buttons[buttonsOrder[0]].element, 'click', this.buttonToMinClick],
                  [buttons[buttonsOrder[1]].element, 'click', this.buttonToMaxClick], */
            [track, 'click', this.trackClick],
            [bar, 'mousedown', mouseDownHandler],
            [bar.ownerDocument, 'mousemove', mouseMoveHandler],
            [bar.ownerDocument, 'mouseup', mouseUpHandler]
        ];

        // Touch events
        if (Highcharts.hasTouch) {
            _events.push(
                [bar, 'touchstart', mouseDownHandler], [bar.ownerDocument, 'touchmove', mouseMoveHandler], [bar.ownerDocument, 'touchend', mouseUpHandler]
            );
        }

        // Add them all
        _events.forEach(function(args) {
            Highcharts.addEvent.apply(null, args);
        });
        chart._events = _events;
    };
}());

编辑:删除旧的细节

svg highcharts scrollbar
1个回答
0
投票

这是因为在包含其他自定义按钮的同时尝试单独禁用上下文按钮。上下文按钮作为幻像按钮悬挂在滚动条向上箭头上,导致调试期间的误诊。

解决方案我最终通过覆盖符号/符号X symoblY(按钮区域中的中心符号)/ onclick行为重新调整上下文按钮

路由onclick到resetScope行为我正努力覆盖汉堡符号与png保存/由UX决定

© www.soinside.com 2019 - 2024. All rights reserved.