tvcharts 0.9.11 → 0.9.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.
@@ -44,6 +44,7 @@
44
44
  import { subPixelOptimize } from '../../util/graphic.js';
45
45
  import createRenderPlanner from '../helper/createRenderPlanner.js';
46
46
  import { map } from 'tvrender/lib/core/util.js';
47
+ import { isMobileRender } from "../../util/mobile.js";
47
48
  var positiveBorderColorQuery = ['itemStyle', 'borderColor'];
48
49
  var negativeBorderColorQuery = ['itemStyle', 'borderColor0'];
49
50
  var dojiBorderColorQuery = ['itemStyle', 'borderColorDoji'];
@@ -82,9 +83,8 @@ var candlePlotLayout = {
82
83
  }
83
84
  var showLast = seriesModel.get('showLast');
84
85
  var ignoreParentColor = seriesModel.get('ignoreParentColor');
85
- var isMobile = seriesModel.get('isMobile');
86
- var offsetX = isMobile ? 0 : 0.5;
87
- var formatY = isMobile ? function (y) {
86
+ var offsetX = isMobileRender ? 0 : 0.5;
87
+ var formatY = isMobileRender ? function (y) {
88
88
  return y;
89
89
  } : function (y) {
90
90
  return Math.floor(y);
@@ -228,7 +228,7 @@ function optimalCandlestickWidth(barSpacing, pixelRatio) {
228
228
  var barSpacingSpecialCaseTo = 4;
229
229
  var barSpacingSpecialCaseCoeff = 3;
230
230
  if (barSpacing >= barSpacingSpecialCaseFrom && barSpacing <= barSpacingSpecialCaseTo) {
231
- return Math.floor(barSpacingSpecialCaseCoeff * pixelRatio) - 2;
231
+ return Math.floor(barSpacingSpecialCaseCoeff * pixelRatio) - 1;
232
232
  }
233
233
  // coeff should be 1 on small barspacing and go to 0.8 while groing bar spacing
234
234
  var barSpacingReducingCoeff = 0.2;
@@ -46,6 +46,9 @@ import ComponentView from "../../view/Component.js";
46
46
  import { each } from "tvrender/lib/core/util.js";
47
47
  import * as graphic from "../../util/graphic.js";
48
48
  var r = 15;
49
+ var optimizeX = function (x, lineWidth) {
50
+ return lineWidth % 2 === 0 ? x : Math.floor(x) + 0.5;
51
+ };
49
52
  var EventsView = /** @class */function (_super) {
50
53
  __extends(EventsView, _super);
51
54
  function EventsView() {
@@ -59,7 +62,7 @@ var EventsView = /** @class */function (_super) {
59
62
  }
60
63
  EventsView.prototype.init = function (ecModel, api) {
61
64
  this._api = api;
62
- // api.getZr().on('mousemove', this._mouseMove, this);
65
+ // api.getZr().on('mousemove', this._eventClick, this);
63
66
  };
64
67
 
65
68
  EventsView.prototype.render = function (eventsModel, ecModel, api) {
@@ -118,6 +121,7 @@ var EventsView = /** @class */function (_super) {
118
121
  var id = time + "_" + item.id;
119
122
  var isSelected = selectedEventViewId === id;
120
123
  var renderZ = isSelected ? z + 1 : z;
124
+ var imgGroup = new graphic.Group();
121
125
  var img = new graphic.Image({
122
126
  style: {
123
127
  image: item.url,
@@ -139,7 +143,7 @@ var EventsView = /** @class */function (_super) {
139
143
  }
140
144
  });
141
145
  img.setClipPath(clipPath);
142
- group.add(img);
146
+ imgGroup.add(img);
143
147
  var rect = new graphic.Rect({
144
148
  shape: {
145
149
  x: x + 5 - borderWidth / 2,
@@ -150,7 +154,8 @@ var EventsView = /** @class */function (_super) {
150
154
  },
151
155
  style: {
152
156
  stroke: "#ED544F",
153
- fill: "none"
157
+ fill: "none",
158
+ lineWidth: borderWidth
154
159
  },
155
160
  z2: z2,
156
161
  z: renderZ
@@ -162,7 +167,7 @@ var EventsView = /** @class */function (_super) {
162
167
  this.hoverEventId = '';
163
168
  }
164
169
  }
165
- group.add(rect);
170
+ imgGroup.add(rect);
166
171
  if (i !== list.length - 1) {
167
172
  y = y - 24;
168
173
  }
@@ -195,21 +200,23 @@ var EventsView = /** @class */function (_super) {
195
200
  }
196
201
  });
197
202
  };
198
- img.onmouseout = mouseout;
199
- img.onmousemove = mouseMove;
200
- img.onmouseover = mouseover;
201
- img.onclick = click;
202
- rect.onmouseout = mouseout;
203
- rect.onmousemove = mouseMove;
204
- rect.onmouseover = mouseover;
205
- rect.onclick = click;
203
+ imgGroup.onmouseout = mouseout;
204
+ imgGroup.onmousemove = mouseMove;
205
+ imgGroup.onmouseover = mouseover;
206
+ imgGroup.onmouseup = click;
207
+ group.add(imgGroup);
208
+ // rect.onmouseout = mouseout;
209
+ // rect.onmousemove = mouseMove;
210
+ // rect.onmouseover = mouseover;
211
+ // rect.onclick = click;
206
212
  }, this_1);
207
213
  if (lineVisible && list.length) {
214
+ var linex = optimizeX(x + 15, lineStyle.width);
208
215
  var line = new graphic.Line({
209
216
  shape: {
210
- x1: x + 15,
217
+ x1: linex,
211
218
  y1: 0,
212
- x2: x + 15,
219
+ x2: linex,
213
220
  y2: y
214
221
  },
215
222
  silent: true,
@@ -230,6 +237,8 @@ var EventsView = /** @class */function (_super) {
230
237
  if (state_1 === "break") break;
231
238
  }
232
239
  };
240
+ // _eventClick(e: any){
241
+ // }
233
242
  EventsView.prototype._mouseMove = function (e) {
234
243
  this._lastPoint = {
235
244
  x: e.offsetX,
@@ -242,7 +251,9 @@ var EventsView = /** @class */function (_super) {
242
251
  x: 0,
243
252
  y: 0
244
253
  };
254
+ // this._api && this._api.getZr()?.off('mousemove', this._eventClick);
245
255
  };
256
+
246
257
  EventsView.type = "events";
247
258
  return EventsView;
248
259
  }(ComponentView);
package/lib/coord/Axis.js CHANGED
@@ -44,28 +44,8 @@
44
44
  import { each, map } from 'tvrender/lib/core/util.js';
45
45
  import { linearMap, getPixelPrecision, round } from '../util/number.js';
46
46
  import { createAxisTicks, createAxisLabels, calculateCategoryInterval } from './axisTickLabelBuilder.js';
47
+ import { isMobileRender } from "../util/mobile.js";
47
48
  var NORMALIZED_EXTENT = [0, 1];
48
- function isMobileByWidth(breakPoint) {
49
- if (breakPoint === void 0) {
50
- breakPoint = 768;
51
- }
52
- // 服务端渲染(SSR)或非浏览器环境返回false
53
- if (typeof window === "undefined") return false;
54
- // 获取当前视口宽度(实时检测)
55
- var viewportWidth = window.innerWidth;
56
- // 判断是否小于断点
57
- return viewportWidth < breakPoint && window.devicePixelRatio !== 1;
58
- }
59
- function isMobileView() {
60
- // 其次检查 User Agent
61
- var userAgent = navigator.userAgent;
62
- var mobileRegex = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i;
63
- if (isMobileByWidth() && mobileRegex.test(userAgent)) {
64
- return true;
65
- }
66
- return false;
67
- }
68
- var isMobile = isMobileView();
69
49
  /**
70
50
  * Base class of Axis.
71
51
  */
@@ -124,7 +104,7 @@ var Axis = /** @class */function () {
124
104
  var deltaFromRight = dataCount + scale.lastBarRightSideDiffBarCount - dataIndex;
125
105
  // return this._extent[1] - (deltaFromRight + 0.5) * scale.barSpace - 1;
126
106
  // return Math.floor(this._extent[1] - deltaFromRight * scale.barSpace) + 0.5;
127
- return isMobile ? this._extent[1] - deltaFromRight * scale.barSpace : Math.round(this._extent[1] - deltaFromRight * scale.barSpace);
107
+ return isMobileRender ? this._extent[1] - deltaFromRight * scale.barSpace : Math.round(this._extent[1] - deltaFromRight * scale.barSpace);
128
108
  }
129
109
  if (this.onBand && scale.type === 'ordinal') {
130
110
  extent = extent.slice();
@@ -0,0 +1,47 @@
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
+ function isMobileByWidth(breakPoint) {
27
+ if (breakPoint === void 0) {
28
+ breakPoint = 768;
29
+ }
30
+ // 服务端渲染(SSR)或非浏览器环境返回false
31
+ if (typeof window === "undefined") return false;
32
+ // 获取当前视口宽度(实时检测)
33
+ var viewportWidth = window.innerWidth;
34
+ // 判断是否小于断点
35
+ return viewportWidth < breakPoint && window.devicePixelRatio !== 1;
36
+ }
37
+ function isMobileView() {
38
+ // 其次检查 User Agent
39
+ var userAgent = navigator.userAgent;
40
+ var mobileRegex = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i;
41
+ if (isMobileByWidth() && mobileRegex.test(userAgent)) {
42
+ return true;
43
+ }
44
+ return false;
45
+ }
46
+ var isMobileRender = isMobileView();
47
+ export { isMobileRender };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tvcharts",
3
- "version": "0.9.11",
3
+ "version": "0.9.13",
4
4
  "main": "dist/echarts.js",
5
5
  "module": "index.js",
6
6
  "jsdelivr": "dist/echarts.min.js",
@@ -0,0 +1,2 @@
1
+ declare const isMobileRender: boolean;
2
+ export { isMobileRender };