@progress/kendo-charts 2.12.2 → 2.12.3-develop.2
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.
- package/dist/cdn/js/kendo-charts.js +1 -1
- package/dist/cdn/main.js +1 -1
- package/dist/es/chart/area-chart/area-chart.js +33 -27
- package/dist/es/chart/area-chart/spline-area-segment.js +1 -16
- package/dist/es/chart/mixins/line-chart-mixin.js +13 -1
- package/dist/es/core/curve-processor.js +6 -29
- package/dist/es2015/chart/area-chart/area-chart.js +33 -27
- package/dist/es2015/chart/area-chart/spline-area-segment.js +1 -16
- package/dist/es2015/chart/mixins/line-chart-mixin.js +13 -1
- package/dist/es2015/core/curve-processor.js +6 -29
- package/dist/npm/main.js +49 -71
- package/dist/systemjs/kendo-charts.js +1 -1
- package/package.json +1 -1
|
@@ -7,6 +7,8 @@ import SplineAreaSegment from './spline-area-segment';
|
|
|
7
7
|
|
|
8
8
|
import { STEP, SMOOTH, ZERO } from '../constants';
|
|
9
9
|
|
|
10
|
+
import { last } from '../../common';
|
|
11
|
+
|
|
10
12
|
class AreaChart extends LineChart {
|
|
11
13
|
createSegment(linePoints, currentSeries, seriesIx, prevSegment) {
|
|
12
14
|
const isStacked = this.options.isStacked;
|
|
@@ -15,13 +17,8 @@ class AreaChart extends LineChart {
|
|
|
15
17
|
|
|
16
18
|
let stackPoints;
|
|
17
19
|
if (isStacked && seriesIx > 0 && prevSegment) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
stackPoints = prevSegment.linePoints;
|
|
21
|
-
previousSegment = prevSegment;
|
|
22
|
-
} else {
|
|
23
|
-
stackPoints = this._gapStackPoints(linePoints, seriesIx, style);
|
|
24
|
-
}
|
|
20
|
+
stackPoints = this._getStackPoints(linePoints, seriesIx, style);
|
|
21
|
+
previousSegment = prevSegment;
|
|
25
22
|
}
|
|
26
23
|
|
|
27
24
|
let pointType;
|
|
@@ -49,41 +46,50 @@ class AreaChart extends LineChart {
|
|
|
49
46
|
}
|
|
50
47
|
}
|
|
51
48
|
|
|
52
|
-
|
|
49
|
+
_getStackPoints(linePoints, seriesIx, style) {
|
|
53
50
|
const seriesPoints = this.seriesPoints;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
if (startIdx < 0) {
|
|
57
|
-
startIdx = 0;
|
|
58
|
-
length--;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const endIdx = startIdx + length;
|
|
51
|
+
const startIdx = Math.max(-1, linePoints[0].categoryIx);
|
|
52
|
+
const endIdx = last(linePoints).categoryIx + 1;
|
|
62
53
|
const pointOffset = this.seriesOptions[0]._outOfRangeMinPoint ? 1 : 0;
|
|
63
54
|
const stackPoints = [];
|
|
64
55
|
|
|
65
56
|
this._stackPoints = this._stackPoints || [];
|
|
66
57
|
for (let categoryIx = startIdx; categoryIx < endIdx; categoryIx++) {
|
|
67
|
-
const pointIx = categoryIx
|
|
58
|
+
const pointIx = categoryIx;
|
|
68
59
|
let currentSeriesIx = seriesIx;
|
|
69
|
-
let
|
|
60
|
+
let prevPoint;
|
|
61
|
+
let crossesSegment = false;
|
|
70
62
|
|
|
71
63
|
do {
|
|
72
64
|
currentSeriesIx--;
|
|
73
|
-
|
|
74
|
-
} while (currentSeriesIx > 0 && !point);
|
|
65
|
+
prevPoint = seriesPoints[currentSeriesIx][pointIx + pointOffset];
|
|
75
66
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
67
|
+
if (!prevPoint && this.hasSegmentForPoint(currentSeriesIx, categoryIx)) {
|
|
68
|
+
crossesSegment = true;
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
} while (currentSeriesIx > 0 && !prevPoint);
|
|
72
|
+
|
|
73
|
+
if (prevPoint) {
|
|
74
|
+
if (style !== STEP && categoryIx > startIdx) {
|
|
75
|
+
const crossesPrevSegment = this.hasSegmentForPoint(currentSeriesIx, pointIx - 1);
|
|
76
|
+
if (!crossesPrevSegment) {
|
|
77
|
+
// No previous point, close the gap with a point from the previous segment
|
|
78
|
+
stackPoints.push(this._previousSegmentPoint(categoryIx, pointIx, pointIx - 1, currentSeriesIx));
|
|
79
|
+
}
|
|
79
80
|
}
|
|
80
81
|
|
|
81
|
-
stackPoints.push(
|
|
82
|
+
stackPoints.push(prevPoint);
|
|
82
83
|
|
|
83
|
-
if (style !== STEP && categoryIx + 1 < endIdx
|
|
84
|
-
|
|
84
|
+
if (style !== STEP && categoryIx + 1 < endIdx) {
|
|
85
|
+
const crossesNextSegment = this.hasSegmentForPoint(currentSeriesIx, pointIx + 1);
|
|
86
|
+
if (!crossesNextSegment) {
|
|
87
|
+
// No next point, close the gap with a point from the previous segment
|
|
88
|
+
stackPoints.push(this._previousSegmentPoint(categoryIx, pointIx, pointIx + 1, currentSeriesIx));
|
|
89
|
+
}
|
|
85
90
|
}
|
|
86
|
-
} else {
|
|
91
|
+
} else if (!crossesSegment) {
|
|
92
|
+
// No previous point in the stack and does not cross a segment, add a gap point
|
|
87
93
|
const gapStackPoint = this._createGapStackPoint(categoryIx);
|
|
88
94
|
this._stackPoints.push(gapStackPoint);
|
|
89
95
|
stackPoints.push(gapStackPoint);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { geometry as geom } from '@progress/kendo-drawing';
|
|
2
1
|
import { CurveProcessor } from '../../core';
|
|
3
2
|
|
|
4
3
|
import AreaSegment from './area-segment';
|
|
@@ -12,20 +11,6 @@ class SplineAreaSegment extends AreaSegment {
|
|
|
12
11
|
return curveProcessor.process(linePoints);
|
|
13
12
|
}
|
|
14
13
|
|
|
15
|
-
createStackSegments() {
|
|
16
|
-
const strokeSegments = this.strokeSegments();
|
|
17
|
-
const stackSegments = [];
|
|
18
|
-
for (let idx = strokeSegments.length - 1; idx >= 0; idx--) {
|
|
19
|
-
const segment = strokeSegments[idx];
|
|
20
|
-
stackSegments.push(new geom.Segment(
|
|
21
|
-
segment.anchor(),
|
|
22
|
-
segment.controlOut(),
|
|
23
|
-
segment.controlIn()
|
|
24
|
-
));
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return stackSegments;
|
|
28
|
-
}
|
|
29
14
|
}
|
|
30
15
|
|
|
31
|
-
export default SplineAreaSegment;
|
|
16
|
+
export default SplineAreaSegment;
|
|
@@ -49,6 +49,18 @@ const LineChartMixin = {
|
|
|
49
49
|
segment.parent = this;
|
|
50
50
|
},
|
|
51
51
|
|
|
52
|
+
hasSegmentForPoint(seriesIx, pointIx) {
|
|
53
|
+
return this._segments.some(segment => {
|
|
54
|
+
if (segment.seriesIx !== seriesIx) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
const points = segment.linePoints;
|
|
58
|
+
const start = points[0].categoryIx;
|
|
59
|
+
const end = points[points.length - 1].categoryIx;
|
|
60
|
+
return pointIx >= start && pointIx <= end;
|
|
61
|
+
});
|
|
62
|
+
},
|
|
63
|
+
|
|
52
64
|
sortPoints: function(points) {
|
|
53
65
|
return points;
|
|
54
66
|
},
|
|
@@ -84,4 +96,4 @@ const LineChartMixin = {
|
|
|
84
96
|
}
|
|
85
97
|
};
|
|
86
98
|
|
|
87
|
-
export default LineChartMixin;
|
|
99
|
+
export default LineChartMixin;
|
|
@@ -153,7 +153,6 @@ class CurveProcessor {
|
|
|
153
153
|
controlPoints(p0, p1, p2) {
|
|
154
154
|
let xField = X;
|
|
155
155
|
let yField = Y;
|
|
156
|
-
let restrict = false;
|
|
157
156
|
let switchOrientation = false;
|
|
158
157
|
let tangent;
|
|
159
158
|
|
|
@@ -166,8 +165,11 @@ class CurveProcessor {
|
|
|
166
165
|
};
|
|
167
166
|
|
|
168
167
|
if (monotonic.x && monotonic.y) {
|
|
169
|
-
|
|
170
|
-
|
|
168
|
+
const h0 = p1[xField] - p0[xField];
|
|
169
|
+
const h1 = p2[xField] - p1[xField];
|
|
170
|
+
const d0 = (p1[yField] - p0[yField]) / h0;
|
|
171
|
+
const d1 = (p2[yField] - p1[yField]) / h1;
|
|
172
|
+
tangent = 3 * (h0 + h1) / ((2 * h1 + h0) / d0 + (h1 + 2 * h0) / d1);
|
|
171
173
|
} else {
|
|
172
174
|
if (this.invertAxis(p0, p1, p2)) {
|
|
173
175
|
xField = Y;
|
|
@@ -201,34 +203,9 @@ class CurveProcessor {
|
|
|
201
203
|
|
|
202
204
|
const firstControlPoint = this.firstControlPoint(tangent, p1, p2, xField, yField);
|
|
203
205
|
|
|
204
|
-
if (restrict) {
|
|
205
|
-
this.restrictControlPoint(p0, p1, secondControlPoint, tangent);
|
|
206
|
-
this.restrictControlPoint(p1, p2, firstControlPoint, tangent);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
206
|
return [ secondControlPoint, firstControlPoint ];
|
|
210
207
|
}
|
|
211
208
|
|
|
212
|
-
restrictControlPoint(p1, p2, cp, tangent) {
|
|
213
|
-
if (p1.y < p2.y) {
|
|
214
|
-
if (p2.y < cp.y) {
|
|
215
|
-
cp.x = p1.x + (p2.y - p1.y) / tangent;
|
|
216
|
-
cp.y = p2.y;
|
|
217
|
-
} else if (cp.y < p1.y) {
|
|
218
|
-
cp.x = p2.x - (p2.y - p1.y) / tangent;
|
|
219
|
-
cp.y = p1.y;
|
|
220
|
-
}
|
|
221
|
-
} else {
|
|
222
|
-
if (cp.y < p2.y) {
|
|
223
|
-
cp.x = p1.x - (p1.y - p2.y) / tangent;
|
|
224
|
-
cp.y = p2.y;
|
|
225
|
-
} else if (p1.y < cp.y) {
|
|
226
|
-
cp.x = p2.x + (p1.y - p2.y) / tangent;
|
|
227
|
-
cp.y = p1.y;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
|
|
232
209
|
tangent(p0, p1, xField, yField) {
|
|
233
210
|
const x = p1[xField] - p0[xField];
|
|
234
211
|
const y = p1[yField] - p0[yField];
|
|
@@ -287,4 +264,4 @@ function numberSign(value) {
|
|
|
287
264
|
return value <= 0 ? -1 : 1;
|
|
288
265
|
}
|
|
289
266
|
|
|
290
|
-
export default CurveProcessor;
|
|
267
|
+
export default CurveProcessor;
|
|
@@ -7,6 +7,8 @@ import SplineAreaSegment from './spline-area-segment';
|
|
|
7
7
|
|
|
8
8
|
import { STEP, SMOOTH, ZERO } from '../constants';
|
|
9
9
|
|
|
10
|
+
import { last } from '../../common';
|
|
11
|
+
|
|
10
12
|
class AreaChart extends LineChart {
|
|
11
13
|
createSegment(linePoints, currentSeries, seriesIx, prevSegment) {
|
|
12
14
|
const isStacked = this.options.isStacked;
|
|
@@ -15,13 +17,8 @@ class AreaChart extends LineChart {
|
|
|
15
17
|
|
|
16
18
|
let stackPoints;
|
|
17
19
|
if (isStacked && seriesIx > 0 && prevSegment) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
stackPoints = prevSegment.linePoints;
|
|
21
|
-
previousSegment = prevSegment;
|
|
22
|
-
} else {
|
|
23
|
-
stackPoints = this._gapStackPoints(linePoints, seriesIx, style);
|
|
24
|
-
}
|
|
20
|
+
stackPoints = this._getStackPoints(linePoints, seriesIx, style);
|
|
21
|
+
previousSegment = prevSegment;
|
|
25
22
|
}
|
|
26
23
|
|
|
27
24
|
let pointType;
|
|
@@ -49,41 +46,50 @@ class AreaChart extends LineChart {
|
|
|
49
46
|
}
|
|
50
47
|
}
|
|
51
48
|
|
|
52
|
-
|
|
49
|
+
_getStackPoints(linePoints, seriesIx, style) {
|
|
53
50
|
const seriesPoints = this.seriesPoints;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
if (startIdx < 0) {
|
|
57
|
-
startIdx = 0;
|
|
58
|
-
length--;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const endIdx = startIdx + length;
|
|
51
|
+
const startIdx = Math.max(-1, linePoints[0].categoryIx);
|
|
52
|
+
const endIdx = last(linePoints).categoryIx + 1;
|
|
62
53
|
const pointOffset = this.seriesOptions[0]._outOfRangeMinPoint ? 1 : 0;
|
|
63
54
|
const stackPoints = [];
|
|
64
55
|
|
|
65
56
|
this._stackPoints = this._stackPoints || [];
|
|
66
57
|
for (let categoryIx = startIdx; categoryIx < endIdx; categoryIx++) {
|
|
67
|
-
const pointIx = categoryIx
|
|
58
|
+
const pointIx = categoryIx;
|
|
68
59
|
let currentSeriesIx = seriesIx;
|
|
69
|
-
let
|
|
60
|
+
let prevPoint;
|
|
61
|
+
let crossesSegment = false;
|
|
70
62
|
|
|
71
63
|
do {
|
|
72
64
|
currentSeriesIx--;
|
|
73
|
-
|
|
74
|
-
} while (currentSeriesIx > 0 && !point);
|
|
65
|
+
prevPoint = seriesPoints[currentSeriesIx][pointIx + pointOffset];
|
|
75
66
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
67
|
+
if (!prevPoint && this.hasSegmentForPoint(currentSeriesIx, categoryIx)) {
|
|
68
|
+
crossesSegment = true;
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
} while (currentSeriesIx > 0 && !prevPoint);
|
|
72
|
+
|
|
73
|
+
if (prevPoint) {
|
|
74
|
+
if (style !== STEP && categoryIx > startIdx) {
|
|
75
|
+
const crossesPrevSegment = this.hasSegmentForPoint(currentSeriesIx, pointIx - 1);
|
|
76
|
+
if (!crossesPrevSegment) {
|
|
77
|
+
// No previous point, close the gap with a point from the previous segment
|
|
78
|
+
stackPoints.push(this._previousSegmentPoint(categoryIx, pointIx, pointIx - 1, currentSeriesIx));
|
|
79
|
+
}
|
|
79
80
|
}
|
|
80
81
|
|
|
81
|
-
stackPoints.push(
|
|
82
|
+
stackPoints.push(prevPoint);
|
|
82
83
|
|
|
83
|
-
if (style !== STEP && categoryIx + 1 < endIdx
|
|
84
|
-
|
|
84
|
+
if (style !== STEP && categoryIx + 1 < endIdx) {
|
|
85
|
+
const crossesNextSegment = this.hasSegmentForPoint(currentSeriesIx, pointIx + 1);
|
|
86
|
+
if (!crossesNextSegment) {
|
|
87
|
+
// No next point, close the gap with a point from the previous segment
|
|
88
|
+
stackPoints.push(this._previousSegmentPoint(categoryIx, pointIx, pointIx + 1, currentSeriesIx));
|
|
89
|
+
}
|
|
85
90
|
}
|
|
86
|
-
} else {
|
|
91
|
+
} else if (!crossesSegment) {
|
|
92
|
+
// No previous point in the stack and does not cross a segment, add a gap point
|
|
87
93
|
const gapStackPoint = this._createGapStackPoint(categoryIx);
|
|
88
94
|
this._stackPoints.push(gapStackPoint);
|
|
89
95
|
stackPoints.push(gapStackPoint);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { geometry as geom } from '@progress/kendo-drawing';
|
|
2
1
|
import { CurveProcessor } from '../../core';
|
|
3
2
|
|
|
4
3
|
import AreaSegment from './area-segment';
|
|
@@ -12,20 +11,6 @@ class SplineAreaSegment extends AreaSegment {
|
|
|
12
11
|
return curveProcessor.process(linePoints);
|
|
13
12
|
}
|
|
14
13
|
|
|
15
|
-
createStackSegments() {
|
|
16
|
-
const strokeSegments = this.strokeSegments();
|
|
17
|
-
const stackSegments = [];
|
|
18
|
-
for (let idx = strokeSegments.length - 1; idx >= 0; idx--) {
|
|
19
|
-
const segment = strokeSegments[idx];
|
|
20
|
-
stackSegments.push(new geom.Segment(
|
|
21
|
-
segment.anchor(),
|
|
22
|
-
segment.controlOut(),
|
|
23
|
-
segment.controlIn()
|
|
24
|
-
));
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return stackSegments;
|
|
28
|
-
}
|
|
29
14
|
}
|
|
30
15
|
|
|
31
|
-
export default SplineAreaSegment;
|
|
16
|
+
export default SplineAreaSegment;
|
|
@@ -49,6 +49,18 @@ const LineChartMixin = {
|
|
|
49
49
|
segment.parent = this;
|
|
50
50
|
},
|
|
51
51
|
|
|
52
|
+
hasSegmentForPoint(seriesIx, pointIx) {
|
|
53
|
+
return this._segments.some(segment => {
|
|
54
|
+
if (segment.seriesIx !== seriesIx) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
const points = segment.linePoints;
|
|
58
|
+
const start = points[0].categoryIx;
|
|
59
|
+
const end = points[points.length - 1].categoryIx;
|
|
60
|
+
return pointIx >= start && pointIx <= end;
|
|
61
|
+
});
|
|
62
|
+
},
|
|
63
|
+
|
|
52
64
|
sortPoints: function(points) {
|
|
53
65
|
return points;
|
|
54
66
|
},
|
|
@@ -84,4 +96,4 @@ const LineChartMixin = {
|
|
|
84
96
|
}
|
|
85
97
|
};
|
|
86
98
|
|
|
87
|
-
export default LineChartMixin;
|
|
99
|
+
export default LineChartMixin;
|
|
@@ -153,7 +153,6 @@ class CurveProcessor {
|
|
|
153
153
|
controlPoints(p0, p1, p2) {
|
|
154
154
|
let xField = X;
|
|
155
155
|
let yField = Y;
|
|
156
|
-
let restrict = false;
|
|
157
156
|
let switchOrientation = false;
|
|
158
157
|
let tangent;
|
|
159
158
|
|
|
@@ -166,8 +165,11 @@ class CurveProcessor {
|
|
|
166
165
|
};
|
|
167
166
|
|
|
168
167
|
if (monotonic.x && monotonic.y) {
|
|
169
|
-
|
|
170
|
-
|
|
168
|
+
const h0 = p1[xField] - p0[xField];
|
|
169
|
+
const h1 = p2[xField] - p1[xField];
|
|
170
|
+
const d0 = (p1[yField] - p0[yField]) / h0;
|
|
171
|
+
const d1 = (p2[yField] - p1[yField]) / h1;
|
|
172
|
+
tangent = 3 * (h0 + h1) / ((2 * h1 + h0) / d0 + (h1 + 2 * h0) / d1);
|
|
171
173
|
} else {
|
|
172
174
|
if (this.invertAxis(p0, p1, p2)) {
|
|
173
175
|
xField = Y;
|
|
@@ -201,34 +203,9 @@ class CurveProcessor {
|
|
|
201
203
|
|
|
202
204
|
const firstControlPoint = this.firstControlPoint(tangent, p1, p2, xField, yField);
|
|
203
205
|
|
|
204
|
-
if (restrict) {
|
|
205
|
-
this.restrictControlPoint(p0, p1, secondControlPoint, tangent);
|
|
206
|
-
this.restrictControlPoint(p1, p2, firstControlPoint, tangent);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
206
|
return [ secondControlPoint, firstControlPoint ];
|
|
210
207
|
}
|
|
211
208
|
|
|
212
|
-
restrictControlPoint(p1, p2, cp, tangent) {
|
|
213
|
-
if (p1.y < p2.y) {
|
|
214
|
-
if (p2.y < cp.y) {
|
|
215
|
-
cp.x = p1.x + (p2.y - p1.y) / tangent;
|
|
216
|
-
cp.y = p2.y;
|
|
217
|
-
} else if (cp.y < p1.y) {
|
|
218
|
-
cp.x = p2.x - (p2.y - p1.y) / tangent;
|
|
219
|
-
cp.y = p1.y;
|
|
220
|
-
}
|
|
221
|
-
} else {
|
|
222
|
-
if (cp.y < p2.y) {
|
|
223
|
-
cp.x = p1.x - (p1.y - p2.y) / tangent;
|
|
224
|
-
cp.y = p2.y;
|
|
225
|
-
} else if (p1.y < cp.y) {
|
|
226
|
-
cp.x = p2.x + (p1.y - p2.y) / tangent;
|
|
227
|
-
cp.y = p1.y;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
|
|
232
209
|
tangent(p0, p1, xField, yField) {
|
|
233
210
|
const x = p1[xField] - p0[xField];
|
|
234
211
|
const y = p1[yField] - p0[yField];
|
|
@@ -287,4 +264,4 @@ function numberSign(value) {
|
|
|
287
264
|
return value <= 0 ? -1 : 1;
|
|
288
265
|
}
|
|
289
266
|
|
|
290
|
-
export default CurveProcessor;
|
|
267
|
+
export default CurveProcessor;
|