@progress/kendo-charts 1.25.1 → 1.26.0-dev.202209260625

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.
@@ -2,14 +2,16 @@ import { drawing as draw } from '@progress/kendo-drawing';
2
2
 
3
3
  import Target from './target';
4
4
 
5
- import { ChartElement, Box } from '../../core';
5
+ import { Box, ChartElement } from '../../core';
6
6
 
7
7
  import PointEventsMixin from '../mixins/point-events-mixin';
8
8
  import NoteMixin from '../mixins/note-mixin';
9
9
  import Bar from '../bar-chart/bar';
10
10
 
11
11
  import { WHITE, TOP, RIGHT } from '../../common/constants';
12
- import { alignPathToPixel, deepExtend, defined, setDefaultOptions, valueOrDefault } from '../../common';
12
+ import { alignPathToPixel, deepExtend, defined, getTemplate, setDefaultOptions, valueOrDefault } from '../../common';
13
+
14
+ import BarLabel from '../bar-chart/bar-label';
13
15
 
14
16
  var Bullet = (function (ChartElement) {
15
17
  function Bullet(value, options) {
@@ -48,10 +50,31 @@ var Bullet = (function (ChartElement) {
48
50
  this.append(this.target);
49
51
  }
50
52
 
53
+ this.createLabel();
51
54
  this.createNote();
52
55
  }
53
56
  };
54
57
 
58
+ Bullet.prototype.createLabel = function createLabel () {
59
+ var options = this.options;
60
+ var labels = options.labels;
61
+
62
+ if (labels.visible) {
63
+ var pointData = this.pointData();
64
+ var labelTemplate = getTemplate(labels);
65
+ var labelText;
66
+
67
+ if (labelTemplate) {
68
+ labelText = labelTemplate(pointData);
69
+ } else {
70
+ labelText = this.formatValue(labels.format);
71
+ }
72
+
73
+ this.label = new BarLabel(labelText, labels, pointData);
74
+ this.append(this.label);
75
+ }
76
+ };
77
+
55
78
  Bullet.prototype.reflow = function reflow (box) {
56
79
  this.render();
57
80
 
@@ -76,6 +99,12 @@ var Bullet = (function (ChartElement) {
76
99
  target.reflow(targetSlot);
77
100
  }
78
101
 
102
+ var label = this.label;
103
+ if (label) {
104
+ label.options.aboveAxis = this.aboveAxis;
105
+ label.reflow(box);
106
+ }
107
+
79
108
  if (this.note) {
80
109
  this.note.reflow(box);
81
110
  }
@@ -138,6 +167,15 @@ var Bullet = (function (ChartElement) {
138
167
  return this.owner.formatPointValue(this, format);
139
168
  };
140
169
 
170
+ Bullet.prototype.pointData = function pointData () {
171
+ return {
172
+ dataItem: this.dataItem,
173
+ category: this.category,
174
+ value: this.value,
175
+ series: this.series
176
+ };
177
+ };
178
+
141
179
  return Bullet;
142
180
  }(ChartElement));
143
181
 
@@ -159,8 +197,14 @@ setDefaultOptions(Bullet, {
159
197
  width: 2
160
198
  }
161
199
  },
200
+ labels: {
201
+ visible: false
202
+ },
162
203
  tooltip: {
163
204
  format: "Current: {0}<br />Target: {1}"
205
+ },
206
+ notes: {
207
+ label: {}
164
208
  }
165
209
  });
166
210
 
@@ -2,14 +2,16 @@ import { drawing as draw } from '@progress/kendo-drawing';
2
2
 
3
3
  import Target from './target';
4
4
 
5
- import { ChartElement, Box } from '../../core';
5
+ import { Box, ChartElement } from '../../core';
6
6
 
7
7
  import PointEventsMixin from '../mixins/point-events-mixin';
8
8
  import NoteMixin from '../mixins/note-mixin';
9
9
  import Bar from '../bar-chart/bar';
10
10
 
11
11
  import { WHITE, TOP, RIGHT } from '../../common/constants';
12
- import { alignPathToPixel, deepExtend, defined, setDefaultOptions, valueOrDefault } from '../../common';
12
+ import { alignPathToPixel, deepExtend, defined, getTemplate, setDefaultOptions, valueOrDefault } from '../../common';
13
+
14
+ import BarLabel from '../bar-chart/bar-label';
13
15
 
14
16
  class Bullet extends ChartElement {
15
17
  constructor(value, options) {
@@ -44,10 +46,31 @@ class Bullet extends ChartElement {
44
46
  this.append(this.target);
45
47
  }
46
48
 
49
+ this.createLabel();
47
50
  this.createNote();
48
51
  }
49
52
  }
50
53
 
54
+ createLabel() {
55
+ const options = this.options;
56
+ const labels = options.labels;
57
+
58
+ if (labels.visible) {
59
+ const pointData = this.pointData();
60
+ let labelTemplate = getTemplate(labels);
61
+ let labelText;
62
+
63
+ if (labelTemplate) {
64
+ labelText = labelTemplate(pointData);
65
+ } else {
66
+ labelText = this.formatValue(labels.format);
67
+ }
68
+
69
+ this.label = new BarLabel(labelText, labels, pointData);
70
+ this.append(this.label);
71
+ }
72
+ }
73
+
51
74
  reflow(box) {
52
75
  this.render();
53
76
 
@@ -69,6 +92,12 @@ class Bullet extends ChartElement {
69
92
  target.reflow(targetSlot);
70
93
  }
71
94
 
95
+ const label = this.label;
96
+ if (label) {
97
+ label.options.aboveAxis = this.aboveAxis;
98
+ label.reflow(box);
99
+ }
100
+
72
101
  if (this.note) {
73
102
  this.note.reflow(box);
74
103
  }
@@ -130,6 +159,15 @@ class Bullet extends ChartElement {
130
159
  formatValue(format) {
131
160
  return this.owner.formatPointValue(this, format);
132
161
  }
162
+
163
+ pointData() {
164
+ return {
165
+ dataItem: this.dataItem,
166
+ category: this.category,
167
+ value: this.value,
168
+ series: this.series
169
+ };
170
+ }
133
171
  }
134
172
 
135
173
  Bullet.prototype.tooltipAnchor = Bar.prototype.tooltipAnchor;
@@ -150,8 +188,14 @@ setDefaultOptions(Bullet, {
150
188
  width: 2
151
189
  }
152
190
  },
191
+ labels: {
192
+ visible: false
193
+ },
153
194
  tooltip: {
154
195
  format: "Current: {0}<br />Target: {1}"
196
+ },
197
+ notes: {
198
+ label: {}
155
199
  }
156
200
  });
157
201