@progress/kendo-charts 2.3.0-dev.202403191229 → 2.3.0-dev.202403211054

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.
@@ -5,6 +5,13 @@ import { nodeColor } from "./node";
5
5
  import { BOTTOM, CENTER, POINTER } from "../common/constants";
6
6
  import { AREA } from "../chart/constants";
7
7
 
8
+ var sortData = function (a, b) {
9
+ if (a.node.x0 - b.node.x0 !== 0) {
10
+ return a.node.x0 - b.node.x0;
11
+ }
12
+ return a.node.y0 - b.node.y0;
13
+ };
14
+
8
15
  export var Legend = (function (SankeyElement) {
9
16
  function Legend () {
10
17
  SankeyElement.apply(this, arguments);
@@ -30,6 +37,8 @@ export var Legend = (function (SankeyElement) {
30
37
  node: node,
31
38
  }); });
32
39
 
40
+ data.sort(sortData);
41
+
33
42
  var legend = new ChartLegend(Object.assign({}, options, {data: data}));
34
43
  legend.reflow(drawingRect);
35
44
 
@@ -28,6 +28,10 @@ export var Node = (function (SankeyElement) {
28
28
  opacity: options.opacity
29
29
  },
30
30
  stroke: { width: 0 },
31
+ className: 'k-sankey-node',
32
+ role: 'graphics-symbol',
33
+ ariaRoleDescription: 'Node',
34
+ ariaLabel: options.node.label.text
31
35
  };
32
36
  };
33
37
 
@@ -19,9 +19,9 @@ export var Sankey = (function (Observable) {
19
19
  function Sankey(element, options, theme) {
20
20
  Observable.call(this);
21
21
 
22
- this._initElement(element);
23
22
  this._initTheme(theme);
24
23
  this._setOptions(options);
24
+ this._initElement(element);
25
25
  this._initSurface();
26
26
 
27
27
  if (options && options.data) {
@@ -43,7 +43,16 @@ export var Sankey = (function (Observable) {
43
43
 
44
44
  Sankey.prototype._initElement = function _initElement (element) {
45
45
  this.element = element;
46
- addClass(this.element, [ "k-chart", "k-sankey" ]);
46
+ addClass(element, [ "k-chart", "k-sankey" ]);
47
+ element.setAttribute('role', 'graphics-document');
48
+ element.tabIndex = element.getAttribute("tabindex") || 0;
49
+
50
+ var ref = this.options;
51
+ var title = ref.title;
52
+
53
+ if (title.text) {
54
+ element.setAttribute('aria-label', title.text);
55
+ }
47
56
  };
48
57
 
49
58
  Sankey.prototype._initSurface = function _initSurface () {
@@ -81,6 +90,7 @@ export var Sankey = (function (Observable) {
81
90
  mouseenter: this._mouseenter.bind(this),
82
91
  mouseleave: this._mouseleave.bind(this),
83
92
  mousemove: this._mousemove.bind(this),
93
+ click: this._click.bind(this)
84
94
  });
85
95
  };
86
96
 
@@ -105,6 +115,7 @@ export var Sankey = (function (Observable) {
105
115
  Sankey.prototype.trigger = function trigger (name, ev) {
106
116
  var event = Object.assign({}, ev,
107
117
  {type: name,
118
+ targetType: ev.element.type,
108
119
  dataItem: ev.element.dataItem});
109
120
 
110
121
  return Observable.prototype.trigger.call(this, name, event);
@@ -218,6 +229,18 @@ export var Sankey = (function (Observable) {
218
229
  }, delay);
219
230
  };
220
231
 
232
+ Sankey.prototype._click = function _click (ev) {
233
+ var element = ev.element;
234
+ var isLink = element.type === LINK;
235
+ var isNode = element.type === NODE;
236
+
237
+ if (isNode) {
238
+ this.trigger('nodeClick', ev);
239
+ } else if (isLink) {
240
+ this.trigger('linkClick', ev);
241
+ }
242
+ };
243
+
221
244
  Sankey.prototype.highlightLinks = function highlightLinks (node, highlight) {
222
245
  var this$1 = this;
223
246
 
@@ -466,12 +489,6 @@ export var Sankey = (function (Observable) {
466
489
  visual.append(titleVisual);
467
490
  }
468
491
 
469
- if (legendBox) {
470
- var legendElement = new Legend(Object.assign({}, legend, {drawingRect: legendBox, nodes: nodes, colors: nodesColors}));
471
- var legendVisual = legendElement.exportVisual();
472
- visual.append(legendVisual);
473
- }
474
-
475
492
  var visualNodes = new Map();
476
493
  sankeyContext.nodesVisuals = visualNodes;
477
494
 
@@ -532,6 +549,12 @@ export var Sankey = (function (Observable) {
532
549
  }
533
550
  });
534
551
 
552
+ if (legendBox) {
553
+ var legendElement = new Legend(Object.assign({}, legend, {drawingRect: legendBox, nodes: nodes, colors: nodesColors}));
554
+ var legendVisual = legendElement.exportVisual();
555
+ visual.append(legendVisual);
556
+ }
557
+
535
558
  return visual;
536
559
  };
537
560
 
@@ -5,6 +5,13 @@ import { nodeColor } from "./node";
5
5
  import { BOTTOM, CENTER, POINTER } from "../common/constants";
6
6
  import { AREA } from "../chart/constants";
7
7
 
8
+ const sortData = (a, b) => {
9
+ if (a.node.x0 - b.node.x0 !== 0) {
10
+ return a.node.x0 - b.node.x0;
11
+ }
12
+ return a.node.y0 - b.node.y0;
13
+ };
14
+
8
15
  export class Legend extends SankeyElement {
9
16
  getElement() {
10
17
  const options = this.options;
@@ -20,6 +27,8 @@ export class Legend extends SankeyElement {
20
27
  node: node,
21
28
  }));
22
29
 
30
+ data.sort(sortData);
31
+
23
32
  const legend = new ChartLegend(Object.assign({}, options, {data}));
24
33
  legend.reflow(drawingRect);
25
34
 
@@ -20,6 +20,10 @@ export class Node extends SankeyElement {
20
20
  opacity: options.opacity
21
21
  },
22
22
  stroke: { width: 0 },
23
+ className: 'k-sankey-node',
24
+ role: 'graphics-symbol',
25
+ ariaRoleDescription: 'Node',
26
+ ariaLabel: options.node.label.text
23
27
  };
24
28
  }
25
29
  }
@@ -19,9 +19,9 @@ export class Sankey extends Observable {
19
19
  constructor(element, options, theme) {
20
20
  super();
21
21
 
22
- this._initElement(element);
23
22
  this._initTheme(theme);
24
23
  this._setOptions(options);
24
+ this._initElement(element);
25
25
  this._initSurface();
26
26
 
27
27
  if (options && options.data) {
@@ -39,7 +39,15 @@ export class Sankey extends Observable {
39
39
 
40
40
  _initElement(element) {
41
41
  this.element = element;
42
- addClass(this.element, [ "k-chart", "k-sankey" ]);
42
+ addClass(element, [ "k-chart", "k-sankey" ]);
43
+ element.setAttribute('role', 'graphics-document');
44
+ element.tabIndex = element.getAttribute("tabindex") || 0;
45
+
46
+ const { title } = this.options;
47
+
48
+ if (title.text) {
49
+ element.setAttribute('aria-label', title.text);
50
+ }
43
51
  }
44
52
 
45
53
  _initSurface() {
@@ -73,6 +81,7 @@ export class Sankey extends Observable {
73
81
  mouseenter: this._mouseenter.bind(this),
74
82
  mouseleave: this._mouseleave.bind(this),
75
83
  mousemove: this._mousemove.bind(this),
84
+ click: this._click.bind(this)
76
85
  });
77
86
  }
78
87
 
@@ -95,6 +104,7 @@ export class Sankey extends Observable {
95
104
  trigger(name, ev) {
96
105
  const event = Object.assign({}, ev,
97
106
  {type: name,
107
+ targetType: ev.element.type,
98
108
  dataItem: ev.element.dataItem});
99
109
 
100
110
  return super.trigger(name, event);
@@ -200,6 +210,18 @@ export class Sankey extends Observable {
200
210
  }, delay);
201
211
  }
202
212
 
213
+ _click(ev) {
214
+ const element = ev.element;
215
+ const isLink = element.type === LINK;
216
+ const isNode = element.type === NODE;
217
+
218
+ if (isNode) {
219
+ this.trigger('nodeClick', ev);
220
+ } else if (isLink) {
221
+ this.trigger('linkClick', ev);
222
+ }
223
+ }
224
+
203
225
  highlightLinks(node, highlight) {
204
226
  if (node) {
205
227
  this.setLinksOpacity(highlight.inactiveOpacity);
@@ -426,12 +448,6 @@ export class Sankey extends Observable {
426
448
  visual.append(titleVisual);
427
449
  }
428
450
 
429
- if (legendBox) {
430
- const legendElement = new Legend(Object.assign({}, legend, {drawingRect: legendBox, nodes, colors: nodesColors}));
431
- const legendVisual = legendElement.exportVisual();
432
- visual.append(legendVisual);
433
- }
434
-
435
451
  const visualNodes = new Map();
436
452
  sankeyContext.nodesVisuals = visualNodes;
437
453
 
@@ -491,6 +507,12 @@ export class Sankey extends Observable {
491
507
  }
492
508
  });
493
509
 
510
+ if (legendBox) {
511
+ const legendElement = new Legend(Object.assign({}, legend, {drawingRect: legendBox, nodes, colors: nodesColors}));
512
+ const legendVisual = legendElement.exportVisual();
513
+ visual.append(legendVisual);
514
+ }
515
+
494
516
  return visual;
495
517
  }
496
518