@progress/kendo-charts 2.10.0-develop.2 → 2.10.0-develop.4

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.
@@ -367,14 +367,12 @@ class Chart {
367
367
 
368
368
  const transitions = this.options.transitions;
369
369
  const motionConfig = this.options.motion || {};
370
- const motion = {
371
- enabled: motionConfig.enabled
372
- };
373
370
  if (transitions !== false) {
374
371
  model.traverse(function(element) {
375
372
  if (element.animation) {
376
- const loading = (transitions && transitions !== true) ? transitions.loading : transitions;
377
- element.animation.options = Object.assign({}, element.animation.options, loading, {motionConfig, motion});
373
+ element.animation.options = Object.assign({}, element.animation.options,
374
+ {duration: undefined,
375
+ motionConfig: Object.assign({}, motionConfig)});
378
376
  element.animation.setup();
379
377
  }
380
378
  });
@@ -481,6 +479,75 @@ class Chart {
481
479
  return visual;
482
480
  }
483
481
 
482
+ _toggleCategoryHighlight(index, axis) {
483
+ const plotArea = this._plotArea;
484
+ const categoryAxis = axis || plotArea.categoryAxis;
485
+
486
+ if (this._categoryHighlightIndex === index && this._categoryHighlightAxis === categoryAxis) {
487
+ return;
488
+ }
489
+
490
+ this._categoryHighlightIndex = index;
491
+ this._categoryHighlightAxis = categoryAxis;
492
+
493
+ const highlightOptions = (categoryAxis.options || {}).highlight;
494
+
495
+ if (!highlightOptions || !highlightOptions.visible || index === null) {
496
+ if (this._categoryHighlight) {
497
+ this._categoryHighlight.visible(false);
498
+ }
499
+ return;
500
+ }
501
+
502
+ if (!this._categoryHighlight) {
503
+ this._categoryHighlight = new draw.Path({
504
+ fill: {
505
+ color: highlightOptions.color,
506
+ opacity: highlightOptions.opacity
507
+ },
508
+ stroke: highlightOptions.border || null,
509
+ closed: true
510
+ });
511
+
512
+ this.surface.draw(this._categoryHighlight);
513
+ } else {
514
+ const options = this._categoryHighlight.options;
515
+ options.set("fill", {
516
+ color: highlightOptions.color,
517
+ opacity: highlightOptions.opacity
518
+ });
519
+ options.set("stroke", highlightOptions.border);
520
+ }
521
+
522
+ const slot = categoryAxis.getSlot(index);
523
+ const rect = slot.toRect();
524
+ let plotBox = plotArea.box;
525
+
526
+ if (categoryAxis.pane) {
527
+ plotBox = categoryAxis.pane.chartsBox();
528
+ }
529
+
530
+ if (categoryAxis.options.vertical) {
531
+ rect.origin.x = plotBox.x1;
532
+ rect.size.width = plotBox.width();
533
+ } else {
534
+ rect.origin.y = plotBox.y1;
535
+ rect.size.height = plotBox.height();
536
+ }
537
+
538
+ const newPath = draw.Path.fromRect(rect);
539
+ this._categoryHighlight.segments.elements(newPath.segments.elements());
540
+ this._categoryHighlight.visible(true);
541
+ }
542
+
543
+ _categoryHighlightEnabled() {
544
+ const plotArea = this._plotArea;
545
+ const categoryAxis = plotArea.categoryAxis || {};
546
+ const highlightOptions = (categoryAxis.options || {}).highlight;
547
+
548
+ return plotArea instanceof CategoricalPlotArea && highlightOptions && highlightOptions.visible;
549
+ }
550
+
484
551
  _sharedTooltip() {
485
552
  return this._plotArea instanceof CategoricalPlotArea && this.options.tooltip && this.options.tooltip.shared;
486
553
  }
@@ -1796,6 +1863,22 @@ class Chart {
1796
1863
  if (this._sharedTooltip()) {
1797
1864
  this._trackSharedTooltip(coords, e);
1798
1865
  }
1866
+
1867
+ if (this._categoryHighlightEnabled()) {
1868
+ this._trackCategoryHighlight(coords);
1869
+ }
1870
+ }
1871
+
1872
+ _trackCategoryHighlight(coords) {
1873
+ const { _plotArea: plotArea } = this;
1874
+ const categoryAxis = plotArea.categoryAxisByPoint(coords) || plotArea.categoryAxis;
1875
+
1876
+ if (plotArea.backgroundContainsPoint(coords)) {
1877
+ const index = categoryAxis.pointCategoryIndex(coords);
1878
+ this._toggleCategoryHighlight(index, categoryAxis);
1879
+ } else {
1880
+ this._toggleCategoryHighlight(null);
1881
+ }
1799
1882
  }
1800
1883
 
1801
1884
  _trackCrosshairs(coords) {
@@ -1862,6 +1945,8 @@ class Chart {
1862
1945
  plotArea.hideCrosshairs();
1863
1946
 
1864
1947
  this._unsetActivePoint(options);
1948
+
1949
+ this._toggleCategoryHighlight(null);
1865
1950
  }
1866
1951
 
1867
1952
  _unsetActivePoint(options) {
@@ -2001,7 +2086,7 @@ class Chart {
2001
2086
  }
2002
2087
 
2003
2088
  _shouldAttachMouseMove() {
2004
- return this._plotArea.crosshairs.length || (this._tooltip && this._sharedTooltip()) || this.requiresHandlers([ PLOT_AREA_HOVER, PLOT_AREA_LEAVE ]);
2089
+ return this._plotArea.crosshairs.length || (this._tooltip && this._sharedTooltip()) || this._categoryHighlightEnabled() || this.requiresHandlers([ PLOT_AREA_HOVER, PLOT_AREA_LEAVE ]);
2005
2090
  }
2006
2091
 
2007
2092
  updateMouseMoveHandler() {
@@ -2315,9 +2400,7 @@ function triggerPaneRender(panes) {
2315
2400
 
2316
2401
  setDefaultOptions(Chart, {
2317
2402
  renderAs: "",
2318
- motion: {
2319
- enabled: false,
2320
- },
2403
+ motion: {},
2321
2404
  chartArea: {},
2322
2405
  legend: {
2323
2406
  visible: true,
@@ -2331,7 +2414,12 @@ setDefaultOptions(Chart, {
2331
2414
  }
2332
2415
  }
2333
2416
  },
2334
- categoryAxis: {},
2417
+ categoryAxis: {
2418
+ highlight: {
2419
+ visible: false,
2420
+ border: null
2421
+ }
2422
+ },
2335
2423
  seriesDefaults: {
2336
2424
  type: COLUMN,
2337
2425
  data: [],
@@ -11,10 +11,10 @@ const ClipAnimationMixin = {
11
11
  if (root && transitions !== false) {
12
12
  const box = (this.parent && this.parent.clipBox) || root.size();
13
13
  const clipPath = draw.Path.fromRect(box.toRect());
14
- const loading = (transitions && transitions !== true) ? transitions.loading : transitions;
15
14
  this.visual.clip(clipPath);
16
- this.animation = new ClipAnimation(clipPath, Object.assign({}, {box: box},
17
- loading));
15
+ this.animation = new ClipAnimation(clipPath, {
16
+ box: box
17
+ });
18
18
  if (anyHasZIndex(this.options.series)) {
19
19
  this._setChildrenAnimation(clipPath);
20
20
  }
@@ -883,6 +883,21 @@ class CategoricalPlotArea extends PlotAreaBase {
883
883
 
884
884
  return sortableSeries || stackableSeries && point.options.isStacked;
885
885
  }
886
+
887
+ categoryAxisByPoint(point) {
888
+ const axes = this.axes;
889
+ let axis;
890
+
891
+ for (let i = 0; i < axes.length; i++) {
892
+ const current = axes[i];
893
+ if (current instanceof CategoryAxis && current.pane.chartsBox().containsPoint(point)) {
894
+ axis = current;
895
+ break;
896
+ }
897
+ }
898
+
899
+ return axis;
900
+ }
886
901
  }
887
902
 
888
903
  function updateAxisOptions(targetOptions, axis, options) {
@@ -62,29 +62,12 @@ const parseToMS = (value) => {
62
62
  };
63
63
 
64
64
  function parseCubicBezier(input) {
65
- const s = input.trim();
65
+ const s = (input || "").trim();
66
66
  const m = s.match(
67
67
  /cubic-bezier\s*\(\s*([+-]?\d*\.?\d+)\s*,\s*([+-]?\d*\.?\d+)\s*,\s*([+-]?\d*\.?\d+)\s*,\s*([+-]?\d*\.?\d+)\s*\)\s*/i
68
68
  );
69
69
 
70
- return m ? [Number(m[1]), Number(m[2]), Number(m[3]), Number(m[4])] : [0, 0, 1, 1];
71
- }
72
-
73
- function parseEasing(input) {
74
- switch (input) {
75
- case "linear":
76
- return [0, 0, 1, 1];
77
- case "ease":
78
- return [0.25, 0.1, 0.25, 1];
79
- case "ease-in":
80
- return [0.42, 0, 1, 1];
81
- case "ease-out":
82
- return [0, 0, 0.58, 1];
83
- case "ease-in-out":
84
- return [0.42, 0, 0.58, 1];
85
- default:
86
- return input ? parseCubicBezier(input) : [0, 0, 1, 1];
87
- }
70
+ return m ? [Number(m[1]), Number(m[2]), Number(m[3]), Number(m[4])] : null;
88
71
  }
89
72
 
90
73
  // -----------------------------------------------------------------------------
@@ -123,8 +106,9 @@ const chartVariables = {
123
106
  inactive: "--kendo-chart-inactive",
124
107
  initialAnimationDuration: '--kendo-duration-steady',
125
108
  fadeInAnimationDuration: '--kendo-duration-rapid',
126
- elasticEasing: '--kendo-easing-elastic',
109
+ elasticEasing: '--kendo-easing-stretchy',
127
110
  linearEasing: '--kendo-easing-linear',
111
+ swingEasing: '--kendo-easing-standard',
128
112
  };
129
113
 
130
114
  // Sankey-specific variables (in addition to shared)
@@ -293,10 +277,11 @@ export const chartTheme = (element) => {
293
277
  });
294
278
 
295
279
  const motion = {
296
- initialDuration: parseToMS(getProp(element, vars.initialAnimationDuration)),
297
- fadeInDuration: parseToMS(getProp(element, vars.fadeInAnimationDuration)),
298
- elasticEasing: parseEasing(getProp(element, vars.elasticEasing)),
299
- linearEasing: parseEasing(getProp(element, vars.linearEasing)),
280
+ steady: parseToMS(getProp(element, vars.initialAnimationDuration)) || 600,
281
+ rapid: parseToMS(getProp(element, vars.fadeInAnimationDuration)) || 200,
282
+ easeOutElastic: parseCubicBezier(getProp(element, vars.elasticEasing)) || [0.07, 1.81, 0.3, 0.81],
283
+ linear: parseCubicBezier(getProp(element, vars.linearEasing)) || [0, 0, 1, 1],
284
+ swing: parseCubicBezier(getProp(element, vars.swingEasing)) || [0.42, 0, 0.58, 1]
300
285
  };
301
286
 
302
287
  return {
@@ -323,6 +308,12 @@ export const chartTheme = (element) => {
323
308
  font: defaultFont(element),
324
309
  }
325
310
  },
311
+ categoryAxis: {
312
+ highlight: {
313
+ color: "#8C9FD9",
314
+ opacity: 0.15
315
+ }
316
+ },
326
317
  chartArea: {
327
318
  background: chartBg,
328
319
  },