@progress/kendo-charts 2.6.0-dev.202410171740 → 2.6.0-dev.202410180430

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -23,7 +23,7 @@ import { X, Y, VALUE, DEFAULT_WIDTH, DEFAULT_HEIGHT, DEFAULT_SERIES_OPACITY,
23
23
  ENTER, ESCAPE } from '../common/constants';
24
24
  import { addClass, Class, setDefaultOptions, deepExtend, defined, find, isObject, isFunction, elementSize, elementOffset,
25
25
  elementScale, elementStyles, eventCoordinates, bindEvents, unbindEvents, mousewheelDelta, FontLoader, inArray, round,
26
- valueOrDefault, isString, cycleUp, cycleDown, hasOwnProperty } from '../common';
26
+ valueOrDefault, isString, cycleUp, cycleDown, hasOwnProperty, hasClasses } from '../common';
27
27
 
28
28
  import { DRAG_START, DRAG, DRAG_END, ZOOM_START, ZOOM, ZOOM_END, SELECT_START, SELECT, SELECT_END, PLOT_AREA_HOVER, PLOT_AREA_LEAVE,
29
29
  RENDER, CATEGORY, PIE, DONUT, FUNNEL, PYRAMID, COLUMN, MOUSEWHEEL, MOUSEWHEEL_DELAY, MOUSEWHEEL_ZOOM_RATE, SHOW_TOOLTIP, SERIES_HOVER,
@@ -74,6 +74,7 @@ var Chart = (function (Class) {
74
74
  this$1.trigger('init');
75
75
  this$1._redraw();
76
76
  this$1._attachEvents();
77
+ this$1._restoreOverlayElement();
77
78
  }
78
79
  });
79
80
  }
@@ -83,14 +84,27 @@ var Chart = (function (Class) {
83
84
  Chart.prototype.constructor = Chart;
84
85
 
85
86
  Chart.prototype._initElement = function _initElement (element) {
87
+ var this$1 = this;
88
+
86
89
  this._setElementClass(element);
87
90
  element.style.position = "relative";
88
91
  element.tabIndex = element.getAttribute("tabindex") ? element.getAttribute("tabindex") : 0;
89
92
  // To support user agents and assistive technologies based on the ARIA 1.0 specification, authors may wish to include the document role as a fallback value, in the form role="graphics-document document".
90
93
  element.setAttribute("role", "graphics-document document");
91
- while (element.firstChild) {
92
- element.removeChild(element.firstChild);
94
+
95
+ for (var i = element.childNodes.length - 1; i >= 0; i--) {
96
+ var child = element.childNodes[i];
97
+
98
+ if (!hasClasses(child, "k-chart-overlay")) {
99
+ element.removeChild(child);
100
+ } else {
101
+ // this is necessary if the overlay is rendered server-side, e.g. in blazor
102
+ // but drawing the surface clears the contents of the element
103
+ // and thus the no data overlay is lost
104
+ this$1.overlayElement = child;
105
+ }
93
106
  }
107
+
94
108
  this.element = element;
95
109
  };
96
110
 
@@ -98,6 +112,28 @@ var Chart = (function (Class) {
98
112
  addClass(element, "k-chart");
99
113
  };
100
114
 
115
+ Chart.prototype._restoreOverlayElement = function _restoreOverlayElement () {
116
+ if (!this.overlayElement) {
117
+ return;
118
+ }
119
+
120
+ if (this._hasSeriesData()) {
121
+ this.overlayElement.style.display = "none";
122
+ } else {
123
+ this.overlayElement.style.display = "";
124
+ }
125
+
126
+ if (this.overlayElement.parentElement !== this.element) {
127
+ this.element.appendChild(this.overlayElement);
128
+ }
129
+ };
130
+
131
+ Chart.prototype._hasSeriesData = function _hasSeriesData () {
132
+ var series = this.options.series || [];
133
+ var result = series.length > 0 && series.every(function (x) { return x.data && x.data.length > 0; });
134
+ return result;
135
+ };
136
+
101
137
  Chart.prototype._initTheme = function _initTheme (options, themeOptions) {
102
138
  var seriesCopies = [];
103
139
  var series = options.series || [];
@@ -2023,6 +2059,7 @@ var Chart = (function (Class) {
2023
2059
  this.bindCategories();
2024
2060
  this.redraw();
2025
2061
  this.updateMouseMoveHandler();
2062
+ this._restoreOverlayElement();
2026
2063
  };
2027
2064
 
2028
2065
  Chart.prototype.setDirection = function setDirection (rtl) {
@@ -23,7 +23,7 @@ import { X, Y, VALUE, DEFAULT_WIDTH, DEFAULT_HEIGHT, DEFAULT_SERIES_OPACITY,
23
23
  ENTER, ESCAPE } from '../common/constants';
24
24
  import { addClass, Class, setDefaultOptions, deepExtend, defined, find, isObject, isFunction, elementSize, elementOffset,
25
25
  elementScale, elementStyles, eventCoordinates, bindEvents, unbindEvents, mousewheelDelta, FontLoader, inArray, round,
26
- valueOrDefault, isString, cycleUp, cycleDown, hasOwnProperty } from '../common';
26
+ valueOrDefault, isString, cycleUp, cycleDown, hasOwnProperty, hasClasses } from '../common';
27
27
 
28
28
  import { DRAG_START, DRAG, DRAG_END, ZOOM_START, ZOOM, ZOOM_END, SELECT_START, SELECT, SELECT_END, PLOT_AREA_HOVER, PLOT_AREA_LEAVE,
29
29
  RENDER, CATEGORY, PIE, DONUT, FUNNEL, PYRAMID, COLUMN, MOUSEWHEEL, MOUSEWHEEL_DELAY, MOUSEWHEEL_ZOOM_RATE, SHOW_TOOLTIP, SERIES_HOVER,
@@ -71,6 +71,7 @@ class Chart extends Class {
71
71
  this.trigger('init');
72
72
  this._redraw();
73
73
  this._attachEvents();
74
+ this._restoreOverlayElement();
74
75
  }
75
76
  });
76
77
  }
@@ -81,9 +82,20 @@ class Chart extends Class {
81
82
  element.tabIndex = element.getAttribute("tabindex") ? element.getAttribute("tabindex") : 0;
82
83
  // To support user agents and assistive technologies based on the ARIA 1.0 specification, authors may wish to include the document role as a fallback value, in the form role="graphics-document document".
83
84
  element.setAttribute("role", "graphics-document document");
84
- while (element.firstChild) {
85
- element.removeChild(element.firstChild);
85
+
86
+ for (let i = element.childNodes.length - 1; i >= 0; i--) {
87
+ const child = element.childNodes[i];
88
+
89
+ if (!hasClasses(child, "k-chart-overlay")) {
90
+ element.removeChild(child);
91
+ } else {
92
+ // this is necessary if the overlay is rendered server-side, e.g. in blazor
93
+ // but drawing the surface clears the contents of the element
94
+ // and thus the no data overlay is lost
95
+ this.overlayElement = child;
96
+ }
86
97
  }
98
+
87
99
  this.element = element;
88
100
  }
89
101
 
@@ -91,6 +103,28 @@ class Chart extends Class {
91
103
  addClass(element, "k-chart");
92
104
  }
93
105
 
106
+ _restoreOverlayElement() {
107
+ if (!this.overlayElement) {
108
+ return;
109
+ }
110
+
111
+ if (this._hasSeriesData()) {
112
+ this.overlayElement.style.display = "none";
113
+ } else {
114
+ this.overlayElement.style.display = "";
115
+ }
116
+
117
+ if (this.overlayElement.parentElement !== this.element) {
118
+ this.element.appendChild(this.overlayElement);
119
+ }
120
+ }
121
+
122
+ _hasSeriesData() {
123
+ const series = this.options.series || [];
124
+ const result = series.length > 0 && series.every(x => x.data && x.data.length > 0);
125
+ return result;
126
+ }
127
+
94
128
  _initTheme(options, themeOptions) {
95
129
  const seriesCopies = [];
96
130
  const series = options.series || [];
@@ -1958,6 +1992,7 @@ class Chart extends Class {
1958
1992
  this.bindCategories();
1959
1993
  this.redraw();
1960
1994
  this.updateMouseMoveHandler();
1995
+ this._restoreOverlayElement();
1961
1996
  }
1962
1997
 
1963
1998
  setDirection(rtl) {