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

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,19 @@ 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
+
179
+ Bullet.prototype.overlapsBox = function overlapsBox (box) {
180
+ return this.box.overlaps(box);
181
+ };
182
+
141
183
  return Bullet;
142
184
  }(ChartElement));
143
185
 
@@ -159,8 +201,14 @@ setDefaultOptions(Bullet, {
159
201
  width: 2
160
202
  }
161
203
  },
204
+ labels: {
205
+ visible: false
206
+ },
162
207
  tooltip: {
163
208
  format: "Current: {0}<br />Target: {1}"
209
+ },
210
+ notes: {
211
+ label: {}
164
212
  }
165
213
  });
166
214
 
@@ -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,19 @@ 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
+ }
171
+
172
+ overlapsBox(box) {
173
+ return this.box.overlaps(box);
174
+ }
133
175
  }
134
176
 
135
177
  Bullet.prototype.tooltipAnchor = Bar.prototype.tooltipAnchor;
@@ -150,8 +192,14 @@ setDefaultOptions(Bullet, {
150
192
  width: 2
151
193
  }
152
194
  },
195
+ labels: {
196
+ visible: false
197
+ },
153
198
  tooltip: {
154
199
  format: "Current: {0}<br />Target: {1}"
200
+ },
201
+ notes: {
202
+ label: {}
155
203
  }
156
204
  });
157
205