From fe8083fcb1aa762b89cea7cad4a436473a3beaf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E5=AD=90=E6=A5=9A=5Czhuzi?= Date: Tue, 9 Jan 2024 00:17:30 +0800 Subject: [PATCH] fix bug #397 and #393 --- src/Qt5/imports/FluentUI/JS/Chart.js | 39 +++++++++++++++++++--------- src/Qt6/imports/FluentUI/JS/Chart.js | 39 +++++++++++++++++++--------- 2 files changed, 54 insertions(+), 24 deletions(-) diff --git a/src/Qt5/imports/FluentUI/JS/Chart.js b/src/Qt5/imports/FluentUI/JS/Chart.js index ca84b6fe..cce4f915 100644 --- a/src/Qt5/imports/FluentUI/JS/Chart.js +++ b/src/Qt5/imports/FluentUI/JS/Chart.js @@ -7277,8 +7277,9 @@ var core_layouts = { } }]; }; - - chart.boxes.push(item); + if(Array.isArray(chart.boxes)){ + chart.boxes.push(item); + } }, /** @@ -7287,9 +7288,13 @@ var core_layouts = { * @param {ILayoutItem} layoutItem - the item to remove from the layout */ removeBox: function(chart, layoutItem) { - var index = chart.boxes ? chart.boxes.indexOf(layoutItem) : -1; - if (index !== -1) { - chart.boxes.splice(index, 1); + if(chart.boxes){ + if(layoutItem){ + if(Array.isArray(chart.boxes)){ + var index = chart.boxes.indexOf(layoutItem) + chart.boxes.splice(index, 1); + } + } } }, @@ -9656,12 +9661,16 @@ helpers$1.extend(Chart.prototype, /** @lends Chart */ { // plugins options references might have change, let's invalidate the cache // https://github.com/chartjs/Chart.js/issues/5111#issuecomment-355934167 - core_plugins._invalidate(me); +// core_plugins._invalidate(me); if (core_plugins.notify(me, 'beforeUpdate') === false) { return; } + if(me.data === undefined){ + return; + } + // In case the entire data object changed me.tooltip._data = me.data; @@ -9885,8 +9894,11 @@ helpers$1.extend(Chart.prototype, /** @lends Chart */ { */ transition: function(easingValue) { var me = this; - - for (var i = 0, ilen = (me.data.datasets || []).length; i < ilen; ++i) { + var datasets = []; + if(me.data){ + datasets = me.data.datasets + } + for (var i = 0, ilen = datasets.length; i < ilen; ++i) { if (me.isDatasetVisible(i)) { me.getDatasetMeta(i).controller.transition(easingValue); } @@ -9900,7 +9912,10 @@ helpers$1.extend(Chart.prototype, /** @lends Chart */ { */ _getSortedDatasetMetas: function(filterVisible) { var me = this; - var datasets = me.data.datasets || []; + var datasets = [] + if(me.data){ + datasets = me.data.datasets; + } var result = []; var i, ilen; @@ -12357,9 +12372,9 @@ var Scale = core_element.extend({ } // MV workaround, as it seems that emptying line dash does not work - if(ctx.getLineDash && ctx.getLineDash().length === 0) { - ctx.setLineDash([9999]); - } +// if(ctx.getLineDash && ctx.getLineDash().length === 0) { +// ctx.setLineDash([9999]); +// } ctx.beginPath(); diff --git a/src/Qt6/imports/FluentUI/JS/Chart.js b/src/Qt6/imports/FluentUI/JS/Chart.js index ca84b6fe..cce4f915 100644 --- a/src/Qt6/imports/FluentUI/JS/Chart.js +++ b/src/Qt6/imports/FluentUI/JS/Chart.js @@ -7277,8 +7277,9 @@ var core_layouts = { } }]; }; - - chart.boxes.push(item); + if(Array.isArray(chart.boxes)){ + chart.boxes.push(item); + } }, /** @@ -7287,9 +7288,13 @@ var core_layouts = { * @param {ILayoutItem} layoutItem - the item to remove from the layout */ removeBox: function(chart, layoutItem) { - var index = chart.boxes ? chart.boxes.indexOf(layoutItem) : -1; - if (index !== -1) { - chart.boxes.splice(index, 1); + if(chart.boxes){ + if(layoutItem){ + if(Array.isArray(chart.boxes)){ + var index = chart.boxes.indexOf(layoutItem) + chart.boxes.splice(index, 1); + } + } } }, @@ -9656,12 +9661,16 @@ helpers$1.extend(Chart.prototype, /** @lends Chart */ { // plugins options references might have change, let's invalidate the cache // https://github.com/chartjs/Chart.js/issues/5111#issuecomment-355934167 - core_plugins._invalidate(me); +// core_plugins._invalidate(me); if (core_plugins.notify(me, 'beforeUpdate') === false) { return; } + if(me.data === undefined){ + return; + } + // In case the entire data object changed me.tooltip._data = me.data; @@ -9885,8 +9894,11 @@ helpers$1.extend(Chart.prototype, /** @lends Chart */ { */ transition: function(easingValue) { var me = this; - - for (var i = 0, ilen = (me.data.datasets || []).length; i < ilen; ++i) { + var datasets = []; + if(me.data){ + datasets = me.data.datasets + } + for (var i = 0, ilen = datasets.length; i < ilen; ++i) { if (me.isDatasetVisible(i)) { me.getDatasetMeta(i).controller.transition(easingValue); } @@ -9900,7 +9912,10 @@ helpers$1.extend(Chart.prototype, /** @lends Chart */ { */ _getSortedDatasetMetas: function(filterVisible) { var me = this; - var datasets = me.data.datasets || []; + var datasets = [] + if(me.data){ + datasets = me.data.datasets; + } var result = []; var i, ilen; @@ -12357,9 +12372,9 @@ var Scale = core_element.extend({ } // MV workaround, as it seems that emptying line dash does not work - if(ctx.getLineDash && ctx.getLineDash().length === 0) { - ctx.setLineDash([9999]); - } +// if(ctx.getLineDash && ctx.getLineDash().length === 0) { +// ctx.setLineDash([9999]); +// } ctx.beginPath();