tvcharts 0.6.11 → 0.6.13

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.
Files changed (36) hide show
  1. package/dist/echarts.js +868 -114
  2. package/dist/echarts.js.map +3 -3
  3. package/index.js +2 -2
  4. package/lib/chart/bgColor/BgColorView.js +4 -1
  5. package/lib/chart/helper/Symbol.js +55 -12
  6. package/lib/chart/helper/SymbolDraw.js +2 -1
  7. package/lib/chart/labels/LabelsSeries.js +109 -0
  8. package/lib/chart/labels/LabelsView.js +133 -0
  9. package/lib/chart/labels/install.js +55 -0
  10. package/lib/chart/labels/labelsVisual.js +128 -0
  11. package/lib/chart/labels.js +46 -0
  12. package/lib/chart/linesPlot/LinesPlotSeries.js +2 -26
  13. package/lib/chart/linesPlot/LinesPlotView.js +52 -34
  14. package/lib/chart/linesPlot/SymbolPath.js +88 -0
  15. package/lib/chart/linesPlot/linesPlotLayout.js +58 -32
  16. package/lib/chart/scatter/ScatterView.js +2 -1
  17. package/lib/export/charts.js +1 -0
  18. package/lib/model/Global.js +1 -0
  19. package/lib/util/symbol.js +597 -1
  20. package/package.json +1 -1
  21. package/types/dist/charts.d.ts +1 -1
  22. package/types/dist/components.d.ts +1 -1
  23. package/types/dist/echarts.d.ts +5 -6
  24. package/types/dist/renderers.d.ts +1 -1
  25. package/types/dist/shared.d.ts +11 -10
  26. package/types/src/chart/helper/Symbol.d.ts +1 -0
  27. package/types/src/chart/helper/SymbolDraw.d.ts +1 -0
  28. package/types/src/chart/labels/LabelsSeries.d.ts +37 -0
  29. package/types/src/chart/labels/LabelsView.d.ts +28 -0
  30. package/types/src/chart/labels/install.d.ts +2 -0
  31. package/types/src/chart/labels/labelsVisual.d.ts +3 -0
  32. package/types/src/chart/labels.d.ts +1 -0
  33. package/types/src/chart/linesPlot/LinesPlotSeries.d.ts +6 -7
  34. package/types/src/chart/linesPlot/SymbolPath.d.ts +24 -0
  35. package/types/src/chart/linesPlot/linesPlotLayout.d.ts +1 -1
  36. package/types/src/export/charts.d.ts +1 -0
package/index.js CHANGED
@@ -51,7 +51,7 @@ export * from './lib/export/core.js';
51
51
  // not included in this list.
52
52
  // ----------------------------------------------
53
53
  import { SVGRenderer, CanvasRenderer } from './lib/export/renderers.js';
54
- import { LineChart, BarChart, PieChart, ScatterChart, RadarChart, MapChart, TreeChart, TreemapChart, GraphChart, GaugeChart, FunnelChart, ParallelChart, SankeyChart, BoxplotChart, CandlestickChart, EffectScatterChart, LinesChart, LinesPlotChart, HLinesChart, BgColorChart, HeatmapChart, PictorialBarChart, ThemeRiverChart, SunburstChart, CustomChart } from './lib/export/charts.js';
54
+ import { LineChart, BarChart, PieChart, ScatterChart, RadarChart, MapChart, TreeChart, TreemapChart, GraphChart, GaugeChart, FunnelChart, ParallelChart, SankeyChart, BoxplotChart, CandlestickChart, EffectScatterChart, LinesChart, LinesPlotChart, LabelsChart, HLinesChart, BgColorChart, HeatmapChart, PictorialBarChart, ThemeRiverChart, SunburstChart, CustomChart } from './lib/export/charts.js';
55
55
  import { GridComponent, PolarComponent, GeoComponent, SingleAxisComponent, ParallelComponent, CalendarComponent, GraphicComponent, ToolboxComponent, TooltipComponent, AxisPointerComponent, BrushComponent, TitleComponent, TimelineComponent, MarkPointComponent, MarkLineComponent, MarkAreaComponent, MarkLabelComponent, LegendComponent, DataZoomComponent, DataZoomInsideComponent, DataZoomSliderComponent, VisualMapComponent, VisualMapContinuousComponent, VisualMapPiecewiseComponent, AriaComponent, DatasetComponent, TransformComponent } from './lib/export/components.js';
56
56
  import { UniversalTransition, LabelLayout } from './lib/export/features.js';
57
57
  // -----------------
@@ -72,7 +72,7 @@ use([SVGRenderer]);
72
72
  // type: 'line' // or 'bar', 'pie', ...
73
73
  // }]
74
74
  // });
75
- use([LineChart, BarChart, PieChart, ScatterChart, RadarChart, MapChart, TreeChart, TreemapChart, GraphChart, GaugeChart, FunnelChart, ParallelChart, SankeyChart, BoxplotChart, CandlestickChart, EffectScatterChart, LinesChart, LinesPlotChart, HLinesChart, BgColorChart, HeatmapChart, PictorialBarChart, ThemeRiverChart, SunburstChart, CustomChart]);
75
+ use([LineChart, BarChart, PieChart, ScatterChart, RadarChart, MapChart, TreeChart, TreemapChart, GraphChart, GaugeChart, FunnelChart, ParallelChart, SankeyChart, BoxplotChart, CandlestickChart, EffectScatterChart, LinesChart, LinesPlotChart, LabelsChart, HLinesChart, BgColorChart, HeatmapChart, PictorialBarChart, ThemeRiverChart, SunburstChart, CustomChart]);
76
76
  // -------------------
77
77
  // Coordinate systems
78
78
  // -------------------
@@ -96,7 +96,10 @@ var BgColorView = /** @class */function (_super) {
96
96
  graphic.traverseElements(this._bgColorGroup, cb);
97
97
  };
98
98
  BgColorView.prototype.remove = function (ecModel, api) {
99
- this.group.remove(this._bgColorGroup);
99
+ if (this._bgColorGroup) {
100
+ this.group.remove(this._bgColorGroup);
101
+ this._bgColorGroup = null;
102
+ }
100
103
  };
101
104
  BgColorView.prototype.dispose = function (ecModel, api) {
102
105
  this.remove(ecModel, api);
@@ -51,6 +51,7 @@ import { extend } from 'zrender/lib/core/util.js';
51
51
  import { setLabelStyle, getLabelStatesModels } from '../../label/labelStyle.js';
52
52
  import ZRImage from 'zrender/lib/graphic/Image.js';
53
53
  import { saveOldStyle } from '../../animation/basicTransition.js';
54
+ var variableTypes = ['labelCenter', 'labelDown', 'labelUp', 'labelLeft', 'labelRight', 'labelLowerLeft', 'labelLowerRight', 'labelUpperLeft', 'labelUpperRight', 'arrowUp', 'arrowDown'];
54
55
  var Symbol = /** @class */function (_super) {
55
56
  __extends(Symbol, _super);
56
57
  function Symbol(data, idx, seriesScope, opts) {
@@ -61,6 +62,7 @@ var Symbol = /** @class */function (_super) {
61
62
  Symbol.prototype._createSymbol = function (symbolType, data, idx, symbolSize, keepAspect) {
62
63
  // Remove paths created before
63
64
  this.removeAll();
65
+ var isVariable = variableTypes.includes(symbolType);
64
66
  // let symbolPath = createSymbol(
65
67
  // symbolType, -0.5, -0.5, 1, 1, color
66
68
  // );
@@ -68,15 +70,27 @@ var Symbol = /** @class */function (_super) {
68
70
  // and macOS Sierra, a circle stroke become a rect, no matter what
69
71
  // the scale is set. So we set width/height as 2. See #4150.
70
72
  var symbolPath = createSymbol(symbolType, -1, -1, 2, 2, null, keepAspect);
71
- symbolPath.attr({
72
- z2: 100,
73
- culling: true,
74
- scaleX: symbolSize[0] / 2,
75
- scaleY: symbolSize[1] / 2
76
- });
73
+ if (isVariable) {
74
+ symbolPath.attr({
75
+ z2: 100,
76
+ culling: true,
77
+ shape: {
78
+ width: symbolSize[0],
79
+ height: symbolSize[1]
80
+ }
81
+ });
82
+ } else {
83
+ symbolPath.attr({
84
+ z2: 100,
85
+ culling: true,
86
+ scaleX: symbolSize[0] / 2,
87
+ scaleY: symbolSize[1] / 2
88
+ });
89
+ }
77
90
  // Rewrite drift method
78
91
  symbolPath.drift = driftSymbol;
79
92
  this._symbolType = symbolType;
93
+ this._isVariable = isVariable;
80
94
  this.add(symbolPath);
81
95
  };
82
96
  /**
@@ -147,6 +161,14 @@ var Symbol = /** @class */function (_super) {
147
161
  scaleX: symbolSize[0] / 2,
148
162
  scaleY: symbolSize[1] / 2
149
163
  };
164
+ if (this._isVariable) {
165
+ target = {
166
+ shape: {
167
+ width: symbolSize[0],
168
+ height: symbolSize[1]
169
+ }
170
+ };
171
+ }
150
172
  disableAnimation ? symbolPath.attr(target) : graphic.updateProps(symbolPath, target, seriesModel, idx);
151
173
  saveOldStyle(symbolPath);
152
174
  }
@@ -162,8 +184,22 @@ var Symbol = /** @class */function (_super) {
162
184
  opacity: symbolPath.style.opacity
163
185
  }
164
186
  };
165
- symbolPath.scaleX = symbolPath.scaleY = 0;
166
- symbolPath.style.opacity = 0;
187
+ if (this._isVariable) {
188
+ target = {
189
+ shape: {
190
+ width: this._sizeX * 2,
191
+ height: this._sizeY * 2
192
+ },
193
+ style: {
194
+ // Always fadeIn. Because it has fadeOut animation when symbol is removed..
195
+ opacity: symbolPath.style.opacity
196
+ }
197
+ };
198
+ symbolPath.style.opacity = 0;
199
+ } else {
200
+ symbolPath.scaleX = symbolPath.scaleY = 0;
201
+ symbolPath.style.opacity = 0;
202
+ }
167
203
  graphic.initProps(symbolPath, target, seriesModel, idx);
168
204
  }
169
205
  }
@@ -217,6 +253,7 @@ var Symbol = /** @class */function (_super) {
217
253
  }
218
254
  cursorStyle && symbolPath.attr('cursor', cursorStyle);
219
255
  var symbolStyle = data.getItemVisual(idx, 'style');
256
+ // symbolStyle.stroke = symbolStyle.fill;
220
257
  var visualColor = symbolStyle.fill;
221
258
  if (symbolPath instanceof ZRImage) {
222
259
  var pathStyle = symbolPath.style;
@@ -254,7 +291,7 @@ var Symbol = /** @class */function (_super) {
254
291
  this._z2 = null;
255
292
  }
256
293
  var useNameLabel = opts && opts.useNameLabel;
257
- // todo setLabelStyle性能不好 暂时用不到先注释
294
+ // todo setLabelStyle需要优化
258
295
  setLabelStyle(symbolPath, labelStatesModels, {
259
296
  labelFetcher: seriesModel,
260
297
  labelDataIndex: idx,
@@ -277,9 +314,15 @@ var Symbol = /** @class */function (_super) {
277
314
  var scaleRatio = hoverScale == null || hoverScale === true ? Math.max(1.1, 3 / this._sizeY)
278
315
  // PENDING: restrict hoverScale > 1? It seems unreasonable to scale down
279
316
  : isFinite(hoverScale) && hoverScale > 0 ? +hoverScale : 1;
280
- // always set scale to allow resetting
281
- emphasisState.scaleX = this._sizeX * scaleRatio;
282
- emphasisState.scaleY = this._sizeY * scaleRatio;
317
+ if (this._isVariable) {
318
+ // always set scale to allow resetting
319
+ emphasisState.scaleX = scaleRatio;
320
+ emphasisState.scaleY = scaleRatio;
321
+ } else {
322
+ // always set scale to allow resetting
323
+ emphasisState.scaleX = this._sizeX * scaleRatio;
324
+ emphasisState.scaleY = this._sizeY * scaleRatio;
325
+ }
283
326
  this.setSymbolScale(1);
284
327
  toggleHoverEmphasis(this, focus, blurScope, emphasisDisabled);
285
328
  };
@@ -94,7 +94,8 @@ var SymbolDraw = /** @class */function () {
94
94
  var disableAnimation = opt.disableAnimation;
95
95
  var seriesScope = makeSeriesScope(data);
96
96
  var symbolUpdateOpt = {
97
- disableAnimation: disableAnimation
97
+ disableAnimation: disableAnimation,
98
+ useNameLabel: opt.useNameLabel
98
99
  };
99
100
  var getSymbolPoint = opt.getSymbolPoint || function (idx) {
100
101
  return data.getItemLayout(idx);
@@ -0,0 +1,109 @@
1
+
2
+ /*
3
+ * Licensed to the Apache Software Foundation (ASF) under one
4
+ * or more contributor license agreements. See the NOTICE file
5
+ * distributed with this work for additional information
6
+ * regarding copyright ownership. The ASF licenses this file
7
+ * to you under the Apache License, Version 2.0 (the
8
+ * "License"); you may not use this file except in compliance
9
+ * with the License. You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing,
14
+ * software distributed under the License is distributed on an
15
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ * KIND, either express or implied. See the License for the
17
+ * specific language governing permissions and limitations
18
+ * under the License.
19
+ */
20
+
21
+
22
+ /**
23
+ * AUTO-GENERATED FILE. DO NOT MODIFY.
24
+ */
25
+
26
+ /*
27
+ * Licensed to the Apache Software Foundation (ASF) under one
28
+ * or more contributor license agreements. See the NOTICE file
29
+ * distributed with this work for additional information
30
+ * regarding copyright ownership. The ASF licenses this file
31
+ * to you under the Apache License, Version 2.0 (the
32
+ * "License"); you may not use this file except in compliance
33
+ * with the License. You may obtain a copy of the License at
34
+ *
35
+ * http://www.apache.org/licenses/LICENSE-2.0
36
+ *
37
+ * Unless required by applicable law or agreed to in writing,
38
+ * software distributed under the License is distributed on an
39
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
40
+ * KIND, either express or implied. See the License for the
41
+ * specific language governing permissions and limitations
42
+ * under the License.
43
+ */
44
+ import { __extends } from "tslib";
45
+ import createSeriesData from '../helper/createSeriesData.js';
46
+ import SeriesModel from '../../model/Series.js';
47
+ var LabelsSeriesModel = /** @class */function (_super) {
48
+ __extends(LabelsSeriesModel, _super);
49
+ function LabelsSeriesModel() {
50
+ var _this = _super !== null && _super.apply(this, arguments) || this;
51
+ _this.type = LabelsSeriesModel.type;
52
+ return _this;
53
+ }
54
+ // hasSymbolVisual = true;
55
+ LabelsSeriesModel.prototype.getInitialData = function (option, ecModel) {
56
+ return createSeriesData(null, this, {
57
+ useEncodeDefaulter: true
58
+ });
59
+ };
60
+ LabelsSeriesModel.prototype.getProgressive = function () {
61
+ var progressive = this.option.progressive;
62
+ if (progressive == null) {
63
+ // PENDING
64
+ return this.option.large ? 5e3 : this.get('progressive');
65
+ }
66
+ return progressive;
67
+ };
68
+ LabelsSeriesModel.prototype.getProgressiveThreshold = function () {
69
+ var progressiveThreshold = this.option.progressiveThreshold;
70
+ if (progressiveThreshold == null) {
71
+ // PENDING
72
+ return this.option.large ? 1e4 : this.get('progressiveThreshold');
73
+ }
74
+ return progressiveThreshold;
75
+ };
76
+ LabelsSeriesModel.prototype.brushSelector = function (dataIndex, data, selectors) {
77
+ return selectors.point(data.getItemLayout(dataIndex));
78
+ };
79
+ LabelsSeriesModel.prototype.getZLevelKey = function () {
80
+ // Each progressive series has individual key.
81
+ return this.getData().count() > this.getProgressiveThreshold() ? this.id : '';
82
+ };
83
+ LabelsSeriesModel.type = 'series.labels';
84
+ LabelsSeriesModel.dependencies = ['grid', 'polar', 'geo', 'singleAxis', 'calendar'];
85
+ LabelsSeriesModel.defaultOption = {
86
+ coordinateSystem: 'cartesian2d',
87
+ // zlevel: 0,
88
+ z: 2,
89
+ legendHoverLink: true,
90
+ symbolSize: 10,
91
+ // symbolRotate: null, // 图形旋转控制
92
+ large: false,
93
+ // Available when large is true
94
+ largeThreshold: 2000,
95
+ // cursor: null,
96
+ itemStyle: {
97
+ // opacity: 0.8
98
+ // color: 各异
99
+ },
100
+ // emphasis: {
101
+ // scale: true
102
+ // },
103
+ // If clip the overflow graphics
104
+ // Works on cartesian / polar series
105
+ clip: true
106
+ };
107
+ return LabelsSeriesModel;
108
+ }(SeriesModel);
109
+ export default LabelsSeriesModel;
@@ -0,0 +1,133 @@
1
+
2
+ /*
3
+ * Licensed to the Apache Software Foundation (ASF) under one
4
+ * or more contributor license agreements. See the NOTICE file
5
+ * distributed with this work for additional information
6
+ * regarding copyright ownership. The ASF licenses this file
7
+ * to you under the Apache License, Version 2.0 (the
8
+ * "License"); you may not use this file except in compliance
9
+ * with the License. You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing,
14
+ * software distributed under the License is distributed on an
15
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ * KIND, either express or implied. See the License for the
17
+ * specific language governing permissions and limitations
18
+ * under the License.
19
+ */
20
+
21
+
22
+ /**
23
+ * AUTO-GENERATED FILE. DO NOT MODIFY.
24
+ */
25
+
26
+ /*
27
+ * Licensed to the Apache Software Foundation (ASF) under one
28
+ * or more contributor license agreements. See the NOTICE file
29
+ * distributed with this work for additional information
30
+ * regarding copyright ownership. The ASF licenses this file
31
+ * to you under the Apache License, Version 2.0 (the
32
+ * "License"); you may not use this file except in compliance
33
+ * with the License. You may obtain a copy of the License at
34
+ *
35
+ * http://www.apache.org/licenses/LICENSE-2.0
36
+ *
37
+ * Unless required by applicable law or agreed to in writing,
38
+ * software distributed under the License is distributed on an
39
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
40
+ * KIND, either express or implied. See the License for the
41
+ * specific language governing permissions and limitations
42
+ * under the License.
43
+ */
44
+ import { __extends } from "tslib";
45
+ import SymbolDraw from '../helper/SymbolDraw.js';
46
+ import LargeSymbolDraw from '../helper/LargeSymbolDraw.js';
47
+ import pointsLayout from '../../layout/points.js';
48
+ import ChartView from '../../view/Chart.js';
49
+ var ScatterView = /** @class */function (_super) {
50
+ __extends(ScatterView, _super);
51
+ function ScatterView() {
52
+ var _this = _super !== null && _super.apply(this, arguments) || this;
53
+ _this.type = ScatterView.type;
54
+ return _this;
55
+ }
56
+ ScatterView.prototype.render = function (seriesModel, ecModel, api) {
57
+ var data = seriesModel.getData();
58
+ var symbolDraw = this._updateSymbolDraw(data, seriesModel);
59
+ symbolDraw.updateData(data, {
60
+ // TODO
61
+ // If this parameter should be a shape or a bounding volume
62
+ // shape will be more general.
63
+ // But bounding volume like bounding rect will be much faster in the contain calculation
64
+ clipShape: this._getClipShape(seriesModel)
65
+ });
66
+ this._finished = true;
67
+ };
68
+ ScatterView.prototype.incrementalPrepareRender = function (seriesModel, ecModel, api) {
69
+ var data = seriesModel.getData();
70
+ var symbolDraw = this._updateSymbolDraw(data, seriesModel);
71
+ symbolDraw.incrementalPrepareUpdate(data);
72
+ this._finished = false;
73
+ };
74
+ ScatterView.prototype.incrementalRender = function (taskParams, seriesModel, ecModel) {
75
+ this._symbolDraw.incrementalUpdate(taskParams, seriesModel.getData(), {
76
+ clipShape: this._getClipShape(seriesModel)
77
+ });
78
+ this._finished = taskParams.end === seriesModel.getData().count();
79
+ };
80
+ ScatterView.prototype.updateTransform = function (seriesModel, ecModel, api) {
81
+ var data = seriesModel.getData();
82
+ // Must mark group dirty and make sure the incremental layer will be cleared
83
+ // PENDING
84
+ this.group.dirty();
85
+ if (!this._finished || data.count() > 1e4) {
86
+ return {
87
+ update: true
88
+ };
89
+ } else {
90
+ var res = pointsLayout('').reset(seriesModel, ecModel, api);
91
+ if (res.progress) {
92
+ res.progress({
93
+ start: 0,
94
+ end: data.count(),
95
+ count: data.count()
96
+ }, data);
97
+ }
98
+ this._symbolDraw.updateLayout(data);
99
+ }
100
+ };
101
+ ScatterView.prototype.eachRendered = function (cb) {
102
+ this._symbolDraw && this._symbolDraw.eachRendered(cb);
103
+ };
104
+ ScatterView.prototype._getClipShape = function (seriesModel) {
105
+ if (!seriesModel.get('clip', true)) {
106
+ return;
107
+ }
108
+ var coordSys = seriesModel.coordinateSystem;
109
+ // PENDING make `0.1` configurable, for example, `clipTolerance`?
110
+ return coordSys && coordSys.getArea && coordSys.getArea(.1);
111
+ };
112
+ ScatterView.prototype._updateSymbolDraw = function (data, seriesModel) {
113
+ var symbolDraw = this._symbolDraw;
114
+ var pipelineContext = seriesModel.pipelineContext;
115
+ var isLargeDraw = pipelineContext.large;
116
+ if (!symbolDraw || isLargeDraw !== this._isLargeDraw) {
117
+ symbolDraw && symbolDraw.remove();
118
+ symbolDraw = this._symbolDraw = isLargeDraw ? new LargeSymbolDraw() : new SymbolDraw();
119
+ this._isLargeDraw = isLargeDraw;
120
+ this.group.removeAll();
121
+ }
122
+ this.group.add(symbolDraw.group);
123
+ return symbolDraw;
124
+ };
125
+ ScatterView.prototype.remove = function (ecModel, api) {
126
+ this._symbolDraw && this._symbolDraw.remove(true);
127
+ this._symbolDraw = null;
128
+ };
129
+ ScatterView.prototype.dispose = function () {};
130
+ ScatterView.type = 'labels';
131
+ return ScatterView;
132
+ }(ChartView);
133
+ export default ScatterView;
@@ -0,0 +1,55 @@
1
+
2
+ /*
3
+ * Licensed to the Apache Software Foundation (ASF) under one
4
+ * or more contributor license agreements. See the NOTICE file
5
+ * distributed with this work for additional information
6
+ * regarding copyright ownership. The ASF licenses this file
7
+ * to you under the Apache License, Version 2.0 (the
8
+ * "License"); you may not use this file except in compliance
9
+ * with the License. You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing,
14
+ * software distributed under the License is distributed on an
15
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ * KIND, either express or implied. See the License for the
17
+ * specific language governing permissions and limitations
18
+ * under the License.
19
+ */
20
+
21
+
22
+ /**
23
+ * AUTO-GENERATED FILE. DO NOT MODIFY.
24
+ */
25
+
26
+ /*
27
+ * Licensed to the Apache Software Foundation (ASF) under one
28
+ * or more contributor license agreements. See the NOTICE file
29
+ * distributed with this work for additional information
30
+ * regarding copyright ownership. The ASF licenses this file
31
+ * to you under the Apache License, Version 2.0 (the
32
+ * "License"); you may not use this file except in compliance
33
+ * with the License. You may obtain a copy of the License at
34
+ *
35
+ * http://www.apache.org/licenses/LICENSE-2.0
36
+ *
37
+ * Unless required by applicable law or agreed to in writing,
38
+ * software distributed under the License is distributed on an
39
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
40
+ * KIND, either express or implied. See the License for the
41
+ * specific language governing permissions and limitations
42
+ * under the License.
43
+ */
44
+ import LabelsSeriesModel from './LabelsSeries.js';
45
+ import LabelsView from './LabelsView.js';
46
+ // import {install as installGridSimple} from '../../component/grid/installSimple.js';
47
+ import layoutPoints from '../../layout/points.js';
48
+ import labelsVisual from './labelsVisual.js';
49
+ export function install(registers) {
50
+ // In case developer forget to include grid component
51
+ registers.registerSeriesModel(LabelsSeriesModel);
52
+ registers.registerChartView(LabelsView);
53
+ registers.registerLayout(layoutPoints('labels'));
54
+ registers.registerVisual(labelsVisual);
55
+ }
@@ -0,0 +1,128 @@
1
+
2
+ /*
3
+ * Licensed to the Apache Software Foundation (ASF) under one
4
+ * or more contributor license agreements. See the NOTICE file
5
+ * distributed with this work for additional information
6
+ * regarding copyright ownership. The ASF licenses this file
7
+ * to you under the Apache License, Version 2.0 (the
8
+ * "License"); you may not use this file except in compliance
9
+ * with the License. You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing,
14
+ * software distributed under the License is distributed on an
15
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ * KIND, either express or implied. See the License for the
17
+ * specific language governing permissions and limitations
18
+ * under the License.
19
+ */
20
+
21
+
22
+ /**
23
+ * AUTO-GENERATED FILE. DO NOT MODIFY.
24
+ */
25
+
26
+ /*
27
+ * Licensed to the Apache Software Foundation (ASF) under one
28
+ * or more contributor license agreements. See the NOTICE file
29
+ * distributed with this work for additional information
30
+ * regarding copyright ownership. The ASF licenses this file
31
+ * to you under the Apache License, Version 2.0 (the
32
+ * "License"); you may not use this file except in compliance
33
+ * with the License. You may obtain a copy of the License at
34
+ *
35
+ * http://www.apache.org/licenses/LICENSE-2.0
36
+ *
37
+ * Unless required by applicable law or agreed to in writing,
38
+ * software distributed under the License is distributed on an
39
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
40
+ * KIND, either express or implied. See the License for the
41
+ * specific language governing permissions and limitations
42
+ * under the License.
43
+ */
44
+ import { extend } from 'zrender/lib/core/util.js';
45
+ var SYMBOL_PROPS_WITH_CB = ['symbol', 'symbolSize', 'symbolRotate', 'symbolOffset'];
46
+ var SYMBOL_PROPS = SYMBOL_PROPS_WITH_CB.concat(['symbolKeepAspect']);
47
+ var labelSymbols = ['labelDown', 'labelUp', 'labelLeft', 'labelRight', 'labelLowerLeft', 'labelLowerRight', 'labelUpperLeft', 'labelUpperRight', 'labelCenter'];
48
+ var lineSymbols = ['xCross', 'lCross'];
49
+ var padding = 10;
50
+ var LabelsLayout = {
51
+ createOnAllSeries: true,
52
+ // For legend.
53
+ performRawSeries: true,
54
+ reset: function (seriesModel) {
55
+ // if (!seriesModel.hasSymbolVisual) {
56
+ // return;
57
+ // }
58
+ // Only visible series has each data be visual encoded
59
+ // if (ecModel.isSeriesFiltered(seriesModel)) {
60
+ // return;
61
+ // }
62
+ var data = seriesModel.getData();
63
+ var symbolOptions = {};
64
+ // const symbolOptionsCb = {} as Record<(typeof SYMBOL_PROPS_WITH_CB)[number], any>;
65
+ for (var i = 0; i < SYMBOL_PROPS_WITH_CB.length; i++) {
66
+ var symbolPropName = SYMBOL_PROPS_WITH_CB[i];
67
+ var val = seriesModel.get(symbolPropName);
68
+ symbolOptions[symbolPropName] = val;
69
+ }
70
+ symbolOptions.symbol = symbolOptions.symbol || seriesModel.defaultSymbol;
71
+ data.setVisual(extend({
72
+ // legendIcon: seriesModel.legendIcon || symbolOptions.symbol,
73
+ symbolKeepAspect: seriesModel.get('symbolKeepAspect')
74
+ }, symbolOptions));
75
+ function dataEach(data, idx) {
76
+ var itemModel = data.getItemModel(idx);
77
+ var symbol = itemModel.getShallow('symbol');
78
+ var symbolSize = itemModel.getShallow('symbolSize');
79
+ var symbolRotate = itemModel.getShallow('symbolRotate');
80
+ var symbolOffset = itemModel.getShallow('symbolOffset');
81
+ var symbolKeepAspect = itemModel.getShallow('symbolKeepAspect');
82
+ var style = itemModel.getModel('itemStyle').getItemStyle();
83
+ if (labelSymbols.includes(symbol)) {
84
+ var labelModel = itemModel.getModel('label');
85
+ var text = labelModel.get('formatter');
86
+ if (labelModel.get('show') && text) {
87
+ var rect = labelModel.getTextRect(text);
88
+ symbolSize = [rect.width + padding, rect.height + padding];
89
+ var align = labelModel.get('align');
90
+ if (align === 'left') {
91
+ labelModel.option.offset = [-rect.width / 2, 0];
92
+ } else if (align === 'right') {
93
+ labelModel.option.offset = [rect.width / 2, 0];
94
+ }
95
+ }
96
+ // const rect = textContain.getBoundingRect(
97
+ // labelModel.getFont(),
98
+ // );
99
+ }
100
+ // if (!style.fill) {
101
+ // style.fill = color;
102
+ // }
103
+ if (lineSymbols.includes(symbol)) {
104
+ style.stroke = style.fill;
105
+ }
106
+ data.setItemVisual(idx, {
107
+ symbol: symbol,
108
+ symbolSize: symbolSize,
109
+ symbolRotate: symbolRotate,
110
+ symbolOffset: symbolOffset,
111
+ symbolKeepAspect: symbolKeepAspect,
112
+ style: style
113
+ });
114
+ // for (let i = 0; i < SYMBOL_PROPS.length; i++) {
115
+ // const symbolPropName = SYMBOL_PROPS[i];
116
+ // const val = itemModel.getShallow(symbolPropName, true);
117
+ // if (val != null) {
118
+ // data.setItemVisual(idx, symbolPropName, val);
119
+ // }
120
+ // }
121
+ }
122
+
123
+ return {
124
+ dataEach: data.hasItemOption ? dataEach : null
125
+ };
126
+ }
127
+ };
128
+ export default LabelsLayout;
@@ -0,0 +1,46 @@
1
+
2
+ /*
3
+ * Licensed to the Apache Software Foundation (ASF) under one
4
+ * or more contributor license agreements. See the NOTICE file
5
+ * distributed with this work for additional information
6
+ * regarding copyright ownership. The ASF licenses this file
7
+ * to you under the Apache License, Version 2.0 (the
8
+ * "License"); you may not use this file except in compliance
9
+ * with the License. You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing,
14
+ * software distributed under the License is distributed on an
15
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ * KIND, either express or implied. See the License for the
17
+ * specific language governing permissions and limitations
18
+ * under the License.
19
+ */
20
+
21
+
22
+ /**
23
+ * AUTO-GENERATED FILE. DO NOT MODIFY.
24
+ */
25
+
26
+ /*
27
+ * Licensed to the Apache Software Foundation (ASF) under one
28
+ * or more contributor license agreements. See the NOTICE file
29
+ * distributed with this work for additional information
30
+ * regarding copyright ownership. The ASF licenses this file
31
+ * to you under the Apache License, Version 2.0 (the
32
+ * "License"); you may not use this file except in compliance
33
+ * with the License. You may obtain a copy of the License at
34
+ *
35
+ * http://www.apache.org/licenses/LICENSE-2.0
36
+ *
37
+ * Unless required by applicable law or agreed to in writing,
38
+ * software distributed under the License is distributed on an
39
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
40
+ * KIND, either express or implied. See the License for the
41
+ * specific language governing permissions and limitations
42
+ * under the License.
43
+ */
44
+ import { use } from '../extension.js';
45
+ import { install } from './labels/install.js';
46
+ use(install);