@progress/kendo-charts 2.4.0-dev.202405211537 → 2.4.0-dev.202406100726

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.
Files changed (52) hide show
  1. package/dist/cdn/js/kendo-charts.js +1 -1
  2. package/dist/cdn/main.js +1 -1
  3. package/dist/es/chart/legend/legend-layout.js +4 -2
  4. package/dist/es/common/event-map.js +17 -0
  5. package/dist/es/common/event-utils.js +61 -0
  6. package/dist/es/common/get-supported-features.js +55 -0
  7. package/dist/es/common/noop.js +1 -0
  8. package/dist/es/common/now.js +3 -0
  9. package/dist/es/common/observable.js +1 -3
  10. package/dist/es/{map/scroller → common}/user-events.js +43 -131
  11. package/dist/es/common.js +7 -0
  12. package/dist/es/map/layers/layer.js +2 -5
  13. package/dist/es/map/layers/marker.js +3 -3
  14. package/dist/es/map/map.js +6 -6
  15. package/dist/es/map/navigator.js +3 -3
  16. package/dist/es/map/scroller/draggable.js +6 -11
  17. package/dist/es/map/scroller/fx.js +2 -2
  18. package/dist/es/map/scroller/scroller.js +7 -12
  19. package/dist/es/map/utils.js +9 -339
  20. package/dist/es/map/zoom.js +3 -3
  21. package/dist/es/sankey/label.js +21 -7
  22. package/dist/es/sankey/legend.js +16 -4
  23. package/dist/es/sankey/link.js +11 -4
  24. package/dist/es/sankey/sankey.js +67 -15
  25. package/dist/es/services/dom-events-builder.js +2 -4
  26. package/dist/es2015/chart/legend/legend-layout.js +4 -2
  27. package/dist/es2015/common/event-map.js +17 -0
  28. package/dist/es2015/common/event-utils.js +61 -0
  29. package/dist/es2015/common/get-supported-features.js +55 -0
  30. package/dist/es2015/common/noop.js +1 -0
  31. package/dist/es2015/common/now.js +3 -0
  32. package/dist/es2015/common/observable.js +1 -3
  33. package/dist/es2015/{map/scroller → common}/user-events.js +39 -131
  34. package/dist/es2015/common.js +7 -0
  35. package/dist/es2015/map/layers/layer.js +2 -5
  36. package/dist/es2015/map/layers/marker.js +3 -3
  37. package/dist/es2015/map/map.js +6 -6
  38. package/dist/es2015/map/navigator.js +3 -3
  39. package/dist/es2015/map/scroller/draggable.js +6 -11
  40. package/dist/es2015/map/scroller/fx.js +2 -2
  41. package/dist/es2015/map/scroller/scroller.js +7 -12
  42. package/dist/es2015/map/utils.js +8 -339
  43. package/dist/es2015/map/zoom.js +3 -3
  44. package/dist/es2015/sankey/label.js +19 -6
  45. package/dist/es2015/sankey/legend.js +15 -5
  46. package/dist/es2015/sankey/link.js +9 -4
  47. package/dist/es2015/sankey/sankey.js +66 -17
  48. package/dist/es2015/services/dom-events-builder.js +2 -4
  49. package/dist/npm/main.js +2795 -2975
  50. package/dist/npm/sankey.d.ts +4 -0
  51. package/dist/systemjs/kendo-charts.js +1 -1
  52. package/package.json +1 -1
@@ -13,6 +13,27 @@ import { defined } from '../drawing-utils';
13
13
  const LINK = 'link';
14
14
  const NODE = 'node';
15
15
 
16
+ const toRtl = sankey => {
17
+ const { nodes, links } = sankey;
18
+ const startX = Math.min(...nodes.map(node => node.x0));
19
+ const endX = Math.max(...nodes.map(node => node.x1));
20
+ const width = endX - startX;
21
+
22
+ nodes.forEach(node => {
23
+ const x0 = width - (node.x1 - 2 * startX);
24
+ const x1 = width - (node.x0 - 2 * startX);
25
+ node.x0 = x0;
26
+ node.x1 = x1;
27
+ });
28
+
29
+ links.forEach(link => {
30
+ const x0 = width - (link.x1 - 2 * startX);
31
+ const x1 = width - (link.x0 - 2 * startX);
32
+ link.x1 = x0;
33
+ link.x0 = x1;
34
+ });
35
+ };
36
+
16
37
  export class Sankey extends Observable {
17
38
  constructor(element, options, theme) {
18
39
  super();
@@ -91,11 +112,15 @@ export class Sankey extends Observable {
91
112
  element.addEventListener('pointerdown', this._onDownHandler);
92
113
 
93
114
  this._focusState = {
94
- node: this.columns[0][0],
115
+ node: this.firstFocusableNode(),
95
116
  link: null
96
117
  };
97
118
  }
98
119
 
120
+ firstFocusableNode() {
121
+ return this.columns[0][0];
122
+ }
123
+
99
124
  _initResizeObserver() {
100
125
  const observer = new ResizeObserver((entries) => {
101
126
  entries.forEach(entry => {
@@ -147,10 +172,13 @@ export class Sankey extends Observable {
147
172
  }
148
173
 
149
174
  trigger(name, ev) {
175
+ let dataItem = ev.element.dataItem;
176
+ const targetType = ev.element.type;
177
+
150
178
  const event = Object.assign({}, ev,
151
179
  {type: name,
152
- targetType: ev.element.type,
153
- dataItem: ev.element.dataItem});
180
+ targetType,
181
+ dataItem: dataItem});
154
182
 
155
183
  return super.trigger(name, event);
156
184
  }
@@ -416,7 +444,14 @@ export class Sankey extends Observable {
416
444
  }
417
445
 
418
446
  _keydown(ev) {
419
- const handler = this['on' + ev.key];
447
+ let handler = this['on' + ev.key];
448
+ const rtl = this.options.rtl;
449
+
450
+ if (rtl && ev.key === 'ArrowLeft') {
451
+ handler = this.onArrowRight;
452
+ } else if (rtl && ev.key === 'ArrowRight') {
453
+ handler = this.onArrowLeft;
454
+ }
420
455
 
421
456
  if (handler) {
422
457
  handler.call(this, ev);
@@ -426,7 +461,7 @@ export class Sankey extends Observable {
426
461
  onEscape(ev) {
427
462
  ev.preventDefault();
428
463
 
429
- this._focusState = { node: this.columns[0][0], link: null };
464
+ this._focusState = { node: this.firstFocusableNode(), link: null };
430
465
  this._focusNode();
431
466
  }
432
467
 
@@ -557,7 +592,7 @@ export class Sankey extends Observable {
557
592
  }
558
593
 
559
594
  calculateSankey(calcOptions, sankeyOptions) {
560
- const { title, legend, data, nodes, labels, nodeColors, disableAutoLayout, disableKeyboardNavigation } = sankeyOptions;
595
+ const { title, legend, data, nodes, labels, nodeColors, disableAutoLayout, disableKeyboardNavigation, rtl } = sankeyOptions;
561
596
  const autoLayout = !disableAutoLayout;
562
597
  const padding = disableKeyboardNavigation ? 0 : highlightOptions.width / 2;
563
598
 
@@ -608,12 +643,20 @@ export class Sankey extends Observable {
608
643
 
609
644
  const box = new Box();
610
645
 
646
+ const diagramMinX = calculatedNodes.reduce((acc, node) => Math.min(acc, node.x0), Infinity);
647
+ const diagramMaxX = calculatedNodes.reduce((acc, node) => Math.max(acc, node.x1), 0);
648
+
611
649
  calculatedNodes.forEach((nodeEl, i) => {
650
+ if (rtl) {
651
+ const { x0, x1 } = nodeEl;
652
+ nodeEl.x0 = diagramMaxX - x1;
653
+ nodeEl.x1 = diagramMaxX - x0;
654
+ }
612
655
  const nodeOps = resolveNodeOptions(nodeEl, nodes, nodeColors, i);
613
656
  const nodeInstance = new Node(nodeOps);
614
657
  box.wrap(rectToBox(nodeInstance.exportVisual().rawBBox()));
615
658
 
616
- const labelInstance = new Label(resolveLabelOptions(nodeEl, labels, sankeyBox.width()));
659
+ const labelInstance = new Label(resolveLabelOptions(nodeEl, labels, rtl, diagramMinX, diagramMaxX));
617
660
  const labelVisual = labelInstance.exportVisual();
618
661
  if (labelVisual) {
619
662
  box.wrap(rectToBox(labelVisual.rawBBox()));
@@ -687,11 +730,15 @@ export class Sankey extends Observable {
687
730
  const sankeyOptions = options || this.options;
688
731
  const sankeyContext = context || this;
689
732
 
690
- const { data, labels: labelOptions, nodes: nodesOptions, links: linkOptions, nodeColors, title, legend, disableKeyboardNavigation } = sankeyOptions;
733
+ const { labels: labelOptions, nodes: nodesOptions, links: linkOptions, nodeColors, title, legend, rtl, disableKeyboardNavigation } = sankeyOptions;
734
+ let data = sankeyOptions.data;
691
735
  const { width, height } = sankeyContext.size;
692
736
 
693
737
  const calcOptions = Object.assign({}, data, {width, height, nodesOptions, title, legend});
694
738
  const { sankey, titleBox, legendBox } = this.calculateSankey(calcOptions, sankeyOptions);
739
+ if (rtl) {
740
+ toRtl(sankey);
741
+ }
695
742
  const { nodes, links, columns } = sankey;
696
743
 
697
744
  sankeyContext.columns = columns.map(column => {
@@ -767,10 +814,11 @@ export class Sankey extends Observable {
767
814
  const { source, target } = link;
768
815
  const sourceNode = visualNodes.get(source.id);
769
816
  const targetNode = visualNodes.get(target.id);
770
- const linkOps = resolveLinkOptions(link, linkOptions, sourceNode, targetNode);
771
- linkOps.root = () => sankeyContext.element;
772
- linkOps.navigatable = disableKeyboardNavigation !== true;
773
- const linkInstance = new Link(linkOps);
817
+ const resolvedOptions = resolveLinkOptions(link, linkOptions, sourceNode, targetNode);
818
+ resolvedOptions.root = () => sankeyContext.element;
819
+ resolvedOptions.navigatable = disableKeyboardNavigation !== true;
820
+ resolvedOptions.rtl = rtl;
821
+ const linkInstance = new Link(resolvedOptions);
774
822
  const linkVisual = linkInstance.exportVisual();
775
823
 
776
824
  linkVisual.type = LINK;
@@ -779,7 +827,7 @@ export class Sankey extends Observable {
779
827
  target: Object.assign({}, targetNode.dataItem),
780
828
  value: link.value
781
829
  };
782
- linkVisual.linkOptions = linkOps;
830
+ linkVisual.linkOptions = resolvedOptions;
783
831
  linksVisuals.push(linkVisual);
784
832
 
785
833
  sourceNode.links.push(linkVisual);
@@ -797,9 +845,11 @@ export class Sankey extends Observable {
797
845
  visual.append(linkVisual);
798
846
  });
799
847
 
800
- const diagramWidth = nodes.reduce((acc, node) => Math.max(acc, node.x1), 0);
848
+ const diagramMinX = nodes.reduce((acc, node) => Math.min(acc, node.x0), Infinity);
849
+ const diagramMaxX = nodes.reduce((acc, node) => Math.max(acc, node.x1), 0);
850
+
801
851
  nodes.forEach((node) => {
802
- const textOps = resolveLabelOptions(node, labelOptions, diagramWidth);
852
+ const textOps = resolveLabelOptions(node, labelOptions, rtl, diagramMinX, diagramMaxX);
803
853
  const labelInstance = new Label(textOps);
804
854
  const labelVisual = labelInstance.exportVisual();
805
855
 
@@ -809,7 +859,7 @@ export class Sankey extends Observable {
809
859
  });
810
860
 
811
861
  if (legendBox) {
812
- const legendElement = new Legend(Object.assign({}, legend, {drawingRect: legendBox, nodes}));
862
+ const legendElement = new Legend(Object.assign({}, legend, {rtl, drawingRect: legendBox, nodes}));
813
863
  const legendVisual = legendElement.exportVisual();
814
864
  visual.append(legendVisual);
815
865
  }
@@ -867,7 +917,6 @@ setDefaultOptions(Sankey, {
867
917
  lineJoin: "round",
868
918
  width: 1
869
919
  },
870
- align: LEFT,
871
920
  offset: { left: 0, top: 0 }
872
921
  },
873
922
  nodes: {
@@ -1,4 +1,4 @@
1
- import { UserEvents } from '../map/scroller/user-events';
1
+ import { UserEvents } from '../common';
2
2
 
3
3
  let current;
4
4
 
@@ -13,9 +13,7 @@ class DomEventsBuilder {
13
13
  if (current) {
14
14
  builder = current.create(element, events);
15
15
  } else {
16
- builder = new UserEvents(element, Object.assign({}, {global: true,
17
- multiTouch: true,
18
- fastTap: true},
16
+ builder = new UserEvents(element, Object.assign({}, {multiTouch: true},
19
17
 
20
18
  events));
21
19
  }