@easyv/charts 1.5.13 → 1.5.14

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.
@@ -183,6 +183,10 @@ var Label = function Label(_ref5) {
183
183
  _ref5$orientation = _ref5.orientation,
184
184
  orientation = _ref5$orientation === void 0 ? defaultOrientation : _ref5$orientation,
185
185
  label = _ref5.label,
186
+ _ref5$iosTrans = _ref5.iosTrans,
187
+ isIOS = _ref5$iosTrans.isIOS,
188
+ iosX = _ref5$iosTrans.x,
189
+ iosY = _ref5$iosTrans.y,
186
190
  coordinate = _ref5.coordinate,
187
191
  _ref5$formatter = _ref5.formatter,
188
192
  formatter = _ref5$formatter === void 0 ? defaultFormatter : _ref5$formatter,
@@ -223,9 +227,9 @@ var Label = function Label(_ref5) {
223
227
 
224
228
  return /*#__PURE__*/_react["default"].createElement("foreignObject", {
225
229
  width: "1",
226
- height: "1",
227
- x: x,
228
- y: y,
230
+ height: "1" // x={x}
231
+ // y={y}
232
+ ,
229
233
  style: {
230
234
  overflow: "visible"
231
235
  }
@@ -237,7 +241,9 @@ var Label = function Label(_ref5) {
237
241
  }),
238
242
  style: _objectSpread(_objectSpread(_objectSpread({}, _style), (0, _utils.getFontStyle)(font)), {}, {
239
243
  /** Safari Bug **/
240
- position: "fixed"
244
+ position: "absolute",
245
+ left: x + (isIOS ? iosX : 0),
246
+ top: y + (isIOS ? iosY : 0)
241
247
  })
242
248
  }, /*#__PURE__*/_react["default"].createElement(_TextOverflow["default"], {
243
249
  type: textOverflow,
@@ -268,6 +274,9 @@ var _default = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef
268
274
  tickLine = _ref6$config.tickLine,
269
275
  gridLine = _ref6$config.gridLine,
270
276
  unit = _ref6$config.unit,
277
+ _ref6$margin = _ref6.margin,
278
+ marginLeft = _ref6$margin.marginLeft,
279
+ marginTop = _ref6$margin.marginTop,
271
280
  positions = _ref6.positions,
272
281
  xLineRange = _ref6.xLineRange,
273
282
  range = _ref6.range,
@@ -282,7 +291,8 @@ var _default = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef
282
291
 
283
292
  var _useContext = (0, _react.useContext)(_context.chartContext),
284
293
  width = _useContext.width,
285
- height = _useContext.height;
294
+ height = _useContext.height,
295
+ isIOS = _useContext.isIOS;
286
296
 
287
297
  var cHeight = controlInfo.cHeight,
288
298
  isC = controlInfo.isC,
@@ -349,6 +359,11 @@ var _default = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef
349
359
  className: "__easyv-label",
350
360
  orientation: orientation,
351
361
  coordinate: coordinate,
362
+ iosTrans: {
363
+ isIOS: isIOS,
364
+ x: marginLeft + x,
365
+ y: marginTop + y
366
+ },
352
367
  config: label,
353
368
  label: tick,
354
369
  tickSize: _tickSize,
@@ -89,7 +89,8 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
89
89
  isHover = _useState2[0],
90
90
  setIsHover = _useState2[1];
91
91
 
92
- var chartWidth = context.width,
92
+ var isIOS = context.isIOS,
93
+ chartWidth = context.width,
93
94
  chartHeight = context.height,
94
95
  triggerOnRelative = context.triggerOnRelative,
95
96
  onEmit = context.onEmit;
@@ -407,8 +408,12 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
407
408
  var controlChartTooltipData = ctlXName && originData.filter(function (d) {
408
409
  return d.x === ctlXName;
409
410
  });
411
+ var bodyWidth = isVertical ? xLineRange + 100 + marginRight + marginLeft : xLineRange,
412
+ bodyHeight = isVertical ? yLineRange : yLineRange + marginTop + marginBottom;
410
413
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_.ChartContainer, {
411
- style: style,
414
+ style: _objectSpread(_objectSpread({}, style), {}, {
415
+ transform: "scale(1)"
416
+ }),
412
417
  width: width,
413
418
  height: height,
414
419
  marginLeft: marginLeft,
@@ -444,19 +449,19 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
444
449
  triggerClick: onInteraction,
445
450
  xLineRange: xLineRange,
446
451
  yLineRange: yLineRange,
447
- controlInfo: controlInfo
452
+ controlInfo: controlInfo,
453
+ margin: {
454
+ marginLeft: marginLeft,
455
+ marginTop: marginTop
456
+ }
448
457
  }, config, {
449
458
  key: index
450
459
  }));
451
460
  }), showTooltip && !control && /*#__PURE__*/_react["default"].createElement(_.Indicator, (0, _extends2["default"])({}, indicator, indicatorAttr)), /*#__PURE__*/_react["default"].createElement("foreignObject", {
452
- style: isVertical ? {
453
- width: xLineRange + 100 + marginRight + marginLeft,
454
- height: yLineRange,
455
- transform: "translateX(".concat(-marginRight, "px)")
456
- } : {
457
- width: xLineRange,
458
- height: yLineRange + marginTop + marginBottom,
459
- transform: "translateY(".concat(-marginTop, "px)")
461
+ style: {
462
+ width: bodyWidth,
463
+ height: bodyHeight,
464
+ transform: isVertical ? "translateX(".concat(-marginRight, "px)") : "translateY(".concat(-marginTop, "px)")
460
465
  }
461
466
  }, /*#__PURE__*/_react["default"].createElement("svg", {
462
467
  width: "100%",
@@ -68,6 +68,7 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref2) {
68
68
  emit = _ref2.emit,
69
69
  emitEvent = _ref2.emitEvent,
70
70
  props = (0, _objectWithoutProperties2["default"])(_ref2, _excluded);
71
+ var isIOS = (0, _react.useRef)(/iPad|iPhone|iPod|iOS|CriOS/i.test(navigator.userAgent));
71
72
  var svg = /*#__PURE__*/(0, _react.createRef)();
72
73
  var chartWidth = width - marginLeft - marginRight;
73
74
  var chartHeight = height - marginTop - marginBottom;
@@ -106,6 +107,7 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref2) {
106
107
  var context = (0, _react.useMemo)(function () {
107
108
  return {
108
109
  id: id,
110
+ isIOS: isIOS.current,
109
111
  width: chartWidth,
110
112
  height: chartHeight,
111
113
  triggerOnRelative: triggerOnRelative,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easyv/charts",
3
- "version": "1.5.13",
3
+ "version": "1.5.14",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -174,6 +174,7 @@ type appearance = {
174
174
  type LabelType = {
175
175
  className: string;
176
176
  orientation: Orientation;
177
+ iosTrans: any;
177
178
  label: string;
178
179
  coordinate: number;
179
180
  formatter: Function;
@@ -196,6 +197,7 @@ const Label: (
196
197
  className,
197
198
  orientation = defaultOrientation,
198
199
  label,
200
+ iosTrans:{ isIOS, x:iosX, y:iosY },
199
201
  coordinate,
200
202
  formatter = defaultFormatter,
201
203
  tickSize,
@@ -222,39 +224,41 @@ const Label: (
222
224
  (isVertical ? coordinate : tickSize * directionY) + translateY * directionY;
223
225
 
224
226
  const _style = style && (typeof style == "object" ? style : style(_label));
225
-
227
+
226
228
  return (
227
- <foreignObject
228
- width="1"
229
- height="1"
230
- x={x}
231
- y={y}
232
- style={{ overflow: "visible" }}
233
- >
234
- <div
235
- className={className}
236
- onClick={onClick}
237
- data-data={JSON.stringify({ x: label })}
238
- style={{
239
- ..._style,
240
- ...getFontStyle(font),
241
- /** Safari Bug **/
242
- position:"fixed"
243
- }}
229
+ <foreignObject
230
+ width="1"
231
+ height="1"
232
+ // x={x}
233
+ // y={y}
234
+ style={{ overflow: "visible" }}
244
235
  >
245
- <TextOverflow
246
- type={textOverflow}
247
- speed={speed}
248
- value={_label}
236
+ <div
237
+ className={className}
238
+ onClick={onClick}
239
+ data-data={JSON.stringify({ x: label })}
249
240
  style={{
250
- width,
251
- transform,
252
- textAlign,
253
- justifyContent: textAlign=="left"?"flex-start":textAlign=="right"?"flex-end":"center",
241
+ ..._style,
242
+ ...getFontStyle(font),
243
+ /** Safari Bug **/
244
+ position:"absolute",
245
+ left:x+(isIOS?iosX:0),
246
+ top:y+(isIOS?iosY:0)
254
247
  }}
255
- ></TextOverflow>
256
- </div>
257
- </foreignObject>
248
+ >
249
+ <TextOverflow
250
+ type={textOverflow}
251
+ speed={speed}
252
+ value={_label}
253
+ style={{
254
+ width,
255
+ transform,
256
+ textAlign,
257
+ justifyContent: textAlign=="left"?"flex-start":textAlign=="right"?"flex-end":"center",
258
+ }}
259
+ ></TextOverflow>
260
+ </div>
261
+ </foreignObject>
258
262
  );
259
263
  };
260
264
 
@@ -270,6 +274,7 @@ export default memo(
270
274
  rotate,
271
275
  triggerClick,
272
276
  config: { on, label, axisLine, tickLine, gridLine, unit },
277
+ margin:{ marginLeft, marginTop },
273
278
  positions,
274
279
  xLineRange,
275
280
  range,
@@ -285,7 +290,7 @@ export default memo(
285
290
  ref
286
291
  ) => {
287
292
  if (!(on && ticks.length > 0)) return null;
288
- const { width, height } = useContext(chartContext);
293
+ const { width, height, isIOS } = useContext(chartContext);
289
294
  const { cHeight, isC, cPercent } = controlInfo;
290
295
  const x = orientation == "right" ? width : 0;
291
296
  const y = orientation == "bottom" ? height-cHeight : 0;
@@ -371,6 +376,7 @@ export default memo(
371
376
  className="__easyv-label"
372
377
  orientation={orientation}
373
378
  coordinate={coordinate}
379
+ iosTrans = {{ isIOS, x:marginLeft+x ,y:marginTop+y }}
374
380
  config={label}
375
381
  label={tick}
376
382
  tickSize={_tickSize}
@@ -69,6 +69,7 @@ const Chart = memo(
69
69
  const context = useContext(chartContext);
70
70
  const [isHover, setIsHover] = useState(false);
71
71
  const {
72
+ isIOS,
72
73
  width: chartWidth,
73
74
  height: chartHeight,
74
75
  triggerOnRelative,
@@ -337,11 +338,13 @@ const Chart = memo(
337
338
  const [ctlTip, setCtlTip] = useState(initCtlTip);
338
339
  const { show:showCtl, xName:ctlXName, x:ctlX, indicatorList:ctlIndicatorList } = ctlTip;
339
340
  const controlChartTooltipData = ctlXName && originData.filter((d) => d.x === ctlXName);
341
+ const bodyWidth = isVertical?xLineRange + 100 + marginRight + marginLeft:xLineRange,
342
+ bodyHeight = isVertical?yLineRange:yLineRange + marginTop + marginBottom;
340
343
 
341
344
  return (
342
345
  <>
343
346
  <ChartContainer
344
- style={style}
347
+ style={{...style,transform:"scale(1)"}}
345
348
  width={width}
346
349
  height={height}
347
350
  marginLeft={marginLeft}
@@ -373,6 +376,7 @@ const Chart = memo(
373
376
  </svg>
374
377
  </foreignObject>
375
378
  )}
379
+ {/* 坐标轴 */}
376
380
  {[...axes.values()].reverse().map((item, index) => {
377
381
  const config = item.axisType == "x" ? axisX : item;
378
382
  return (
@@ -384,6 +388,7 @@ const Chart = memo(
384
388
  xLineRange={xLineRange}
385
389
  yLineRange={yLineRange}
386
390
  controlInfo={controlInfo}
391
+ margin={{marginLeft,marginTop}}
387
392
  {...config}
388
393
  key={index}
389
394
  />
@@ -395,17 +400,11 @@ const Chart = memo(
395
400
 
396
401
  <foreignObject
397
402
  style={
398
- isVertical
399
- ? {
400
- width: xLineRange + 100 + marginRight + marginLeft,
401
- height: yLineRange,
402
- transform: `translateX(${-marginRight}px)`,
403
- }
404
- : {
405
- width: xLineRange,
406
- height: yLineRange + marginTop + marginBottom,
407
- transform: `translateY(${-marginTop}px)`,
408
- }
403
+ {
404
+ width:bodyWidth,
405
+ height:bodyHeight,
406
+ transform:isVertical?`translateX(${-marginRight}px)`:`translateY(${-marginTop}px)`
407
+ }
409
408
  }
410
409
  >
411
410
  <svg
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * 总入口,通过外面传进来的type来确定渲染哪种图表,饼环图表为“pie”,否则为轴类图表
3
3
  */
4
- import React, { memo, useMemo, createRef, useState, useEffect, useCallback } from 'react';
4
+ import React, { memo, useMemo, useRef, createRef, useState, useEffect, useCallback } from 'react';
5
5
  import { chartContext } from '../context';
6
6
  import { PieChart, CartesianChart } from '.';
7
7
  import { group } from 'd3v7';
@@ -39,10 +39,10 @@ const Chart = memo(
39
39
  emitEvent,
40
40
  ...props
41
41
  }) => {
42
+ const isIOS = useRef(/iPad|iPhone|iPod|iOS|CriOS/i.test(navigator.userAgent));
42
43
  const svg = createRef();
43
44
  const chartWidth = width - marginLeft - marginRight;
44
45
  const chartHeight = height - marginTop - marginBottom;
45
-
46
46
  const [active, setActive] = useState(true);
47
47
 
48
48
  const triggerOnRelative = useCallback(
@@ -81,6 +81,7 @@ const Chart = memo(
81
81
  const context = useMemo(
82
82
  () => ({
83
83
  id,
84
+ isIOS:isIOS.current,
84
85
  width: chartWidth,
85
86
  height: chartHeight,
86
87
  triggerOnRelative,