@progress/kendo-charts 1.24.1 → 1.25.0-dev.202208301021

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.
@@ -303,6 +303,10 @@ var title = function () { return ({
303
303
  font: SANS16
304
304
  }); };
305
305
 
306
+ var subtitle = function () { return ({
307
+ font: SANS12
308
+ }); };
309
+
306
310
  var legend = function () { return ({
307
311
  labels: {
308
312
  font: SANS12
@@ -329,6 +333,7 @@ export var baseTheme = function (options) {
329
333
  },
330
334
  seriesDefaults: seriesDefaults(options),
331
335
  title: title(),
336
+ subtitle: subtitle(),
332
337
  legend: legend()
333
338
  });
334
339
  };
@@ -471,7 +471,12 @@ var Chart = (function (Class) {
471
471
  model.chart = this;
472
472
  model._plotArea = plotArea;
473
473
 
474
- Title.buildTitle(options.title, model);
474
+ var title = Title.buildTitle(options.title);
475
+ var subtitle = Title.buildTitle(options.subtitle, {
476
+ align: options.title.align,
477
+ position: options.title.position
478
+ });
479
+ model.append.apply(model, Title.orderTitles([title, subtitle]));
475
480
 
476
481
  if (options.legend && options.legend.visible) {
477
482
  model.append(new Legend(plotArea.options.legend, this.chartService));
@@ -36,7 +36,10 @@ var Pane = (function (BoxElement) {
36
36
  });
37
37
  }
38
38
 
39
- this.title = Title.buildTitle(titleOptions, this, Pane.prototype.options.title);
39
+ this.title = Title.buildTitle(titleOptions, Pane.prototype.options.title);
40
+ if (this.title) {
41
+ this.append(this.title);
42
+ }
40
43
  };
41
44
 
42
45
  Pane.prototype.appendAxis = function appendAxis (axis) {
@@ -1,18 +1,18 @@
1
1
  import ChartElement from './chart-element';
2
2
  import TextBox from './text-box';
3
3
 
4
- import { X, BLACK, TOP, CENTER } from '../common/constants';
4
+ import { X, BLACK, TOP, CENTER, BOTTOM } from '../common/constants';
5
5
  import { getSpacing, setDefaultOptions } from '../common';
6
6
 
7
7
  var Title = (function (ChartElement) {
8
8
  function Title(options) {
9
9
  ChartElement.call(this, options);
10
10
 
11
- this.append(
12
- new TextBox(this.options.text, Object.assign({}, this.options, {
13
- vAlign: this.options.position
14
- }))
15
- );
11
+ this._textBox = new TextBox(this.options.text, Object.assign({}, this.options, {
12
+ vAlign: this.options.position
13
+ }));
14
+
15
+ this.append(this._textBox);
16
16
  }
17
17
 
18
18
  if ( ChartElement ) Title.__proto__ = ChartElement;
@@ -24,7 +24,7 @@ var Title = (function (ChartElement) {
24
24
  this.box.snapTo(targetBox, X);
25
25
  };
26
26
 
27
- Title.buildTitle = function buildTitle (options, parent, defaultOptions) {
27
+ Title.buildTitle = function buildTitle (options, defaultOptions) {
28
28
  var titleOptions = options;
29
29
 
30
30
  if (typeof options === "string") {
@@ -36,15 +36,35 @@ var Title = (function (ChartElement) {
36
36
  var title;
37
37
  if (titleOptions && titleOptions.visible && titleOptions.text) {
38
38
  title = new Title(titleOptions);
39
- parent.append(title);
40
39
  }
41
40
 
42
41
  return title;
43
42
  };
44
43
 
44
+ Title.orderTitles = function orderTitles (titles) {
45
+ var items = [].concat(titles);
46
+ var top = items.filter(function (item) { return item && item.options.position !== BOTTOM; });
47
+ var bottom = items.filter(function (item) { return item && item.options.position === BOTTOM; });
48
+
49
+ collapseVerticalMargins(top);
50
+ collapseVerticalMargins(bottom);
51
+
52
+ bottom.reverse();
53
+ return top.concat(bottom);
54
+ };
55
+
45
56
  return Title;
46
57
  }(ChartElement));
47
58
 
59
+ function collapseVerticalMargins(items) {
60
+ for (var i = 1; i < items.length; i++) {
61
+ var box = items[i]._textBox;
62
+ var prevBox = items[i - 1]._textBox;
63
+ prevBox.options.margin = Object.assign(getSpacing(prevBox.options.margin), { bottom: 0 });
64
+ box.options.margin = Object.assign(getSpacing(box.options.margin), { top: 0 });
65
+ }
66
+ }
67
+
48
68
  setDefaultOptions(Title, {
49
69
  color: BLACK,
50
70
  position: TOP,
@@ -53,4 +73,4 @@ setDefaultOptions(Title, {
53
73
  padding: getSpacing(5)
54
74
  });
55
75
 
56
- export default Title;
76
+ export default Title;
@@ -303,6 +303,10 @@ const title = () => ({
303
303
  font: SANS16
304
304
  });
305
305
 
306
+ const subtitle = () => ({
307
+ font: SANS12
308
+ });
309
+
306
310
  const legend = () => ({
307
311
  labels: {
308
312
  font: SANS12
@@ -326,6 +330,7 @@ export const baseTheme = (options = {}) => ({
326
330
  },
327
331
  seriesDefaults: seriesDefaults(options),
328
332
  title: title(),
333
+ subtitle: subtitle(),
329
334
  legend: legend()
330
335
  });
331
336
 
@@ -461,7 +461,12 @@ class Chart extends Class {
461
461
  model.chart = this;
462
462
  model._plotArea = plotArea;
463
463
 
464
- Title.buildTitle(options.title, model);
464
+ const title = Title.buildTitle(options.title);
465
+ const subtitle = Title.buildTitle(options.subtitle, {
466
+ align: options.title.align,
467
+ position: options.title.position
468
+ });
469
+ model.append.apply(model, Title.orderTitles([title, subtitle]));
465
470
 
466
471
  if (options.legend && options.legend.visible) {
467
472
  model.append(new Legend(plotArea.options.legend, this.chartService));
@@ -32,7 +32,10 @@ class Pane extends BoxElement {
32
32
  });
33
33
  }
34
34
 
35
- this.title = Title.buildTitle(titleOptions, this, Pane.prototype.options.title);
35
+ this.title = Title.buildTitle(titleOptions, Pane.prototype.options.title);
36
+ if (this.title) {
37
+ this.append(this.title);
38
+ }
36
39
  }
37
40
 
38
41
  appendAxis(axis) {
@@ -1,18 +1,18 @@
1
1
  import ChartElement from './chart-element';
2
2
  import TextBox from './text-box';
3
3
 
4
- import { X, BLACK, TOP, CENTER } from '../common/constants';
4
+ import { X, BLACK, TOP, CENTER, BOTTOM } from '../common/constants';
5
5
  import { getSpacing, setDefaultOptions } from '../common';
6
6
 
7
7
  class Title extends ChartElement {
8
8
  constructor(options) {
9
9
  super(options);
10
10
 
11
- this.append(
12
- new TextBox(this.options.text, Object.assign({}, this.options, {
13
- vAlign: this.options.position
14
- }))
15
- );
11
+ this._textBox = new TextBox(this.options.text, Object.assign({}, this.options, {
12
+ vAlign: this.options.position
13
+ }));
14
+
15
+ this.append(this._textBox);
16
16
  }
17
17
 
18
18
  reflow(targetBox) {
@@ -20,7 +20,7 @@ class Title extends ChartElement {
20
20
  this.box.snapTo(targetBox, X);
21
21
  }
22
22
 
23
- static buildTitle(options, parent, defaultOptions) {
23
+ static buildTitle(options, defaultOptions) {
24
24
  let titleOptions = options;
25
25
 
26
26
  if (typeof options === "string") {
@@ -32,11 +32,31 @@ class Title extends ChartElement {
32
32
  let title;
33
33
  if (titleOptions && titleOptions.visible && titleOptions.text) {
34
34
  title = new Title(titleOptions);
35
- parent.append(title);
36
35
  }
37
36
 
38
37
  return title;
39
38
  }
39
+
40
+ static orderTitles(titles) {
41
+ const items = [].concat(titles);
42
+ const top = items.filter(item => item && item.options.position !== BOTTOM);
43
+ const bottom = items.filter(item => item && item.options.position === BOTTOM);
44
+
45
+ collapseVerticalMargins(top);
46
+ collapseVerticalMargins(bottom);
47
+
48
+ bottom.reverse();
49
+ return top.concat(bottom);
50
+ }
51
+ }
52
+
53
+ function collapseVerticalMargins(items) {
54
+ for (let i = 1; i < items.length; i++) {
55
+ const box = items[i]._textBox;
56
+ const prevBox = items[i - 1]._textBox;
57
+ prevBox.options.margin = Object.assign(getSpacing(prevBox.options.margin), { bottom: 0 });
58
+ box.options.margin = Object.assign(getSpacing(box.options.margin), { top: 0 });
59
+ }
40
60
  }
41
61
 
42
62
  setDefaultOptions(Title, {
@@ -47,4 +67,4 @@ setDefaultOptions(Title, {
47
67
  padding: getSpacing(5)
48
68
  });
49
69
 
50
- export default Title;
70
+ export default Title;