Dojox Charing - MouseIndicator вешает страницу на пользовательском графике - PullRequest
0 голосов
/ 15 января 2020

Когда пользователь перетаскивает индикатор мыши с левой стороны диаграммы (на метки оси Y), страница зависает, и циклы ЦП на компьютере обычно заканчиваются сбоем вкладки веб-страницы.

ПРИМЕЧАНИЕ. Я предполагал, что это было чем-то, что я делал в своей функции mouseIndicatorChange, но даже когда я удалил этот вызов, он все равно сходит с ума, когда мышь перемещается с левой стороны диаграммы на метки оси Y.

Пример кода: require ([// Требуется ресурс на основе 2D-диаграммы: "dojox / charting / Chart",

            // Require Digit resources:
            "dijit/Tooltip",

            // Legend.
            "dojox/charting/widget/Legend",

            // Charting plugins:
            "dojox/charting/plot2d/Lines",
            "dojox/charting/axis2d/Default",
            "dojox/charting/plot2d/Markers",
            "dojox/charting/plot2d/Grid",
            "dojox/charting/plot2d/Indicator",

            // Action plugins:
            "dojox/charting/action2d/MouseIndicator",

            // Dojo:
            "dojo/on",

            "dojox/xml/parser",

            // Wait until the DOM is ready.
            "dojo/domReady!"
        ], function(Chart, Tooltip, Legend, Lines, Default, Markers, Grid, Indicator, MouseIndicator, on, parser, ready) {

            // Create the chart within it's new "holding" node.
            var chartObj = new Chart('myChart');

            // Add grid lines.
            chartObj.addPlot("Grid", {
                type: Grid,
                vMinorLines: false,
                enableCache: true
            });

            // Add the only/default plot.
            chartObj.addPlot("default", {
                type: Lines,
                markers: true
            });

            // Add x axis.
            chartObj.addAxis("x", {
                titleOrientation: 'away', // Flip so its right side up.
                fixLower:  "micro",
                fixUpper:  "micro",
                title:     "",
                titleGap:  16,
                titleFont: "normal normal normal 8pt Arial",
                majorTickStep: 3,
                minorTickStep: 1
            });

            // Add series here (built dynamically).

            // Add y axis.
            chartObj.addAxis("y", {
                vertical:  true,
                fixLower:  "major",
                fixUpper:  "major",
                title:     "File Count",
                titleGap:  6,
                titleFont: "normal normal normal 8pt Arial",
                min:       0
            });

            // Create the Mouse Indicator object.
            var mseIndX = new MouseIndicator(chartObj, "default", {
                // Set the series to use as the first series in the table results "Feed~Type".
                series: "Series1",
                labels: false,
                lines: false,
                fill: '#FFFFFF' //,
            });

            // Create a fuction to call when mouse changes (mousedown/mousemove/mouseup/change).
            var mouseIndicatorChange = (function(SourceEvent) {
                // Manage a tooltip and other interaction on the page.
            });

            // On Mouse Up of the MouseIndicator object.
            on(mseIndX, "MouseUp", function(evt) {
                // Add the current timestamp to the event.
                evt.startTS = new Date();

                // Pass the new event to the mouseIndicatorChange function.
                mouseIndicatorChange(evt);
            });

            // On Mouse Down of the MouseIndicator object.
            on(mseIndX, "MouseDown", function(evt) {
                // Add the current timestamp to the event.
                evt.startTS = new Date();

                // Pass the new event to the mouseIndicatorChange function.
                mouseIndicatorChange(evt);
            });

            // On Mouse Move of the MouseIndicator object.
            on(mseIndX, "MouseMove", function(evt) {
                // Add the current timestamp to the event.
                evt.startTS = new Date();

                // Pass the new event to the mouseIndicatorChange function.
                mouseIndicatorChange(evt);
            });

            // On change of the MouseIndicator object (triggered AFTER MouseDown/MouseMove/MouseUp events).
            on(mseIndX, "Change", function(evt) {
                // Add the current timestamp to the event.
                evt.startTS = new Date();

                // Store the mouse position for later use.
                $(chartObj.node).findClassedObject('chart-container').data('mouseChngEvt', evt);
            });

});

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...