tvcharts 0.9.40 → 0.9.42
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/lib/chart/barPlot/BarPath.js +27 -17
- package/lib/chart/barPlot/BarPlotSeries.js +1 -0
- package/lib/chart/barPlot/BarPlotView.js +15 -5
- package/lib/chart/barPlot/barPlotLayout.js +56 -24
- package/lib/chart/candlePlot/candlePlotLayout.js +1 -1
- package/lib/chart/labels/LabelsView.js +1 -0
- package/lib/component/alarm/AlarmView.js +3 -0
- package/package.json +2 -2
- package/types/dist/echarts.d.ts +1 -1
- package/types/dist/shared.d.ts +1 -1
- package/types/src/chart/barPlot/BarPath.d.ts +4 -1
- package/types/src/chart/barPlot/BarPlotSeries.d.ts +3 -0
|
@@ -40,30 +40,40 @@ var BarPath = /** @class */function (_super) {
|
|
|
40
40
|
return new BarPathShape();
|
|
41
41
|
};
|
|
42
42
|
BarPath.prototype.buildPath = function (ctx, shape) {
|
|
43
|
-
var
|
|
43
|
+
var typeArray = shape.typeArray,
|
|
44
44
|
isSimpleBox = shape.isSimpleBox,
|
|
45
45
|
candleWidth = shape.candleWidth,
|
|
46
46
|
isWebviewRender = shape.isWebviewRender,
|
|
47
|
-
stroke = shape.stroke
|
|
47
|
+
stroke = shape.stroke,
|
|
48
|
+
ishlc = shape.ishlc,
|
|
49
|
+
_a = shape.offset,
|
|
50
|
+
offset = _a === void 0 ? 0 : _a;
|
|
51
|
+
var points = typeArray.buffer();
|
|
52
|
+
var len = typeArray.length();
|
|
48
53
|
var width = Math.floor(candleWidth / 2) + 0.5;
|
|
49
|
-
for (var
|
|
50
|
-
var
|
|
51
|
-
var
|
|
52
|
-
var
|
|
53
|
-
var
|
|
54
|
+
for (var i = 0; i < len;) {
|
|
55
|
+
var x1 = points[i++] + offset;
|
|
56
|
+
var y1 = points[i++];
|
|
57
|
+
var x2 = points[i++] + offset;
|
|
58
|
+
var y2 = points[i++];
|
|
59
|
+
var x3 = points[i++];
|
|
60
|
+
var y3 = points[i++];
|
|
61
|
+
var x4 = points[i++];
|
|
62
|
+
var y4 = points[i++];
|
|
54
63
|
if (isSimpleBox) {
|
|
55
|
-
|
|
56
|
-
ctx.
|
|
57
|
-
ctx.lineTo(x, point4[1]);
|
|
64
|
+
ctx.moveTo(x3, y3);
|
|
65
|
+
ctx.lineTo(x3, y4);
|
|
58
66
|
} else {
|
|
59
|
-
ctx.moveTo(
|
|
60
|
-
ctx.lineTo(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
67
|
+
ctx.moveTo(x3, y3);
|
|
68
|
+
ctx.lineTo(x4, y4);
|
|
69
|
+
if (!ishlc) {
|
|
70
|
+
ctx.moveTo(x1, y1);
|
|
71
|
+
ctx.lineTo(x1 - width, y1);
|
|
72
|
+
}
|
|
73
|
+
ctx.moveTo(x2, y2);
|
|
74
|
+
ctx.lineTo(x2 + width, y2);
|
|
65
75
|
}
|
|
66
|
-
if (isWebviewRender &&
|
|
76
|
+
if (isWebviewRender && i % (8 * 5) === 0 && stroke) {
|
|
67
77
|
ctx.strokeStyle(stroke);
|
|
68
78
|
ctx.beginPathFill();
|
|
69
79
|
}
|
|
@@ -42,7 +42,6 @@
|
|
|
42
42
|
* under the License.
|
|
43
43
|
*/
|
|
44
44
|
import { __extends } from "tslib";
|
|
45
|
-
import * as zrUtil from 'tvrender/lib/core/util.js';
|
|
46
45
|
import ChartView from '../../view/Chart.js';
|
|
47
46
|
import * as graphic from '../../util/graphic.js';
|
|
48
47
|
import { createClipPath } from '../helper/createClipPathFromCoordSys.js';
|
|
@@ -78,19 +77,30 @@ var BarPlotView = /** @class */function (_super) {
|
|
|
78
77
|
var emphasisState = seriesModel.get('emphasis').emphasisState;
|
|
79
78
|
var groupId = seriesModel.get('groupId');
|
|
80
79
|
var isMobile = seriesModel.get('isMobile');
|
|
80
|
+
var ishlc = seriesModel.get('ishlc');
|
|
81
|
+
var isSmall = seriesModel.get('isSmall');
|
|
82
|
+
var lineWidth = 1;
|
|
83
|
+
if (!isSmall) {
|
|
84
|
+
var barWidth = Math.max(1, Math.floor(candleWidth / 3));
|
|
85
|
+
lineWidth = barWidth % 2 === 0 ? barWidth - 1 : barWidth;
|
|
86
|
+
}
|
|
87
|
+
var offset = Math.floor(lineWidth / 2);
|
|
81
88
|
var bodyPointsByColor = data.getLayout('bodyPointsByColor');
|
|
82
|
-
|
|
89
|
+
bodyPointsByColor.forEach(function (typeArray, stroke) {
|
|
83
90
|
var el = new BarPath({
|
|
84
91
|
shape: {
|
|
85
|
-
|
|
92
|
+
typeArray: typeArray,
|
|
86
93
|
isSimpleBox: isSimpleBox,
|
|
87
94
|
candleWidth: candleWidth,
|
|
88
95
|
stroke: stroke,
|
|
89
|
-
isWebviewRender: isMobile
|
|
96
|
+
isWebviewRender: isMobile,
|
|
97
|
+
ishlc: ishlc,
|
|
98
|
+
offset: offset
|
|
90
99
|
},
|
|
91
100
|
style: {
|
|
92
101
|
stroke: stroke,
|
|
93
|
-
fill: 'none'
|
|
102
|
+
fill: 'none',
|
|
103
|
+
lineWidth: lineWidth
|
|
94
104
|
}
|
|
95
105
|
});
|
|
96
106
|
el.states.emphasis = emphasisState;
|
|
@@ -43,10 +43,11 @@
|
|
|
43
43
|
*/
|
|
44
44
|
import createRenderPlanner from '../helper/createRenderPlanner.js';
|
|
45
45
|
import { map } from 'tvrender/lib/core/util.js';
|
|
46
|
+
import { DynamicTypedArray } from '../../util/DynamicTypedArray.js';
|
|
46
47
|
var positiveColorQuery = ['itemStyle', 'color'];
|
|
47
48
|
var negativeColorQuery = ['itemStyle', 'color0'];
|
|
48
49
|
function getColor(sign, model) {
|
|
49
|
-
return model.get(sign > 0 ? positiveColorQuery : negativeColorQuery
|
|
50
|
+
return model.get(sign > 0 ? positiveColorQuery : negativeColorQuery);
|
|
50
51
|
}
|
|
51
52
|
var barPlotLayout = {
|
|
52
53
|
seriesType: 'barPlot',
|
|
@@ -70,13 +71,14 @@ var barPlotLayout = {
|
|
|
70
71
|
}
|
|
71
72
|
var showLast = seriesModel.get('showLast');
|
|
72
73
|
// const xOffset = seriesModel.get('offset') || 0;
|
|
74
|
+
var signByPrev = seriesModel.get('signByPrev');
|
|
73
75
|
return {
|
|
74
76
|
progress: normalProgress
|
|
75
77
|
};
|
|
76
78
|
function normalProgress(params, data) {
|
|
77
79
|
var dataIndex;
|
|
78
80
|
var store = data.getStore();
|
|
79
|
-
var bodyPointsByColor =
|
|
81
|
+
var bodyPointsByColor = new Map();
|
|
80
82
|
var lastIndex = data.count(true) - 1;
|
|
81
83
|
while ((dataIndex = params.next()) != null) {
|
|
82
84
|
if (showLast && lastIndex - data.getRawIndex(dataIndex) >= showLast) {
|
|
@@ -87,17 +89,35 @@ var barPlotLayout = {
|
|
|
87
89
|
var closeVal = store.get(closeDimI, dataIndex);
|
|
88
90
|
var lowestVal = store.get(lowestDimI, dataIndex);
|
|
89
91
|
var highestVal = store.get(highestDimI, dataIndex);
|
|
90
|
-
var
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
var
|
|
92
|
+
var _a = resolvePoint(openVal, axisDimVal, 0.5),
|
|
93
|
+
ocLowX = _a[0],
|
|
94
|
+
ocLowY = _a[1];
|
|
95
|
+
var _b = resolvePoint(closeVal, axisDimVal, 0.5),
|
|
96
|
+
ocHighX = _b[0],
|
|
97
|
+
ocHighY = _b[1];
|
|
98
|
+
var _c = resolvePoint(lowestVal, axisDimVal),
|
|
99
|
+
lowestX = _c[0],
|
|
100
|
+
lowestY = _c[1];
|
|
101
|
+
var _d = resolvePoint(highestVal, axisDimVal),
|
|
102
|
+
highestX = _d[0],
|
|
103
|
+
highestY = _d[1];
|
|
94
104
|
var itemModel = data.getItemModel(dataIndex);
|
|
95
|
-
var sign = getSign(store, dataIndex, openVal, closeVal, closeDimI);
|
|
105
|
+
var sign = getSign(store, dataIndex, openVal, closeVal, closeDimI, signByPrev);
|
|
96
106
|
var key = getColor(sign, itemModel);
|
|
97
107
|
if (key) {
|
|
98
|
-
var bodyPoints = bodyPointsByColor
|
|
99
|
-
bodyPoints
|
|
100
|
-
|
|
108
|
+
var bodyPoints = bodyPointsByColor.get(key);
|
|
109
|
+
if (!bodyPoints) {
|
|
110
|
+
bodyPoints = new DynamicTypedArray();
|
|
111
|
+
bodyPointsByColor.set(key, bodyPoints);
|
|
112
|
+
}
|
|
113
|
+
bodyPoints.push(ocLowX);
|
|
114
|
+
bodyPoints.push(ocLowY);
|
|
115
|
+
bodyPoints.push(ocHighX);
|
|
116
|
+
bodyPoints.push(ocHighY);
|
|
117
|
+
bodyPoints.push(lowestX);
|
|
118
|
+
bodyPoints.push(lowestY);
|
|
119
|
+
bodyPoints.push(highestX);
|
|
120
|
+
bodyPoints.push(highestY);
|
|
101
121
|
}
|
|
102
122
|
}
|
|
103
123
|
data.setLayout({
|
|
@@ -105,21 +125,18 @@ var barPlotLayout = {
|
|
|
105
125
|
bodyPointsByColor: bodyPointsByColor,
|
|
106
126
|
isSimpleBox: isSimpleBox
|
|
107
127
|
});
|
|
108
|
-
function
|
|
128
|
+
function resolvePoint(val, axisDimVal, yOffset) {
|
|
109
129
|
if (yOffset === void 0) {
|
|
110
130
|
yOffset = 0;
|
|
111
131
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
p[vDimIdx] = val;
|
|
115
|
-
var points = isNaN(axisDimVal) || isNaN(val) ? [NaN, NaN] : coordSys.dataToPoint(p);
|
|
116
|
-
if (!isNaN(points[0])) {
|
|
117
|
-
points[0] = points[0] + 0.5;
|
|
132
|
+
if (isNaN(axisDimVal) || isNaN(val)) {
|
|
133
|
+
return [NaN, NaN];
|
|
118
134
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
135
|
+
var p = [axisDimVal, val];
|
|
136
|
+
var point = coordSys.dataToPoint(p);
|
|
137
|
+
var x = isNaN(point[0]) ? point[0] : point[0] + 0.5;
|
|
138
|
+
var y = isNaN(point[1]) ? point[1] : Math.floor(point[1]) + yOffset;
|
|
139
|
+
return [x, y];
|
|
123
140
|
}
|
|
124
141
|
}
|
|
125
142
|
}
|
|
@@ -131,11 +148,15 @@ var barPlotLayout = {
|
|
|
131
148
|
* 1 for positive,
|
|
132
149
|
* -1 for negative.
|
|
133
150
|
*/
|
|
134
|
-
function getSign(store, dataIndex, openVal, closeVal, closeDimI) {
|
|
151
|
+
function getSign(store, dataIndex, openVal, closeVal, closeDimI, signByPrev) {
|
|
135
152
|
var sign;
|
|
153
|
+
if (signByPrev) {
|
|
154
|
+
var index = store.getRawIndex(dataIndex);
|
|
155
|
+
if (index > 0) return store.getByRawIndex(closeDimI, index - 1) <= closeVal ? 1 : -1;
|
|
156
|
+
}
|
|
136
157
|
if (openVal > closeVal) {
|
|
137
158
|
sign = -1;
|
|
138
|
-
} else {
|
|
159
|
+
} else if (openVal <= closeVal) {
|
|
139
160
|
sign = 1;
|
|
140
161
|
}
|
|
141
162
|
return sign;
|
|
@@ -144,6 +165,17 @@ function calculateCandleWidth(seriesModel, data) {
|
|
|
144
165
|
var baseAxis = seriesModel.getBaseAxis();
|
|
145
166
|
var extent;
|
|
146
167
|
var bandWidth = baseAxis.type === 'category' ? baseAxis.getBandWidth() : (extent = baseAxis.getExtent(), Math.abs(extent[1] - extent[0]) / data.count());
|
|
147
|
-
|
|
168
|
+
var width = optimalCandlestickWidth(bandWidth, 1);
|
|
169
|
+
return width >= 2 && width % 2 === 1 ? width - 1 : width;
|
|
170
|
+
// return Math.floor(Math.max(bandWidth * 0.7, 1));
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function optimalCandlestickWidth(barSpacing, pixelRatio) {
|
|
174
|
+
if (barSpacing >= 2.5 && barSpacing <= 4) return Math.floor(3 * pixelRatio) - 1;
|
|
175
|
+
var n = 0.9 * Math.atan(Math.max(4, barSpacing) - 4) / (.5 * Math.PI),
|
|
176
|
+
i = Math.floor(barSpacing * n * pixelRatio),
|
|
177
|
+
s = Math.floor(barSpacing * pixelRatio),
|
|
178
|
+
r = Math.min(i, s - 1, Math.round(barSpacing - 2));
|
|
179
|
+
return Math.max(Math.floor(pixelRatio), r);
|
|
148
180
|
}
|
|
149
181
|
export default barPlotLayout;
|
|
@@ -229,7 +229,7 @@ function optimalCandlestickWidth(barSpacing, pixelRatio) {
|
|
|
229
229
|
var n = 1 - .2 * Math.atan(Math.max(4, barSpacing) - 4) / (.5 * Math.PI),
|
|
230
230
|
i = Math.floor(barSpacing * n * pixelRatio),
|
|
231
231
|
s = Math.floor(barSpacing * pixelRatio),
|
|
232
|
-
r = Math.min(i, s - 1);
|
|
232
|
+
r = Math.min(i, s - 1, Math.round(barSpacing - 2));
|
|
233
233
|
return Math.max(Math.floor(pixelRatio), r);
|
|
234
234
|
}
|
|
235
235
|
// function optimalCandlestickWidth(barSpacing: number, pixelRatio: number): number {
|
|
@@ -310,6 +310,7 @@ var LabelsView = /** @class */function (_super) {
|
|
|
310
310
|
this._textGroup = null;
|
|
311
311
|
this._toolTipGroup && this._toolTipGroup.removeAll();
|
|
312
312
|
this._toolTipGroup = null;
|
|
313
|
+
this._clearTimer();
|
|
313
314
|
if (this.api) {
|
|
314
315
|
(_a = this.api.getZr()) === null || _a === void 0 ? void 0 : _a.off('mousedown', this._hideTip);
|
|
315
316
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tvcharts",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.42",
|
|
4
4
|
"main": "dist/echarts.js",
|
|
5
5
|
"module": "index.js",
|
|
6
6
|
"jsdelivr": "dist/echarts.min.js",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"tslib": "2.3.0",
|
|
46
|
-
"tvrender": "^5.6.
|
|
46
|
+
"tvrender": "^5.6.98"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@babel/code-frame": "7.10.4",
|
package/types/dist/echarts.d.ts
CHANGED
|
@@ -1229,7 +1229,7 @@ declare type ElementSSRData = HashMap<unknown>;
|
|
|
1229
1229
|
declare type ElementSSRDataGetter<T> = (el: Element) => HashMap<T>;
|
|
1230
1230
|
declare function getElementSSRData(el: Element): ElementSSRData;
|
|
1231
1231
|
declare function registerSSRDataGetter<T>(getter: ElementSSRDataGetter<T>): void;
|
|
1232
|
-
declare const version = "5.6.
|
|
1232
|
+
declare const version = "5.6.98";
|
|
1233
1233
|
interface ZRenderType extends ZRender {
|
|
1234
1234
|
}
|
|
1235
1235
|
|
package/types/dist/shared.d.ts
CHANGED
|
@@ -1229,7 +1229,7 @@ declare type ElementSSRData = HashMap<unknown>;
|
|
|
1229
1229
|
declare type ElementSSRDataGetter<T> = (el: Element) => HashMap<T>;
|
|
1230
1230
|
declare function getElementSSRData(el: Element): ElementSSRData;
|
|
1231
1231
|
declare function registerSSRDataGetter<T>(getter: ElementSSRDataGetter<T>): void;
|
|
1232
|
-
declare const version = "5.6.
|
|
1232
|
+
declare const version = "5.6.98";
|
|
1233
1233
|
interface ZRenderType extends ZRender {
|
|
1234
1234
|
}
|
|
1235
1235
|
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import Path, { PathProps } from 'tvrender/lib/graphic/Path.js';
|
|
2
2
|
import PathProxy from 'tvrender/lib/core/PathProxy.js';
|
|
3
|
+
import { DynamicTypedArray } from '../../util/DynamicTypedArray.js';
|
|
3
4
|
declare class BarPathShape {
|
|
4
|
-
|
|
5
|
+
typeArray: DynamicTypedArray;
|
|
5
6
|
isSimpleBox: boolean;
|
|
6
7
|
candleWidth: number;
|
|
7
8
|
stroke?: string;
|
|
8
9
|
isWebviewRender?: boolean;
|
|
10
|
+
ishlc?: boolean;
|
|
11
|
+
offset?: number;
|
|
9
12
|
}
|
|
10
13
|
interface BarPathProps extends PathProps {
|
|
11
14
|
shape?: Partial<BarPathShape>;
|
|
@@ -23,6 +23,9 @@ interface ExtraStateOption {
|
|
|
23
23
|
export interface BarPlotSeriesOption extends SeriesOption<BarPlotStateOption, ExtraStateOption>, BarPlotStateOption, SeriesOnCartesianOptionMixin, SeriesLargeOptionMixin, SeriesEncodeOptionMixin {
|
|
24
24
|
type?: 'barPlot';
|
|
25
25
|
coordinateSystem?: 'cartesian2d';
|
|
26
|
+
signByPrev?: boolean;
|
|
27
|
+
isSmall?: boolean;
|
|
28
|
+
ishlc?: boolean;
|
|
26
29
|
layout?: LayoutOrient;
|
|
27
30
|
clip?: boolean;
|
|
28
31
|
barMaxWidth?: number | string;
|