This commit is contained in:
朱子楚\zhuzi 2024-01-09 00:17:30 +08:00
parent 7546547364
commit fe8083fcb1
2 changed files with 54 additions and 24 deletions

View File

@ -7277,8 +7277,9 @@ var core_layouts = {
} }
}]; }];
}; };
if(Array.isArray(chart.boxes)){
chart.boxes.push(item); chart.boxes.push(item);
}
}, },
/** /**
@ -7287,9 +7288,13 @@ var core_layouts = {
* @param {ILayoutItem} layoutItem - the item to remove from the layout * @param {ILayoutItem} layoutItem - the item to remove from the layout
*/ */
removeBox: function(chart, layoutItem) { removeBox: function(chart, layoutItem) {
var index = chart.boxes ? chart.boxes.indexOf(layoutItem) : -1; if(chart.boxes){
if (index !== -1) { if(layoutItem){
chart.boxes.splice(index, 1); 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 // plugins options references might have change, let's invalidate the cache
// https://github.com/chartjs/Chart.js/issues/5111#issuecomment-355934167 // 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) { if (core_plugins.notify(me, 'beforeUpdate') === false) {
return; return;
} }
if(me.data === undefined){
return;
}
// In case the entire data object changed // In case the entire data object changed
me.tooltip._data = me.data; me.tooltip._data = me.data;
@ -9885,8 +9894,11 @@ helpers$1.extend(Chart.prototype, /** @lends Chart */ {
*/ */
transition: function(easingValue) { transition: function(easingValue) {
var me = this; var me = this;
var datasets = [];
for (var i = 0, ilen = (me.data.datasets || []).length; i < ilen; ++i) { if(me.data){
datasets = me.data.datasets
}
for (var i = 0, ilen = datasets.length; i < ilen; ++i) {
if (me.isDatasetVisible(i)) { if (me.isDatasetVisible(i)) {
me.getDatasetMeta(i).controller.transition(easingValue); me.getDatasetMeta(i).controller.transition(easingValue);
} }
@ -9900,7 +9912,10 @@ helpers$1.extend(Chart.prototype, /** @lends Chart */ {
*/ */
_getSortedDatasetMetas: function(filterVisible) { _getSortedDatasetMetas: function(filterVisible) {
var me = this; var me = this;
var datasets = me.data.datasets || []; var datasets = []
if(me.data){
datasets = me.data.datasets;
}
var result = []; var result = [];
var i, ilen; var i, ilen;
@ -12357,9 +12372,9 @@ var Scale = core_element.extend({
} }
// MV workaround, as it seems that emptying line dash does not work // MV workaround, as it seems that emptying line dash does not work
if(ctx.getLineDash && ctx.getLineDash().length === 0) { // if(ctx.getLineDash && ctx.getLineDash().length === 0) {
ctx.setLineDash([9999]); // ctx.setLineDash([9999]);
} // }
ctx.beginPath(); ctx.beginPath();

View File

@ -7277,8 +7277,9 @@ var core_layouts = {
} }
}]; }];
}; };
if(Array.isArray(chart.boxes)){
chart.boxes.push(item); chart.boxes.push(item);
}
}, },
/** /**
@ -7287,9 +7288,13 @@ var core_layouts = {
* @param {ILayoutItem} layoutItem - the item to remove from the layout * @param {ILayoutItem} layoutItem - the item to remove from the layout
*/ */
removeBox: function(chart, layoutItem) { removeBox: function(chart, layoutItem) {
var index = chart.boxes ? chart.boxes.indexOf(layoutItem) : -1; if(chart.boxes){
if (index !== -1) { if(layoutItem){
chart.boxes.splice(index, 1); 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 // plugins options references might have change, let's invalidate the cache
// https://github.com/chartjs/Chart.js/issues/5111#issuecomment-355934167 // 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) { if (core_plugins.notify(me, 'beforeUpdate') === false) {
return; return;
} }
if(me.data === undefined){
return;
}
// In case the entire data object changed // In case the entire data object changed
me.tooltip._data = me.data; me.tooltip._data = me.data;
@ -9885,8 +9894,11 @@ helpers$1.extend(Chart.prototype, /** @lends Chart */ {
*/ */
transition: function(easingValue) { transition: function(easingValue) {
var me = this; var me = this;
var datasets = [];
for (var i = 0, ilen = (me.data.datasets || []).length; i < ilen; ++i) { if(me.data){
datasets = me.data.datasets
}
for (var i = 0, ilen = datasets.length; i < ilen; ++i) {
if (me.isDatasetVisible(i)) { if (me.isDatasetVisible(i)) {
me.getDatasetMeta(i).controller.transition(easingValue); me.getDatasetMeta(i).controller.transition(easingValue);
} }
@ -9900,7 +9912,10 @@ helpers$1.extend(Chart.prototype, /** @lends Chart */ {
*/ */
_getSortedDatasetMetas: function(filterVisible) { _getSortedDatasetMetas: function(filterVisible) {
var me = this; var me = this;
var datasets = me.data.datasets || []; var datasets = []
if(me.data){
datasets = me.data.datasets;
}
var result = []; var result = [];
var i, ilen; var i, ilen;
@ -12357,9 +12372,9 @@ var Scale = core_element.extend({
} }
// MV workaround, as it seems that emptying line dash does not work // MV workaround, as it seems that emptying line dash does not work
if(ctx.getLineDash && ctx.getLineDash().length === 0) { // if(ctx.getLineDash && ctx.getLineDash().length === 0) {
ctx.setLineDash([9999]); // ctx.setLineDash([9999]);
} // }
ctx.beginPath(); ctx.beginPath();