@progress/kendo-charts 2.3.0-dev.202403082114 → 2.3.0-dev.202403201419

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.
@@ -81,6 +81,7 @@ export var Sankey = (function (Observable) {
81
81
  mouseenter: this._mouseenter.bind(this),
82
82
  mouseleave: this._mouseleave.bind(this),
83
83
  mousemove: this._mousemove.bind(this),
84
+ click: this._click.bind(this)
84
85
  });
85
86
  };
86
87
 
@@ -105,6 +106,7 @@ export var Sankey = (function (Observable) {
105
106
  Sankey.prototype.trigger = function trigger (name, ev) {
106
107
  var event = Object.assign({}, ev,
107
108
  {type: name,
109
+ targetType: ev.element.type,
108
110
  dataItem: ev.element.dataItem});
109
111
 
110
112
  return Observable.prototype.trigger.call(this, name, event);
@@ -146,7 +148,12 @@ export var Sankey = (function (Observable) {
146
148
  }
147
149
 
148
150
  if (isLink || isNode) {
149
- this.trigger('hideTooltip', ev);
151
+ if (this.tooltipTimeOut) {
152
+ clearTimeout(this.tooltipTimeOut);
153
+ this.tooltipTimeOut = null;
154
+ }
155
+ this.tooltipShown = false;
156
+ this.trigger('tooltipHide', ev);
150
157
  }
151
158
 
152
159
  if ((isLink && this.trigger('linkLeave', ev)) ||
@@ -160,12 +167,68 @@ export var Sankey = (function (Observable) {
160
167
  };
161
168
 
162
169
  Sankey.prototype._mousemove = function _mousemove (ev) {
170
+ var this$1 = this;
171
+
172
+ var element = ev.element;
173
+
174
+ var tooltipElType = element.type;
175
+ if (tooltipElType !== LINK && tooltipElType !== NODE) {
176
+ return;
177
+ }
178
+
179
+ ev.tooltipTargetType = tooltipElType;
180
+ var mouseEvent = ev.originalEvent;
181
+ var rect = this.element.getBoundingClientRect();
182
+ var isLeft = mouseEvent.clientX - rect.left < rect.width / 2;
183
+ var ref = this.options.tooltips;
184
+ var offset = ref.offset;
185
+ var followPointer = ref.followPointer;
186
+ var delay = ref.delay;
187
+
188
+ if (this.tooltipShown && !followPointer) {
189
+ return;
190
+ }
191
+
192
+ ev.tooltipData = {
193
+ popupOffset: {
194
+ left: mouseEvent.pageX + (isLeft ? offset : (-1 * offset)),
195
+ top: mouseEvent.pageY
196
+ },
197
+ popupAlign: {
198
+ horizontal: isLeft ? 'left' : 'right',
199
+ vertical: 'center'
200
+ }
201
+ };
202
+
203
+ if (tooltipElType === NODE) {
204
+ var ref$1 = element.dataItem;
205
+ var sourceLinks = ref$1.sourceLinks;
206
+ var targetLinks = ref$1.targetLinks;
207
+ var links = targetLinks.length ? targetLinks : sourceLinks;
208
+ ev.nodeValue = links.reduce(function (acc, link) { return acc + link.value; }, 0);
209
+ }
210
+
211
+ if (this.tooltipTimeOut) {
212
+ clearTimeout(this.tooltipTimeOut);
213
+ this.tooltipTimeOut = null;
214
+ }
215
+
216
+ this.tooltipTimeOut = setTimeout(function () {
217
+ this$1.trigger('tooltipShow', ev);
218
+ this$1.tooltipShown = true;
219
+ this$1.tooltipTimeOut = null;
220
+ }, delay);
221
+ };
222
+
223
+ Sankey.prototype._click = function _click (ev) {
163
224
  var element = ev.element;
225
+ var isLink = element.type === LINK;
226
+ var isNode = element.type === NODE;
164
227
 
165
- if (element.type === NODE) {
166
- this.trigger('nodeTooltip', ev);
167
- } else if (element.type === LINK) {
168
- this.trigger('linkTooltip', ev);
228
+ if (isNode) {
229
+ this.trigger('nodeClick', ev);
230
+ } else if (isLink) {
231
+ this.trigger('linkClick', ev);
169
232
  }
170
233
  };
171
234
 
@@ -539,5 +602,10 @@ setDefaultOptions(Sankey, {
539
602
  opacity: 0.8,
540
603
  inactiveOpacity: 0.2
541
604
  }
605
+ },
606
+ tooltips: {
607
+ offset: 10,
608
+ followPointer: false,
609
+ delay: 1000
542
610
  }
543
611
  });
@@ -1,7 +1,7 @@
1
1
  import { Title as ChartTitle } from "../core";
2
2
  import { SankeyElement } from "./element";
3
3
  import { setDefaultOptions, getSpacing } from '../common';
4
- import { CENTER, TOP } from "../common/constants";
4
+ import { CENTER } from "../common/constants";
5
5
 
6
6
  export var Title = (function (SankeyElement) {
7
7
  function Title () {
@@ -73,6 +73,7 @@ export class Sankey extends Observable {
73
73
  mouseenter: this._mouseenter.bind(this),
74
74
  mouseleave: this._mouseleave.bind(this),
75
75
  mousemove: this._mousemove.bind(this),
76
+ click: this._click.bind(this)
76
77
  });
77
78
  }
78
79
 
@@ -95,6 +96,7 @@ export class Sankey extends Observable {
95
96
  trigger(name, ev) {
96
97
  const event = Object.assign({}, ev,
97
98
  {type: name,
99
+ targetType: ev.element.type,
98
100
  dataItem: ev.element.dataItem});
99
101
 
100
102
  return super.trigger(name, event);
@@ -135,7 +137,12 @@ export class Sankey extends Observable {
135
137
  }
136
138
 
137
139
  if (isLink || isNode) {
138
- this.trigger('hideTooltip', ev);
140
+ if (this.tooltipTimeOut) {
141
+ clearTimeout(this.tooltipTimeOut);
142
+ this.tooltipTimeOut = null;
143
+ }
144
+ this.tooltipShown = false;
145
+ this.trigger('tooltipHide', ev);
139
146
  }
140
147
 
141
148
  if ((isLink && this.trigger('linkLeave', ev)) ||
@@ -151,10 +158,59 @@ export class Sankey extends Observable {
151
158
  _mousemove(ev) {
152
159
  const element = ev.element;
153
160
 
154
- if (element.type === NODE) {
155
- this.trigger('nodeTooltip', ev);
156
- } else if (element.type === LINK) {
157
- this.trigger('linkTooltip', ev);
161
+ const tooltipElType = element.type;
162
+ if (tooltipElType !== LINK && tooltipElType !== NODE) {
163
+ return;
164
+ }
165
+
166
+ ev.tooltipTargetType = tooltipElType;
167
+ const mouseEvent = ev.originalEvent;
168
+ const rect = this.element.getBoundingClientRect();
169
+ const isLeft = mouseEvent.clientX - rect.left < rect.width / 2;
170
+ const { offset, followPointer, delay } = this.options.tooltips;
171
+
172
+ if (this.tooltipShown && !followPointer) {
173
+ return;
174
+ }
175
+
176
+ ev.tooltipData = {
177
+ popupOffset: {
178
+ left: mouseEvent.pageX + (isLeft ? offset : (-1 * offset)),
179
+ top: mouseEvent.pageY
180
+ },
181
+ popupAlign: {
182
+ horizontal: isLeft ? 'left' : 'right',
183
+ vertical: 'center'
184
+ }
185
+ };
186
+
187
+ if (tooltipElType === NODE) {
188
+ const { sourceLinks, targetLinks } = element.dataItem;
189
+ const links = targetLinks.length ? targetLinks : sourceLinks;
190
+ ev.nodeValue = links.reduce((acc, link) => acc + link.value, 0);
191
+ }
192
+
193
+ if (this.tooltipTimeOut) {
194
+ clearTimeout(this.tooltipTimeOut);
195
+ this.tooltipTimeOut = null;
196
+ }
197
+
198
+ this.tooltipTimeOut = setTimeout(() => {
199
+ this.trigger('tooltipShow', ev);
200
+ this.tooltipShown = true;
201
+ this.tooltipTimeOut = null;
202
+ }, delay);
203
+ }
204
+
205
+ _click(ev) {
206
+ const element = ev.element;
207
+ const isLink = element.type === LINK;
208
+ const isNode = element.type === NODE;
209
+
210
+ if (isNode) {
211
+ this.trigger('nodeClick', ev);
212
+ } else if (isLink) {
213
+ this.trigger('linkClick', ev);
158
214
  }
159
215
  }
160
216
 
@@ -503,5 +559,10 @@ setDefaultOptions(Sankey, {
503
559
  opacity: 0.8,
504
560
  inactiveOpacity: 0.2
505
561
  }
562
+ },
563
+ tooltips: {
564
+ offset: 10,
565
+ followPointer: false,
566
+ delay: 1000
506
567
  }
507
568
  });
@@ -1,7 +1,7 @@
1
1
  import { Title as ChartTitle } from "../core";
2
2
  import { SankeyElement } from "./element";
3
3
  import { setDefaultOptions, getSpacing } from '../common';
4
- import { CENTER, TOP } from "../common/constants";
4
+ import { CENTER } from "../common/constants";
5
5
 
6
6
  export class Title extends SankeyElement {
7
7
  getElement() {