@easyv/charts 1.5.12 → 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.
- package/lib/components/Axis.js +23 -5
- package/lib/components/Band.js +1 -1
- package/lib/components/CartesianChart.js +17 -11
- package/lib/components/Chart.js +2 -0
- package/package.json +1 -1
- package/src/components/Axis.tsx +36 -28
- package/src/components/Band.tsx +1 -1
- package/src/components/CartesianChart.js +12 -12
- package/src/components/Chart.js +3 -2
package/lib/components/Axis.js
CHANGED
|
@@ -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
|
-
|
|
228
|
-
|
|
230
|
+
height: "1" // x={x}
|
|
231
|
+
// y={y}
|
|
232
|
+
,
|
|
229
233
|
style: {
|
|
230
234
|
overflow: "visible"
|
|
231
235
|
}
|
|
@@ -235,7 +239,12 @@ var Label = function Label(_ref5) {
|
|
|
235
239
|
"data-data": JSON.stringify({
|
|
236
240
|
x: label
|
|
237
241
|
}),
|
|
238
|
-
style: _objectSpread(_objectSpread({}, _style), (0, _utils.getFontStyle)(font))
|
|
242
|
+
style: _objectSpread(_objectSpread(_objectSpread({}, _style), (0, _utils.getFontStyle)(font)), {}, {
|
|
243
|
+
/** Safari Bug **/
|
|
244
|
+
position: "absolute",
|
|
245
|
+
left: x + (isIOS ? iosX : 0),
|
|
246
|
+
top: y + (isIOS ? iosY : 0)
|
|
247
|
+
})
|
|
239
248
|
}, /*#__PURE__*/_react["default"].createElement(_TextOverflow["default"], {
|
|
240
249
|
type: textOverflow,
|
|
241
250
|
speed: speed,
|
|
@@ -265,6 +274,9 @@ var _default = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef
|
|
|
265
274
|
tickLine = _ref6$config.tickLine,
|
|
266
275
|
gridLine = _ref6$config.gridLine,
|
|
267
276
|
unit = _ref6$config.unit,
|
|
277
|
+
_ref6$margin = _ref6.margin,
|
|
278
|
+
marginLeft = _ref6$margin.marginLeft,
|
|
279
|
+
marginTop = _ref6$margin.marginTop,
|
|
268
280
|
positions = _ref6.positions,
|
|
269
281
|
xLineRange = _ref6.xLineRange,
|
|
270
282
|
range = _ref6.range,
|
|
@@ -279,7 +291,8 @@ var _default = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef
|
|
|
279
291
|
|
|
280
292
|
var _useContext = (0, _react.useContext)(_context.chartContext),
|
|
281
293
|
width = _useContext.width,
|
|
282
|
-
height = _useContext.height
|
|
294
|
+
height = _useContext.height,
|
|
295
|
+
isIOS = _useContext.isIOS;
|
|
283
296
|
|
|
284
297
|
var cHeight = controlInfo.cHeight,
|
|
285
298
|
isC = controlInfo.isC,
|
|
@@ -346,6 +359,11 @@ var _default = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef
|
|
|
346
359
|
className: "__easyv-label",
|
|
347
360
|
orientation: orientation,
|
|
348
361
|
coordinate: coordinate,
|
|
362
|
+
iosTrans: {
|
|
363
|
+
isIOS: isIOS,
|
|
364
|
+
x: marginLeft + x,
|
|
365
|
+
y: marginTop + y
|
|
366
|
+
},
|
|
349
367
|
config: label,
|
|
350
368
|
label: tick,
|
|
351
369
|
tickSize: _tickSize,
|
package/lib/components/Band.js
CHANGED
|
@@ -266,7 +266,7 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref3) {
|
|
|
266
266
|
height: "100%",
|
|
267
267
|
|
|
268
268
|
/** Safari Bug **/
|
|
269
|
-
position: "fixed",
|
|
269
|
+
// position: "fixed",
|
|
270
270
|
clipPath: setClipPath(),
|
|
271
271
|
opacity: fillType == "pattern" ? opacity : 1,
|
|
272
272
|
background: fillType == "pattern" ? "50% 50% / ".concat(size.width, "px ").concat(size.height, "px repeat ") + "url(" + url + ")" : (0, _utils.getBandBackground)(pattern, extent === flag ? highlightFill : fill),
|
|
@@ -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
|
|
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:
|
|
453
|
-
width:
|
|
454
|
-
height:
|
|
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%",
|
|
@@ -464,6 +469,7 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
464
469
|
ref: seriesEl,
|
|
465
470
|
style: {
|
|
466
471
|
overflow: "visible",
|
|
472
|
+
position: "fixed",
|
|
467
473
|
transform: isVertical ? "translateX(".concat(marginRight, "px)") : "translateY(".concat(marginTop, "px)")
|
|
468
474
|
}
|
|
469
475
|
}, /*#__PURE__*/_react["default"].createElement("g", null, control && ctlIndicatorList.map(function (item, index) {
|
package/lib/components/Chart.js
CHANGED
|
@@ -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
package/src/components/Axis.tsx
CHANGED
|
@@ -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,37 +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
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
>
|
|
234
|
-
<div
|
|
235
|
-
className={className}
|
|
236
|
-
onClick={onClick}
|
|
237
|
-
data-data={JSON.stringify({ x: label })}
|
|
238
|
-
style={{
|
|
239
|
-
..._style,
|
|
240
|
-
...getFontStyle(font),
|
|
241
|
-
}}
|
|
229
|
+
<foreignObject
|
|
230
|
+
width="1"
|
|
231
|
+
height="1"
|
|
232
|
+
// x={x}
|
|
233
|
+
// y={y}
|
|
234
|
+
style={{ overflow: "visible" }}
|
|
242
235
|
>
|
|
243
|
-
<
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
236
|
+
<div
|
|
237
|
+
className={className}
|
|
238
|
+
onClick={onClick}
|
|
239
|
+
data-data={JSON.stringify({ x: label })}
|
|
247
240
|
style={{
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
241
|
+
..._style,
|
|
242
|
+
...getFontStyle(font),
|
|
243
|
+
/** Safari Bug **/
|
|
244
|
+
position:"absolute",
|
|
245
|
+
left:x+(isIOS?iosX:0),
|
|
246
|
+
top:y+(isIOS?iosY:0)
|
|
252
247
|
}}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
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>
|
|
256
262
|
);
|
|
257
263
|
};
|
|
258
264
|
|
|
@@ -268,6 +274,7 @@ export default memo(
|
|
|
268
274
|
rotate,
|
|
269
275
|
triggerClick,
|
|
270
276
|
config: { on, label, axisLine, tickLine, gridLine, unit },
|
|
277
|
+
margin:{ marginLeft, marginTop },
|
|
271
278
|
positions,
|
|
272
279
|
xLineRange,
|
|
273
280
|
range,
|
|
@@ -283,7 +290,7 @@ export default memo(
|
|
|
283
290
|
ref
|
|
284
291
|
) => {
|
|
285
292
|
if (!(on && ticks.length > 0)) return null;
|
|
286
|
-
const { width, height } = useContext(chartContext);
|
|
293
|
+
const { width, height, isIOS } = useContext(chartContext);
|
|
287
294
|
const { cHeight, isC, cPercent } = controlInfo;
|
|
288
295
|
const x = orientation == "right" ? width : 0;
|
|
289
296
|
const y = orientation == "bottom" ? height-cHeight : 0;
|
|
@@ -369,6 +376,7 @@ export default memo(
|
|
|
369
376
|
className="__easyv-label"
|
|
370
377
|
orientation={orientation}
|
|
371
378
|
coordinate={coordinate}
|
|
379
|
+
iosTrans = {{ isIOS, x:marginLeft+x ,y:marginTop+y }}
|
|
372
380
|
config={label}
|
|
373
381
|
label={tick}
|
|
374
382
|
tickSize={_tickSize}
|
package/src/components/Band.tsx
CHANGED
|
@@ -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
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
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
|
|
@@ -414,6 +413,7 @@ const Chart = memo(
|
|
|
414
413
|
ref={seriesEl}
|
|
415
414
|
style={{
|
|
416
415
|
overflow: "visible",
|
|
416
|
+
position: "fixed",
|
|
417
417
|
transform: isVertical
|
|
418
418
|
? `translateX(${marginRight}px)`
|
|
419
419
|
: `translateY(${marginTop}px)`,
|
package/src/components/Chart.js
CHANGED
|
@@ -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,
|