tvcharts 0.8.89 → 0.8.90

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.
@@ -224,4 +224,7 @@ function calculateCandleWidth(seriesModel, data) {
224
224
  // return Math.floor(Math.max(bandWidth * 0.7, 1));
225
225
  }
226
226
 
227
+ export function getRenderIndexX(bandWidth, x) {
228
+ return subPixelOptimize(x - bandWidth / 2, 1, false);
229
+ }
227
230
  export default candlePlotLayout;
@@ -47,6 +47,7 @@ import sliderMove from '../helper/sliderMove.js';
47
47
  import * as roams from './roams.js';
48
48
  import { bind } from 'tvrender/lib/core/util.js';
49
49
  import { barSpaceLimit } from './helper.js';
50
+ import { getRenderIndexX } from '../../chart/candlePlot/candlePlotLayout.js';
50
51
  var InsideZoomView = /** @class */function (_super) {
51
52
  __extends(InsideZoomView, _super);
52
53
  function InsideZoomView() {
@@ -109,6 +110,13 @@ var getRangeHandlers = {
109
110
  if (e.inSitu) {
110
111
  var extent = axisModel.axis.getExtent()[1];
111
112
  var x = axisModel.axis.toLocalCoord(e.originX);
113
+ if (e.isPinch) {
114
+ var _a = axisModel.axis.scale.getExtent(),
115
+ startIndex = _a[0],
116
+ endIndex = _a[1];
117
+ var basex = axisModel.axis.toLocalCoord(axisModel.axis.dataToCoord(Math.floor((endIndex + startIndex) / 2)));
118
+ x = getRenderIndexX(axisModel.axis.getBandWidth(), basex);
119
+ }
112
120
  var dataCount = axisModel.axis.scale.getAxisDataLen();
113
121
  var deltaFromRight = (extent - x) / lastDistanceRange[0];
114
122
  var floatIndex = dataCount + distanceRange[1] - deltaFromRight;
@@ -242,17 +242,23 @@ var RoamController = /** @class */function (_super) {
242
242
  if (interactionMutex.isTaken(this._zr, 'globalPan')) {
243
243
  return;
244
244
  }
245
- var scale = e.pinchScale > 1 ? 1.03 : 1 / 1.03;
246
- // const scale = e.pinchScale;
245
+ // const scale = e.pinchScale > 1 ? 1.03 : 1 / 1.03;
246
+ var scale = e.pinchScale;
247
247
  // if (e.pinchScale === 1) {
248
248
  // console.log('%c [ e ]-316', 'font-size:13px; background:pink; color:#bf2c9f;', e)
249
249
  // }
250
+ // const now = Date.now();
251
+ // if (this._lastPinchTime && now - this._lastPinchTime < 16) {
252
+ // return;
253
+ // }
254
+ // this._lastPinchTime = now;
250
255
  checkPointerAndTrigger(this, 'zoom', 'zoomOnMouseWheel', e, {
251
256
  scale: scale,
252
257
  originX: e.pinchX,
253
258
  originY: e.pinchY,
254
259
  isAvailableBehavior: null,
255
- inSitu: true
260
+ inSitu: true,
261
+ isPinch: true
256
262
  });
257
263
  };
258
264
  RoamController.prototype._kineticScroll = function () {
@@ -939,10 +939,8 @@ var ECharts = /** @class */function (_super) {
939
939
  defaultMainType: 'series'
940
940
  });
941
941
  var seriesModel = parsedFinder.seriesModel;
942
- if (process.env.NODE_ENV !== 'production') {
943
- if (!seriesModel) {
944
- warn('There is no specified series model');
945
- }
942
+ if (!seriesModel) {
943
+ return;
946
944
  }
947
945
  // const data = seriesModel.getData();
948
946
  var dataIndex = parsedFinder.hasOwnProperty('dataIndex') ? parsedFinder.dataIndex : 0;
@@ -2877,9 +2875,11 @@ export function connectLayoutAction(layoutId, action) {
2877
2875
  return layoutId;
2878
2876
  }
2879
2877
  export function disconnectLayoutAction(layoutId, action) {
2880
- layoutEventAbleMap[layoutId] = layoutEventAbleMap[layoutId].filter(function (item) {
2881
- return item !== action;
2882
- });
2878
+ if (layoutEventAbleMap[layoutId]) {
2879
+ layoutEventAbleMap[layoutId] = layoutEventAbleMap[layoutId].filter(function (item) {
2880
+ return item !== action;
2881
+ });
2882
+ }
2883
2883
  return layoutId;
2884
2884
  }
2885
2885
  export function disconnectLayouts(layoutId) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tvcharts",
3
- "version": "0.8.89",
3
+ "version": "0.8.90",
4
4
  "main": "dist/echarts.js",
5
5
  "module": "index.js",
6
6
  "jsdelivr": "dist/echarts.min.js",
@@ -12,4 +12,5 @@ export interface CandlePlotLayoutMeta {
12
12
  }
13
13
  declare const candlePlotLayout: StageHandler;
14
14
  export declare function optimalCandlestickWidth(barSpacing: number, pixelRatio: number): number;
15
+ export declare function getRenderIndexX(bandWidth: number, x: number): number;
15
16
  export default candlePlotLayout;
@@ -21,6 +21,7 @@ export interface RoamEventParams {
21
21
  originX: number;
22
22
  originY: number;
23
23
  inSitu?: boolean;
24
+ isPinch?: boolean;
24
25
  isAvailableBehavior: Bind3<typeof isAvailableBehavior, null, RoamBehavior, ZRElementEvent>;
25
26
  };
26
27
  'scrollMove': {
@@ -63,6 +64,7 @@ declare class RoamController extends Eventful<{
63
64
  private _opt;
64
65
  private _dragging;
65
66
  private _pinching;
67
+ private _lastPinchTime;
66
68
  private _x;
67
69
  private _y;
68
70
  private _startX;