tvcharts 0.5.56 → 0.5.57

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.
@@ -51,6 +51,7 @@ import { createSymbol, normalizeSymbolOffset } from '../../util/symbol.js';
51
51
  import * as matrixUtil from 'zrender/lib/core/matrix.js';
52
52
  import { applyTransform as v2ApplyTransform } from 'zrender/lib/core/vector.js';
53
53
  import { shouldShowAllLabels } from '../../coord/axisHelper.js';
54
+ import * as globalListener from './globalListener.js';
54
55
  import { prepareLayoutList, hideOverlap } from '../../label/labelLayoutHelper.js';
55
56
  var PI = Math.PI;
56
57
  /**
@@ -154,6 +155,8 @@ var AxisBuilder = /** @class */function () {
154
155
  return AxisBuilder;
155
156
  }();
156
157
  ;
158
+ var isMouseDown = false; // 鼠标是否按下
159
+ var mouseY = 0; // 鼠标Y轴位置
157
160
  var builders = {
158
161
  axisLine: function (opt, axisModel, group, transformGroup) {
159
162
  var shown = axisModel.get(['axisLine', 'show']);
@@ -230,6 +233,125 @@ var builders = {
230
233
  });
231
234
  }
232
235
  },
236
+ axisBackground: function (opt, axisModel, group, transformGroup) {
237
+ var shown = axisModel.get(['axisBackground', 'show']);
238
+ if (!shown) {
239
+ return;
240
+ }
241
+ var extent = axisModel.axis.getExtent();
242
+ var matrix = transformGroup.transform;
243
+ var pt1 = [extent[0], 0];
244
+ // const pt2 = [extent[1], 0];
245
+ // const inverse = pt1[0] > pt2[0];
246
+ if (matrix) {
247
+ v2ApplyTransform(pt1, pt1, matrix);
248
+ // v2ApplyTransform(pt2, pt2, matrix);
249
+ }
250
+
251
+ var style = extend({
252
+ // lineCap: 'round'
253
+ }, axisModel.getModel(['axisBackground', 'backStyle']).getLineStyle());
254
+ var dataZoomModals = axisModel.ecModel.queryComponents({
255
+ mainType: 'dataZoom',
256
+ id: axisModel.mainType
257
+ });
258
+ var position = axisModel.axis.position;
259
+ var ecInstance = axisModel.ecModel.scheduler.ecInstance;
260
+ var api = axisModel.ecModel.scheduler.api;
261
+ var width = api.getWidth();
262
+ var rect = position === 'left' ? {
263
+ left: 0,
264
+ right: pt1[0],
265
+ top: 0,
266
+ bottom: pt1[1]
267
+ } : {
268
+ left: pt1[0],
269
+ right: width,
270
+ top: 0,
271
+ bottom: pt1[1]
272
+ };
273
+ var left = rect.left,
274
+ right = rect.right,
275
+ top = rect.top,
276
+ bottom = rect.bottom;
277
+ globalListener.register('axisBackground', axisModel.ecModel.scheduler.api, function (currTrigger, e) {
278
+ if (!e || !e.offsetX || !e.offsetY) {
279
+ return;
280
+ }
281
+ var offsetX = e.offsetX;
282
+ var offsetY = e.offsetY;
283
+ if (offsetX > right || offsetX < left || offsetY < top || offsetY > bottom) {
284
+ return;
285
+ }
286
+ switch (currTrigger) {
287
+ case 'mouseup':
288
+ isMouseDown = false;
289
+ mouseY = 0;
290
+ break;
291
+ case 'mousedown':
292
+ isMouseDown = true;
293
+ break;
294
+ case 'mousemove':
295
+ var zoomStep_1 = 0.2; // 设置缩放步长
296
+ if (isMouseDown && e.offsetY !== mouseY) {
297
+ dataZoomModals.forEach(function (item) {
298
+ var settledOption = item.settledOption,
299
+ componentIndex = item.componentIndex;
300
+ // 下滑
301
+ if (mouseY > e.offsetY) {
302
+ zoomStep_1 = -zoomStep_1;
303
+ }
304
+ ecInstance.dispatchAction({
305
+ type: 'dataZoom',
306
+ dataZoomIndex: componentIndex,
307
+ start: settledOption.start - zoomStep_1,
308
+ end: settledOption.end + zoomStep_1
309
+ });
310
+ mouseY = e.offsetY;
311
+ });
312
+ }
313
+ break;
314
+ case 'mousewheel':
315
+ {
316
+ var zoomStep_2 = e.wheelDelta * 0.8;
317
+ dataZoomModals.forEach(function (item) {
318
+ var settledOption = item.settledOption,
319
+ componentIndex = item.componentIndex;
320
+ ecInstance.dispatchAction({
321
+ type: 'dataZoom',
322
+ dataZoomIndex: componentIndex,
323
+ start: settledOption.start + zoomStep_2,
324
+ end: settledOption.end - zoomStep_2
325
+ });
326
+ });
327
+ }
328
+ break;
329
+ }
330
+ // console.log("y轴交互")
331
+ // if () {
332
+ // }
333
+ });
334
+ // todo 先不管x轴
335
+ var background = new graphic.Rect({
336
+ shape: position === 'left' ? {
337
+ x: 0,
338
+ y: 0,
339
+ width: pt1[0],
340
+ height: pt1[1]
341
+ } : {
342
+ x: pt1[0],
343
+ y: 0,
344
+ width: api.getWidth() - pt1[0],
345
+ height: pt1[1]
346
+ },
347
+ style: style,
348
+ cursor: 'ns-resize',
349
+ z2: 1
350
+ });
351
+ // graphic.subPixelOptimizeLine(line.shape, line.style.lineWidth);
352
+ background.anid = 'background';
353
+ group.add(background);
354
+ },
233
355
  axisTickLabel: function (opt, axisModel, group, transformGroup) {
234
356
  var ticksEls = buildAxisMajorTicks(group, transformGroup, axisModel, opt);
235
357
  var labelEls = buildAxisLabel(group, transformGroup, axisModel, opt);
@@ -49,7 +49,8 @@ import AxisView from './AxisView.js';
49
49
  import * as cartesianAxisHelper from '../../coord/cartesian/cartesianAxisHelper.js';
50
50
  import { rectCoordAxisBuildSplitArea, rectCoordAxisHandleRemove } from './axisSplitHelper.js';
51
51
  import { isIntervalOrLogScale } from '../../scale/helper.js';
52
- var axisBuilderAttrs = ['axisLine', 'axisTickLabel', 'axisName'];
52
+ import * as globalListener from './globalListener.js';
53
+ var axisBuilderAttrs = ['axisLine', 'axisTickLabel', 'axisName', 'axisBackground'];
53
54
  var selfBuilderAttrs = ['splitArea', 'splitLine', 'minorSplitLine'];
54
55
  var CartesianAxisView = /** @class */function (_super) {
55
56
  __extends(CartesianAxisView, _super);
@@ -101,9 +102,14 @@ var CartesianAxisView = /** @class */function (_super) {
101
102
  }
102
103
  _super.prototype.render.call(this, axisModel, ecModel, api, payload);
103
104
  };
104
- CartesianAxisView.prototype.remove = function () {
105
+ CartesianAxisView.prototype.remove = function (ecModel, api) {
106
+ globalListener.unregister('axisPointer', api);
105
107
  rectCoordAxisHandleRemove(this);
106
108
  };
109
+ CartesianAxisView.prototype.dispose = function (ecModel, api) {
110
+ _super.prototype.dispose.call(this, ecModel, api);
111
+ globalListener.unregister('axisPointer', api);
112
+ };
107
113
  CartesianAxisView.type = 'cartesianAxis';
108
114
  return CartesianAxisView;
109
115
  }(AxisView);
@@ -0,0 +1,81 @@
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
+ import * as zrUtil from 'zrender/lib/core/util.js';
27
+ import env from 'zrender/lib/core/env.js';
28
+ import { makeInner } from '../../util/model.js';
29
+ var inner = makeInner();
30
+ var each = zrUtil.each;
31
+ /**
32
+ * @param {string} key
33
+ * @param {module:echarts/ExtensionAPI} api
34
+ * @param {Function} handler
35
+ * param: {string} currTrigger
36
+ * param: {Array.<number>} point
37
+ */
38
+ export function register(key, api, handler) {
39
+ if (env.node) {
40
+ return;
41
+ }
42
+ var zr = api.getZr();
43
+ inner(zr).records || (inner(zr).records = {});
44
+ initGlobalListeners(zr, api);
45
+ var record = inner(zr).records[key] || (inner(zr).records[key] = {});
46
+ record.handler = handler;
47
+ }
48
+ function initGlobalListeners(zr, api) {
49
+ if (inner(zr).initialized) {
50
+ return;
51
+ }
52
+ inner(zr).initialized = true;
53
+ useHandler('mouseup', zrUtil.curry(doEnter, 'mouseup'));
54
+ useHandler('mousemove', zrUtil.curry(doEnter, 'mousemove'));
55
+ useHandler('mousewheel', zrUtil.curry(doEnter, 'mousewheel'));
56
+ useHandler('mousedown', zrUtil.curry(doEnter, 'mousedown'));
57
+ useHandler('globalout', onLeave);
58
+ function useHandler(eventType, cb) {
59
+ zr.on(eventType, function (e) {
60
+ each(inner(zr).records, function (record) {
61
+ record && cb(record, e, api.dispatchAction);
62
+ });
63
+ });
64
+ }
65
+ }
66
+ function onLeave(record, e, dispatchAction) {
67
+ record.handler('leave', null, dispatchAction);
68
+ }
69
+ function doEnter(currTrigger, record, e, dispatchAction) {
70
+ record.handler(currTrigger, e, dispatchAction);
71
+ }
72
+ export function unregister(key, api) {
73
+ if (env.node) {
74
+ return;
75
+ }
76
+ var zr = api.getZr();
77
+ var record = (inner(zr).records || {})[key];
78
+ if (record) {
79
+ inner(zr).records[key] = null;
80
+ }
81
+ }
@@ -54,7 +54,7 @@ var AxisPointerView = /** @class */function (_super) {
54
54
  return _this;
55
55
  }
56
56
  AxisPointerView.prototype.render = function (globalAxisPointerModel, ecModel, api) {
57
- var _a;
57
+ var _a, _b;
58
58
  var xAxisModel = ecModel.getComponent('xAxis');
59
59
  var yAxisModel = ecModel.getComponent('yAxis');
60
60
  var globalTooltipModel = ecModel.getComponent('tooltip');
@@ -98,7 +98,7 @@ var AxisPointerView = /** @class */function (_super) {
98
98
  // todo 当进行dataZoom的时候也需要更新axisPointer
99
99
  if (isDataZoom) {
100
100
  var dispatch = makeDispatchAction(api);
101
- var event_1 = (_a = payload.batch[0]) === null || _a === void 0 ? void 0 : _a.event;
101
+ var event_1 = (_b = (_a = payload.batch) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.event;
102
102
  if ((event_1 === null || event_1 === void 0 ? void 0 : event_1.originX) || (event_1 === null || event_1 === void 0 ? void 0 : event_1.originY)) {
103
103
  handleAxisPointer('mousemove', {
104
104
  offsetX: event_1.originX,
@@ -120,6 +120,12 @@ var defaultOption = {
120
120
  areaStyle: {
121
121
  color: ['rgba(250,250,250,0.2)', 'rgba(210,219,238,0.2)']
122
122
  }
123
+ },
124
+ axisBackground: {
125
+ show: false,
126
+ backStyle: {
127
+ opacity: 0
128
+ }
123
129
  }
124
130
  };
125
131
  var categoryAxis = zrUtil.merge({
@@ -144,6 +150,7 @@ var categoryAxis = zrUtil.merge({
144
150
  }, defaultOption);
145
151
  var valueAxis = zrUtil.merge({
146
152
  boundaryGap: [0, 0],
153
+ axisBackground: {},
147
154
  axisLine: {
148
155
  // Not shown when other axis is categoryAxis in cartesian
149
156
  show: 'auto'
@@ -74,6 +74,7 @@ export function layout(gridModel, axisModel, opt) {
74
74
  // Axis position
75
75
  layout.position = [axisDim === 'y' ? posBound[idx[axisPosition]] : rectBound[0], axisDim === 'x' ? posBound[idx[axisPosition]] : rectBound[3]];
76
76
  // Axis rotation
77
+ // layout.rotation = 0;
77
78
  layout.rotation = Math.PI / 2 * (axisDim === 'x' ? 0 : 1);
78
79
  // Tick and label direction, x y is axisDim
79
80
  var dirMap = {
@@ -384,6 +384,7 @@ var ECharts = /** @class */function (_super) {
384
384
  this._model.setOption(option, {
385
385
  replaceMerge: replaceMerge
386
386
  }, optionPreprocessorFuncs);
387
+ console.log("actions", actions);
387
388
  var updateParams = {
388
389
  seriesTransition: transitionOpt,
389
390
  optionChanged: true
@@ -1055,6 +1056,7 @@ var ECharts = /** @class */function (_super) {
1055
1056
  mainType: model.mainType,
1056
1057
  index: model.componentIndex
1057
1058
  };
1059
+ console.log('%c [ view ]-1527', 'font-size:13px; background:pink; color:#bf2c9f;', view);
1058
1060
  !isComponent && scheduler.prepareView(view, model, ecModel, api);
1059
1061
  }
1060
1062
  for (var i = 0; i < viewList.length;) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tvcharts",
3
- "version": "0.5.56",
3
+ "version": "0.5.57",
4
4
  "description": "基于echarts5.4.3二次开发",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [
@@ -2400,6 +2400,7 @@ interface AxisBaseOptionCommon extends ComponentOption, AnimationOptionMixin {
2400
2400
  splitLine?: SplitLineOption;
2401
2401
  minorSplitLine?: MinorSplitLineOption;
2402
2402
  splitArea?: SplitAreaOption;
2403
+ axisBackground?: AxisBackgroundOption;
2403
2404
  /**
2404
2405
  * Min value of the axis. can be:
2405
2406
  * + ScaleDataValue
@@ -2555,6 +2556,10 @@ interface MinorSplitLineOption {
2555
2556
  show?: boolean;
2556
2557
  lineStyle?: LineStyleOption;
2557
2558
  }
2559
+ interface AxisBackgroundOption {
2560
+ show?: boolean;
2561
+ backStyle?: AreaStyleOption<ZRColor>;
2562
+ }
2558
2563
  interface SplitAreaOption {
2559
2564
  show?: boolean;
2560
2565
  interval?: 'auto' | number | ((index: number, value: string) => boolean);
@@ -2400,6 +2400,7 @@ interface AxisBaseOptionCommon extends ComponentOption, AnimationOptionMixin {
2400
2400
  splitLine?: SplitLineOption;
2401
2401
  minorSplitLine?: MinorSplitLineOption;
2402
2402
  splitArea?: SplitAreaOption;
2403
+ axisBackground?: AxisBackgroundOption;
2403
2404
  /**
2404
2405
  * Min value of the axis. can be:
2405
2406
  * + ScaleDataValue
@@ -2555,6 +2556,10 @@ interface MinorSplitLineOption {
2555
2556
  show?: boolean;
2556
2557
  lineStyle?: LineStyleOption;
2557
2558
  }
2559
+ interface AxisBackgroundOption {
2560
+ show?: boolean;
2561
+ backStyle?: AreaStyleOption<ZRColor>;
2562
+ }
2558
2563
  interface SplitAreaOption {
2559
2564
  show?: boolean;
2560
2565
  interval?: 'auto' | number | ((index: number, value: string) => boolean);
@@ -86,5 +86,5 @@ declare class AxisBuilder {
86
86
  interface AxisElementsBuilder {
87
87
  (opt: AxisBuilderCfg, axisModel: AxisBaseModel, group: graphic.Group, transformGroup: graphic.Group): void;
88
88
  }
89
- declare const builders: Record<'axisLine' | 'axisTickLabel' | 'axisName', AxisElementsBuilder>;
89
+ declare const builders: Record<'axisLine' | 'axisTickLabel' | 'axisName' | 'axisBackground', AxisElementsBuilder>;
90
90
  export default AxisBuilder;
@@ -12,7 +12,8 @@ declare class CartesianAxisView extends AxisView {
12
12
  * @override
13
13
  */
14
14
  render(axisModel: CartesianAxisModel, ecModel: GlobalModel, api: ExtensionAPI, payload: Payload): void;
15
- remove(): void;
15
+ remove(ecModel: GlobalModel, api: ExtensionAPI): void;
16
+ dispose(ecModel: GlobalModel, api: ExtensionAPI): void;
16
17
  }
17
18
  export declare class CartesianXAxisView extends CartesianAxisView {
18
19
  static type: string;
@@ -0,0 +1,14 @@
1
+ import ExtensionAPI from '../../core/ExtensionAPI.js';
2
+ import { ZRElementEvent } from '../../util/types.js';
3
+ declare type DispatchActionMethod = ExtensionAPI['dispatchAction'];
4
+ export declare type Handler = (currTrigger: 'mouseup' | 'mousemove' | 'leave' | 'mousewheel' | 'mousedown', event: ZRElementEvent, dispatchAction: DispatchActionMethod) => void;
5
+ /**
6
+ * @param {string} key
7
+ * @param {module:echarts/ExtensionAPI} api
8
+ * @param {Function} handler
9
+ * param: {string} currTrigger
10
+ * param: {Array.<number>} point
11
+ */
12
+ export declare function register(key: string, api: ExtensionAPI, handler?: Handler): void;
13
+ export declare function unregister(key: string, api: ExtensionAPI): void;
14
+ export {};
@@ -34,6 +34,7 @@ export interface AxisBaseOptionCommon extends ComponentOption, AnimationOptionMi
34
34
  splitLine?: SplitLineOption;
35
35
  minorSplitLine?: MinorSplitLineOption;
36
36
  splitArea?: SplitAreaOption;
37
+ axisBackground?: AxisBackgroundOption;
37
38
  /**
38
39
  * Min value of the axis. can be:
39
40
  * + ScaleDataValue
@@ -189,6 +190,10 @@ interface MinorSplitLineOption {
189
190
  show?: boolean;
190
191
  lineStyle?: LineStyleOption;
191
192
  }
193
+ interface AxisBackgroundOption {
194
+ show?: boolean;
195
+ backStyle?: AreaStyleOption<ZRColor>;
196
+ }
192
197
  interface SplitAreaOption {
193
198
  show?: boolean;
194
199
  interval?: 'auto' | number | ((index: number, value: string) => boolean);