tvcharts 0.6.36 → 0.6.37
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.
|
@@ -87,6 +87,7 @@ var SymbolPath = /** @class */function (_super) {
|
|
|
87
87
|
path.beginPathFill();
|
|
88
88
|
symbolProxyShape.x = x - (needCenter ? width / 2 : 0) + xOffset;
|
|
89
89
|
symbolProxyShape.y = y - (needCenter ? height / 2 : 0) + yOffset;
|
|
90
|
+
// symbolProxyShape.y = y + yOffset;
|
|
90
91
|
symbolProxyShape.width = width;
|
|
91
92
|
symbolProxyShape.height = height;
|
|
92
93
|
symbolProxy.buildPath(path, __assign(__assign({}, symbolProxyShape), points[i].shape), true);
|
|
@@ -62,7 +62,13 @@ function getYByLocation(seriesModel) {
|
|
|
62
62
|
return Math.floor(location === 'top' ? end * boundaryGapX + 30 : end * (1 - boundaryGapY) + 30);
|
|
63
63
|
}
|
|
64
64
|
var labelSymbols = ['labelDown', 'labelUp', 'labelLeft', 'labelRight', 'labelLowerLeft', 'labelLowerRight', 'labelUpperLeft', 'labelUpperRight', 'labelCenter'];
|
|
65
|
+
var upSymbols = ['labelUp', 'labelUpperLeft', 'labelUpperRight'];
|
|
65
66
|
var labelSymbolByType = {};
|
|
67
|
+
var belowbarNotSymbol = {
|
|
68
|
+
labelLeft: 1,
|
|
69
|
+
labelRight: 1,
|
|
70
|
+
labelCenter: 1
|
|
71
|
+
};
|
|
66
72
|
each(labelSymbols, function (type) {
|
|
67
73
|
labelSymbolByType[type] = 1;
|
|
68
74
|
});
|
|
@@ -75,21 +81,23 @@ function changeLabelOffsetBySymbol(symbol, symbolRect, shape, oldOffset) {
|
|
|
75
81
|
case 'labelDown':
|
|
76
82
|
return [offsetX, offsetY - shape.triangleWidth];
|
|
77
83
|
case 'labelUp':
|
|
78
|
-
|
|
79
|
-
break;
|
|
84
|
+
return [offsetX, offsetY + shape.triangleWidth];
|
|
80
85
|
case 'labelLeft':
|
|
81
|
-
return [offsetX + shape.triangleWidth + symbolRect[0] / 2, offsetY];
|
|
86
|
+
return [offsetX + shape.triangleWidth + symbolRect[0] / 2, offsetY + symbolRect[1] / 2];
|
|
82
87
|
case 'labelRight':
|
|
83
|
-
return [offsetX - shape.triangleWidth - symbolRect[0] / 2, offsetY];
|
|
88
|
+
return [offsetX - shape.triangleWidth - symbolRect[0] / 2, offsetY + symbolRect[1] / 2];
|
|
84
89
|
case 'labelLowerLeft':
|
|
85
90
|
return [offsetX + shape.offsetX / 2 + symbolRect[0] / 2, offsetY - shape.offsetY];
|
|
86
91
|
case 'labelLowerRight':
|
|
87
92
|
return [offsetX - shape.offsetX - symbolRect[0] / 2, offsetY - shape.offsetY];
|
|
88
93
|
case 'labelUpperLeft':
|
|
89
|
-
return [offsetX + shape.offsetX + symbolRect[0] / 2, offsetY + shape.
|
|
94
|
+
return [offsetX + shape.offsetX + symbolRect[0] / 2, offsetY + shape.offsetY];
|
|
90
95
|
case 'labelUpperRight':
|
|
91
|
-
return [offsetX - shape.offsetX - symbolRect[0] / 2, offsetY];
|
|
96
|
+
return [offsetX - shape.offsetX - symbolRect[0] / 2, offsetY + shape.offsetY];
|
|
97
|
+
// case 'labelCenter':
|
|
98
|
+
// return [offsetX, offsetY + symbolRect[1]];
|
|
92
99
|
}
|
|
100
|
+
|
|
93
101
|
return oldOffset;
|
|
94
102
|
}
|
|
95
103
|
var labelsLayout = {
|
|
@@ -136,6 +144,7 @@ var labelsLayout = {
|
|
|
136
144
|
continue;
|
|
137
145
|
}
|
|
138
146
|
var itemModel = data.getItemModel(i);
|
|
147
|
+
var yloc = itemModel.get('yloc');
|
|
139
148
|
var symbol = itemModel.getShallow('symbol');
|
|
140
149
|
var symbolSize = itemModel.getShallow('symbolSize');
|
|
141
150
|
// let symbolRotate = itemModel.getShallow('symbolRotate');
|
|
@@ -148,19 +157,23 @@ var labelsLayout = {
|
|
|
148
157
|
var size = (_a = itemModel.get('size')) !== null && _a !== void 0 ? _a : 'normal';
|
|
149
158
|
var text = labelModel.get('formatter');
|
|
150
159
|
var isLabel = labelSymbolByType[symbol];
|
|
151
|
-
var
|
|
160
|
+
var textShow = labelModel.get('show');
|
|
152
161
|
var fontSize = labelModel.getShallow('fontSize');
|
|
153
|
-
var position = 'top';
|
|
154
|
-
|
|
162
|
+
var position = labelModel.get('position') || 'top';
|
|
163
|
+
// const isBelowbar = yloc === 'belowbar';
|
|
164
|
+
// if (isBelowbar) {
|
|
165
|
+
// position = 'bottom';
|
|
166
|
+
// }
|
|
167
|
+
if (location === 'top' || location === 'belowbar') {
|
|
155
168
|
position = 'bottom';
|
|
156
|
-
} else {
|
|
157
|
-
position =
|
|
169
|
+
} else if (isLabel || symbol === 'textOutline') {
|
|
170
|
+
position = 'inside';
|
|
158
171
|
}
|
|
159
|
-
if (
|
|
172
|
+
if (textShow) {
|
|
160
173
|
labelModel.option.fontSize = fontSize = getSymbolLabelFontSize(size, bandWidth);
|
|
161
174
|
}
|
|
162
175
|
var textRect = void 0;
|
|
163
|
-
if (
|
|
176
|
+
if (textShow) {
|
|
164
177
|
textRect = labelModel.getTextRect(text);
|
|
165
178
|
if (isLabel) {
|
|
166
179
|
symbolSize = [textRect.width + padding, textRect.height + padding];
|
|
@@ -177,17 +190,25 @@ var labelsLayout = {
|
|
|
177
190
|
w = _b.w,
|
|
178
191
|
h = _b.h,
|
|
179
192
|
shape = _b.shape;
|
|
180
|
-
if (isLabel ? !
|
|
193
|
+
if (isLabel ? !textShow || !text : true) {
|
|
181
194
|
symbolSize = [w, h];
|
|
182
195
|
}
|
|
183
196
|
var symbolRect = Array.isArray(symbolSize) ? symbolSize : [symbolSize, symbolSize];
|
|
184
197
|
if (shape) {
|
|
185
198
|
symbolShape = shape;
|
|
186
|
-
if (
|
|
199
|
+
if (textShow) {
|
|
187
200
|
oldOffset = changeLabelOffsetBySymbol(symbol, symbolRect, shape, oldOffset);
|
|
188
201
|
}
|
|
189
202
|
}
|
|
190
203
|
var symbolPoint = [point[0], price || point[1]];
|
|
204
|
+
// y轴位置靠下时
|
|
205
|
+
if ((yloc === 'belowbar' || yloc === 'price') && upSymbols.includes(symbol)) {
|
|
206
|
+
symbolPoint[1] = symbolPoint[1] + symbolRect[1];
|
|
207
|
+
}
|
|
208
|
+
// 为居中label时特殊处理
|
|
209
|
+
if (symbol === 'labelCenter') {
|
|
210
|
+
symbolPoint[1] = symbolPoint[1] + symbolRect[1] / 2;
|
|
211
|
+
}
|
|
191
212
|
if (symbol !== 'none' && style.fill) {
|
|
192
213
|
var symbolStyles = symbolStyleMap[symbol] || [];
|
|
193
214
|
symbolStyles.push({
|
|
@@ -199,14 +220,14 @@ var labelsLayout = {
|
|
|
199
220
|
});
|
|
200
221
|
symbolStyleMap[symbol] = symbolStyles;
|
|
201
222
|
}
|
|
202
|
-
if (
|
|
223
|
+
if (textShow) {
|
|
203
224
|
var labelPoint = __spreadArray([], symbolPoint, true);
|
|
204
225
|
if (position === 'inside') {
|
|
205
226
|
labelPoint[1] = labelPoint[1] - textRect.height / 2 - symbolRect[1] / 2;
|
|
206
227
|
} else if (position === 'top') {
|
|
207
228
|
labelPoint[1] = labelPoint[1] - symbolRect[1] - textRect.height / 2 - 10;
|
|
208
229
|
} else {
|
|
209
|
-
labelPoint[1] = labelPoint[1] + 10;
|
|
230
|
+
labelPoint[1] = labelPoint[1] + symbolRect[1] - textRect.height / 2 + 10;
|
|
210
231
|
}
|
|
211
232
|
textList.push({
|
|
212
233
|
text: text,
|
package/lib/util/symbol.js
CHANGED
|
@@ -758,7 +758,7 @@ var symbolShapeMakers = {
|
|
|
758
758
|
var offset = 1;
|
|
759
759
|
shape.x = x - w / 2 + offset;
|
|
760
760
|
shape.triangleWidth = parentShape.triangleWidth;
|
|
761
|
-
shape.y = y - h;
|
|
761
|
+
shape.y = y - h + parentShape.triangleWidth;
|
|
762
762
|
shape.width = w;
|
|
763
763
|
shape.height = h;
|
|
764
764
|
shape.r = r;
|
|
@@ -768,7 +768,7 @@ var symbolShapeMakers = {
|
|
|
768
768
|
var r = 2;
|
|
769
769
|
shape.triangleWidth = triangleWidth;
|
|
770
770
|
shape.x = x + triangleWidth;
|
|
771
|
-
shape.y = y - h;
|
|
771
|
+
shape.y = y - h / 2;
|
|
772
772
|
shape.width = w;
|
|
773
773
|
shape.height = h;
|
|
774
774
|
shape.r = r;
|
|
@@ -778,7 +778,7 @@ var symbolShapeMakers = {
|
|
|
778
778
|
var r = 2;
|
|
779
779
|
shape.triangleWidth = triangleWidth;
|
|
780
780
|
shape.x = x - w - triangleWidth;
|
|
781
|
-
shape.y = y - h;
|
|
781
|
+
shape.y = y - h / 2;
|
|
782
782
|
shape.width = w;
|
|
783
783
|
shape.height = h;
|
|
784
784
|
shape.r = r;
|
|
@@ -815,7 +815,7 @@ var symbolShapeMakers = {
|
|
|
815
815
|
var offsetX = parentShape.offsetX;
|
|
816
816
|
var offsetWidth = parentShape.offsetWidth;
|
|
817
817
|
shape.x = x + offsetX;
|
|
818
|
-
shape.y = y - h
|
|
818
|
+
shape.y = y - h + parentShape.offsetY;
|
|
819
819
|
shape.width = w;
|
|
820
820
|
shape.height = h;
|
|
821
821
|
shape.r = 2;
|
|
@@ -828,7 +828,7 @@ var symbolShapeMakers = {
|
|
|
828
828
|
var offsetX = parentShape.offsetX;
|
|
829
829
|
var offsetWidth = parentShape.offsetWidth;
|
|
830
830
|
shape.x = x - w - offsetX;
|
|
831
|
-
shape.y = y - h;
|
|
831
|
+
shape.y = y - h + parentShape.offsetY;
|
|
832
832
|
shape.width = w;
|
|
833
833
|
shape.height = h;
|
|
834
834
|
shape.r = 2;
|
package/lib/util/symbolSize.js
CHANGED
|
@@ -56,8 +56,8 @@ var xCrossMapping = {
|
|
|
56
56
|
},
|
|
57
57
|
auto: function (width) {
|
|
58
58
|
return {
|
|
59
|
-
w: width,
|
|
60
|
-
h: width
|
|
59
|
+
w: width * 0.7,
|
|
60
|
+
h: width * 0.7
|
|
61
61
|
};
|
|
62
62
|
}
|
|
63
63
|
};
|
|
@@ -94,8 +94,8 @@ var lCrossMapping = {
|
|
|
94
94
|
},
|
|
95
95
|
auto: function (width) {
|
|
96
96
|
return {
|
|
97
|
-
w: width,
|
|
98
|
-
h: width
|
|
97
|
+
w: width * 0.7,
|
|
98
|
+
h: width * 0.7
|
|
99
99
|
};
|
|
100
100
|
}
|
|
101
101
|
};
|
|
@@ -373,8 +373,8 @@ var rectMapping = {
|
|
|
373
373
|
},
|
|
374
374
|
auto: function (width) {
|
|
375
375
|
return {
|
|
376
|
-
w: width,
|
|
377
|
-
h: width
|
|
376
|
+
w: width * 0.7,
|
|
377
|
+
h: width * 0.7
|
|
378
378
|
};
|
|
379
379
|
}
|
|
380
380
|
};
|
|
@@ -471,7 +471,7 @@ var labelFontSizeMapping = {
|
|
|
471
471
|
};
|
|
472
472
|
function getSymbolLabelFontSize(size, width) {
|
|
473
473
|
var _a;
|
|
474
|
-
if (size ===
|
|
474
|
+
if (size === 'auto' && width) {
|
|
475
475
|
return Math.max(6, width / 2);
|
|
476
476
|
}
|
|
477
477
|
return (_a = labelFontSizeMapping[size]) !== null && _a !== void 0 ? _a : 12;
|
package/package.json
CHANGED
|
@@ -18,6 +18,7 @@ interface LabelsStatesOptionMixin {
|
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
20
|
export interface LabelsDataItemOption extends SymbolOptionMixin, LabelsStateOption, StatesOptionMixin<LabelsStateOption, LabelsStatesOptionMixin>, OptionDataItemObject<OptionDataValue> {
|
|
21
|
+
yloc?: 'abovebar' | 'price' | 'belowbar';
|
|
21
22
|
}
|
|
22
23
|
export interface LabelsSeriesOption extends SeriesOption<LabelsStateOption<CallbackDataParams>, LabelsStatesOptionMixin>, LabelsStateOption<CallbackDataParams>, SeriesOnCartesianOptionMixin, SeriesOnPolarOptionMixin, SeriesOnCalendarOptionMixin, SeriesOnGeoOptionMixin, SeriesOnSingleOptionMixin, SeriesLargeOptionMixin, SeriesStackOptionMixin, SymbolOptionMixin<CallbackDataParams>, SeriesEncodeOptionMixin {
|
|
23
24
|
type?: 'labels';
|