@easyv/charts 1.3.34 → 1.3.36
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
CHANGED
|
@@ -244,7 +244,9 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref6) {
|
|
|
244
244
|
tickLine = _ref6$config.tickLine,
|
|
245
245
|
gridLine = _ref6$config.gridLine,
|
|
246
246
|
unit = _ref6$config.unit,
|
|
247
|
-
positions = _ref6.positions
|
|
247
|
+
positions = _ref6.positions,
|
|
248
|
+
xLineRange = _ref6.xLineRange,
|
|
249
|
+
yLineRange = _ref6.yLineRange;
|
|
248
250
|
if (!(on && ticks.length > 0)) return null;
|
|
249
251
|
|
|
250
252
|
var _useContext = (0, _react.useContext)(_context.chartContext),
|
|
@@ -268,7 +270,14 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref6) {
|
|
|
268
270
|
|
|
269
271
|
var _tickSize = tickLine.tickSize || tickSize;
|
|
270
272
|
|
|
271
|
-
|
|
273
|
+
var gridCoord = (0, _utils.getGridCoord)({
|
|
274
|
+
orientation: orientation,
|
|
275
|
+
coordinate: coordinate,
|
|
276
|
+
end: orientation == 'left' || orientation == 'right' ? width : height
|
|
277
|
+
});
|
|
278
|
+
var x1 = gridCoord.x1;
|
|
279
|
+
var y1 = gridCoord.y1;
|
|
280
|
+
return !(orientation == "bottom" && (x1 < 0 || x1 > xLineRange) || y1 < 0 || y1 > yLineRange) && /*#__PURE__*/_react["default"].createElement(_element.Line, (0, _extends2["default"])({
|
|
272
281
|
className: "__easyv-tickLine",
|
|
273
282
|
key: index,
|
|
274
283
|
config: tickLine
|
|
@@ -289,7 +298,14 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref6) {
|
|
|
289
298
|
|
|
290
299
|
var _tickSize = tickLine.tickSize || tickSize;
|
|
291
300
|
|
|
292
|
-
|
|
301
|
+
var gridCoord = (0, _utils.getGridCoord)({
|
|
302
|
+
orientation: orientation,
|
|
303
|
+
coordinate: coordinate,
|
|
304
|
+
end: orientation == 'left' || orientation == 'right' ? width : height
|
|
305
|
+
});
|
|
306
|
+
var x1 = gridCoord.x1;
|
|
307
|
+
var y1 = gridCoord.y1;
|
|
308
|
+
return !(orientation == "bottom" && (x1 < 0 || x1 > xLineRange) || y1 < 0 || y1 > yLineRange) && /*#__PURE__*/_react["default"].createElement(_element.Line, (0, _extends2["default"])({
|
|
293
309
|
className: "__easyv-tickLine",
|
|
294
310
|
key: index,
|
|
295
311
|
config: tickLine
|
|
@@ -306,7 +322,14 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref6) {
|
|
|
306
322
|
|
|
307
323
|
var _tickSize = tickLine.tickSize || tickSize;
|
|
308
324
|
|
|
309
|
-
|
|
325
|
+
var gridCoord = (0, _utils.getGridCoord)({
|
|
326
|
+
orientation: orientation,
|
|
327
|
+
coordinate: coordinate,
|
|
328
|
+
end: orientation == 'left' || orientation == 'right' ? width : height
|
|
329
|
+
});
|
|
330
|
+
var x1 = gridCoord.x1;
|
|
331
|
+
var y1 = gridCoord.y1;
|
|
332
|
+
return !(orientation == "bottom" && (x1 < 0 || x1 > xLineRange) || y1 < 0 || y1 > yLineRange) && /*#__PURE__*/_react["default"].createElement("g", {
|
|
310
333
|
key: index
|
|
311
334
|
}, label && /*#__PURE__*/_react["default"].createElement(Label, {
|
|
312
335
|
className: "__easyv-label",
|
|
@@ -321,11 +344,7 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref6) {
|
|
|
321
344
|
}), gridLine && /*#__PURE__*/_react["default"].createElement(_element.Line, (0, _extends2["default"])({
|
|
322
345
|
className: "__easyv-gridLine",
|
|
323
346
|
config: gridLine
|
|
324
|
-
},
|
|
325
|
-
orientation: orientation,
|
|
326
|
-
coordinate: coordinate,
|
|
327
|
-
end: orientation == 'left' || orientation == 'right' ? width : height
|
|
328
|
-
}))));
|
|
347
|
+
}, gridCoord)));
|
|
329
348
|
}), unit && /*#__PURE__*/_react["default"].createElement(Unit, {
|
|
330
349
|
config: unit
|
|
331
350
|
})));
|
|
@@ -43,6 +43,8 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
43
43
|
_ref$config$chart$mar = _ref$config$chart.margin,
|
|
44
44
|
marginLeft = _ref$config$chart$mar.marginLeft,
|
|
45
45
|
marginTop = _ref$config$chart$mar.marginTop,
|
|
46
|
+
marginRight = _ref$config$chart$mar.marginRight,
|
|
47
|
+
marginBottom = _ref$config$chart$mar.marginBottom,
|
|
46
48
|
animation = _ref$config$chart.animation,
|
|
47
49
|
legend = _ref$config$chart.legend,
|
|
48
50
|
series = _ref$config.series,
|
|
@@ -88,6 +90,8 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
88
90
|
context: context
|
|
89
91
|
});
|
|
90
92
|
var axisX = (0, _hooks.useCarouselAxisX)(axes.get('x'), animation, isHover);
|
|
93
|
+
var xLineRange = width - marginLeft - marginRight;
|
|
94
|
+
var yLineRange = height - marginTop - marginBottom;
|
|
91
95
|
|
|
92
96
|
var _useTooltip = (0, _hooks.useTooltip)({
|
|
93
97
|
svg: svg,
|
|
@@ -144,19 +148,37 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
144
148
|
setIndex(e);
|
|
145
149
|
},
|
|
146
150
|
ref: svg
|
|
147
|
-
}, background && /*#__PURE__*/_react["default"].createElement(
|
|
151
|
+
}, background && /*#__PURE__*/_react["default"].createElement("foreignObject", {
|
|
152
|
+
style: {
|
|
153
|
+
width: xLineRange,
|
|
154
|
+
height: yLineRange
|
|
155
|
+
}
|
|
156
|
+
}, /*#__PURE__*/_react["default"].createElement("svg", {
|
|
157
|
+
width: "100%",
|
|
158
|
+
height: "100%"
|
|
159
|
+
}, /*#__PURE__*/_react["default"].createElement(_.Background, {
|
|
148
160
|
length: isVertical ? chartWidth : chartHeight,
|
|
149
161
|
axis: axisX,
|
|
150
162
|
config: background,
|
|
151
163
|
bandLength: bandLength
|
|
152
|
-
}), (0, _toConsumableArray2["default"])(axes.values()).reverse().map(function (item, index) {
|
|
164
|
+
}))), (0, _toConsumableArray2["default"])(axes.values()).reverse().map(function (item, index) {
|
|
153
165
|
var config = item.axisType == 'x' ? axisX : item;
|
|
154
166
|
return /*#__PURE__*/_react["default"].createElement(_.Axis, (0, _extends2["default"])({
|
|
155
|
-
triggerClick: onInteraction
|
|
167
|
+
triggerClick: onInteraction,
|
|
168
|
+
xLineRange: xLineRange,
|
|
169
|
+
yLineRange: yLineRange
|
|
156
170
|
}, config, {
|
|
157
171
|
key: index
|
|
158
172
|
}));
|
|
159
|
-
}), showTooltip && /*#__PURE__*/_react["default"].createElement(_.Indicator, (0, _extends2["default"])({}, indicator, indicatorAttr)),
|
|
173
|
+
}), showTooltip && /*#__PURE__*/_react["default"].createElement(_.Indicator, (0, _extends2["default"])({}, indicator, indicatorAttr)), /*#__PURE__*/_react["default"].createElement("foreignObject", {
|
|
174
|
+
style: {
|
|
175
|
+
width: xLineRange,
|
|
176
|
+
height: yLineRange
|
|
177
|
+
}
|
|
178
|
+
}, /*#__PURE__*/_react["default"].createElement("svg", {
|
|
179
|
+
width: "100%",
|
|
180
|
+
height: "100%"
|
|
181
|
+
}, series.map(function (_ref2, index) {
|
|
160
182
|
var Component = _ref2.Component,
|
|
161
183
|
yOrZ = _ref2.yOrZ,
|
|
162
184
|
config = (0, _objectWithoutProperties2["default"])(_ref2, _excluded);
|
|
@@ -182,7 +204,7 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
182
204
|
yAxis: yAxis,
|
|
183
205
|
triggerClick: onInteraction
|
|
184
206
|
}));
|
|
185
|
-
}), baseLineData && baseLineData.length > 0 && baseLineData.map(function (item, index) {
|
|
207
|
+
}))), baseLineData && baseLineData.length > 0 && baseLineData.map(function (item, index) {
|
|
186
208
|
var yOrZ = baseLineConfig[index].line.yOrZ;
|
|
187
209
|
var yAxis = axes.get(yOrZ);
|
|
188
210
|
return yAxis && /*#__PURE__*/_react["default"].createElement(_.BaseLine, {
|
package/package.json
CHANGED
package/src/components/Axis.tsx
CHANGED
|
@@ -229,11 +229,14 @@ export default memo(
|
|
|
229
229
|
triggerClick,
|
|
230
230
|
config: { on, label, axisLine, tickLine, gridLine, unit },
|
|
231
231
|
positions,
|
|
232
|
+
xLineRange,
|
|
233
|
+
yLineRange
|
|
232
234
|
}: any) => {
|
|
233
235
|
if (!(on && ticks.length > 0)) return null;
|
|
234
236
|
const { width, height } = useContext(chartContext);
|
|
235
237
|
const x = orientation == 'right' ? width : 0;
|
|
236
238
|
const y = orientation == 'bottom' ? height : 0;
|
|
239
|
+
|
|
237
240
|
return (
|
|
238
241
|
<>
|
|
239
242
|
{axisLine && tickLine && (
|
|
@@ -248,8 +251,18 @@ export default memo(
|
|
|
248
251
|
const coordinate = scaler(tick);
|
|
249
252
|
if (isNaN(coordinate)) return null;
|
|
250
253
|
const _tickSize = tickLine.tickSize || tickSize;
|
|
254
|
+
const gridCoord = getGridCoord({
|
|
255
|
+
orientation,
|
|
256
|
+
coordinate,
|
|
257
|
+
end:
|
|
258
|
+
orientation == 'left' || orientation == 'right'
|
|
259
|
+
? width
|
|
260
|
+
: height,
|
|
261
|
+
});
|
|
262
|
+
const x1 = gridCoord.x1;
|
|
263
|
+
const y1 = gridCoord.y1;
|
|
251
264
|
return (
|
|
252
|
-
<Line
|
|
265
|
+
!(orientation=="bottom" && (x1<0 || x1>xLineRange) || (y1<0 || y1>yLineRange) ) && <Line
|
|
253
266
|
className='__easyv-tickLine'
|
|
254
267
|
key={index}
|
|
255
268
|
config={tickLine}
|
|
@@ -271,8 +284,18 @@ export default memo(
|
|
|
271
284
|
const coordinate = scaler(tick);
|
|
272
285
|
if (isNaN(coordinate)) return null;
|
|
273
286
|
const _tickSize = tickLine.tickSize || tickSize;
|
|
287
|
+
const gridCoord = getGridCoord({
|
|
288
|
+
orientation,
|
|
289
|
+
coordinate,
|
|
290
|
+
end:
|
|
291
|
+
orientation == 'left' || orientation == 'right'
|
|
292
|
+
? width
|
|
293
|
+
: height,
|
|
294
|
+
});
|
|
295
|
+
const x1 = gridCoord.x1;
|
|
296
|
+
const y1 = gridCoord.y1;
|
|
274
297
|
return (
|
|
275
|
-
<Line
|
|
298
|
+
!(orientation=="bottom" && (x1<0 || x1>xLineRange) || (y1<0 || y1>yLineRange)) && <Line
|
|
276
299
|
className='__easyv-tickLine'
|
|
277
300
|
key={index}
|
|
278
301
|
config={tickLine}
|
|
@@ -295,8 +318,18 @@ export default memo(
|
|
|
295
318
|
const coordinate = scaler(tick);
|
|
296
319
|
if (isNaN(coordinate)) return null;
|
|
297
320
|
const _tickSize = tickLine.tickSize || tickSize;
|
|
321
|
+
const gridCoord = getGridCoord({
|
|
322
|
+
orientation,
|
|
323
|
+
coordinate,
|
|
324
|
+
end:
|
|
325
|
+
orientation == 'left' || orientation == 'right'
|
|
326
|
+
? width
|
|
327
|
+
: height,
|
|
328
|
+
});
|
|
329
|
+
const x1 = gridCoord.x1;
|
|
330
|
+
const y1 = gridCoord.y1;
|
|
298
331
|
return (
|
|
299
|
-
<g key={index}>
|
|
332
|
+
!(orientation=="bottom" && (x1<0 || x1>xLineRange) || (y1<0 || y1>yLineRange)) && <g key={index}>
|
|
300
333
|
{label && (
|
|
301
334
|
<Label
|
|
302
335
|
className='__easyv-label'
|
|
@@ -314,14 +347,7 @@ export default memo(
|
|
|
314
347
|
<Line
|
|
315
348
|
className='__easyv-gridLine'
|
|
316
349
|
config={gridLine}
|
|
317
|
-
{...
|
|
318
|
-
orientation,
|
|
319
|
-
coordinate,
|
|
320
|
-
end:
|
|
321
|
-
orientation == 'left' || orientation == 'right'
|
|
322
|
-
? width
|
|
323
|
-
: height,
|
|
324
|
-
})}
|
|
350
|
+
{...gridCoord}
|
|
325
351
|
/>
|
|
326
352
|
)}
|
|
327
353
|
</g>
|
|
@@ -37,7 +37,7 @@ const Chart = memo(
|
|
|
37
37
|
dimension: {
|
|
38
38
|
chartDimension: { height, width },
|
|
39
39
|
},
|
|
40
|
-
margin: { marginLeft, marginTop },
|
|
40
|
+
margin: { marginLeft, marginTop, marginRight, marginBottom },
|
|
41
41
|
animation,
|
|
42
42
|
legend,
|
|
43
43
|
},
|
|
@@ -71,6 +71,8 @@ const Chart = memo(
|
|
|
71
71
|
const svg = createRef();
|
|
72
72
|
const axes = useAxes({ axes: axesConfig, context });
|
|
73
73
|
const axisX = useCarouselAxisX(axes.get('x'), animation, isHover);
|
|
74
|
+
const xLineRange = width-marginLeft-marginRight;
|
|
75
|
+
const yLineRange = height-marginTop-marginBottom;
|
|
74
76
|
|
|
75
77
|
const {
|
|
76
78
|
x: tooltipX,
|
|
@@ -133,53 +135,66 @@ const Chart = memo(
|
|
|
133
135
|
ref={svg}
|
|
134
136
|
>
|
|
135
137
|
{background && (
|
|
136
|
-
<
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
138
|
+
<foreignObject style={{
|
|
139
|
+
width:xLineRange,
|
|
140
|
+
height:yLineRange
|
|
141
|
+
}}>
|
|
142
|
+
<svg width="100%" height="100%">
|
|
143
|
+
<Background
|
|
144
|
+
length={isVertical ? chartWidth : chartHeight}
|
|
145
|
+
axis={axisX}
|
|
146
|
+
config={background}
|
|
147
|
+
bandLength={bandLength}
|
|
148
|
+
/>
|
|
149
|
+
</svg>
|
|
150
|
+
</foreignObject>
|
|
142
151
|
)}
|
|
143
|
-
{[...axes.values()].reverse().map((item, index) => {
|
|
152
|
+
{[...axes.values()].reverse().map((item, index) => {
|
|
144
153
|
const config = item.axisType == 'x' ? axisX : item;
|
|
145
154
|
return (
|
|
146
|
-
<Axis triggerClick={onInteraction} {...config} key={index} />
|
|
155
|
+
<Axis triggerClick={onInteraction} xLineRange={xLineRange} yLineRange={yLineRange} {...config} key={index} />
|
|
147
156
|
);
|
|
148
157
|
})}
|
|
149
158
|
|
|
150
159
|
{showTooltip && <Indicator {...indicator} {...indicatorAttr} />}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
Component
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
160
|
+
<foreignObject style={{
|
|
161
|
+
width:xLineRange,
|
|
162
|
+
height:yLineRange
|
|
163
|
+
}}>
|
|
164
|
+
<svg width="100%" height="100%">
|
|
165
|
+
{series.map(({ Component, yOrZ, ...config }, index) => {
|
|
166
|
+
const yAxis = axes.get(yOrZ);
|
|
167
|
+
return (
|
|
168
|
+
yAxis &&
|
|
169
|
+
Component && (
|
|
170
|
+
<Component
|
|
171
|
+
key={index}
|
|
172
|
+
{...config}
|
|
173
|
+
bandLength={bandLength}
|
|
174
|
+
xAxis={axisX}
|
|
175
|
+
yAxis={yAxis}
|
|
176
|
+
triggerClick={onInteraction}
|
|
177
|
+
/>
|
|
178
|
+
)
|
|
179
|
+
);
|
|
180
|
+
})}
|
|
181
|
+
{series.map(({ Component, yOrZ, ...config }, index) => {
|
|
182
|
+
const yAxis = axes.get(yOrZ);
|
|
183
|
+
return (
|
|
184
|
+
yAxis && (
|
|
185
|
+
<Label
|
|
186
|
+
key={index}
|
|
187
|
+
{...config}
|
|
188
|
+
bandLength={bandLength}
|
|
189
|
+
xAxis={axisX}
|
|
190
|
+
yAxis={yAxis}
|
|
191
|
+
triggerClick={onInteraction}
|
|
192
|
+
/>
|
|
193
|
+
)
|
|
194
|
+
);
|
|
195
|
+
})}
|
|
196
|
+
</svg>
|
|
197
|
+
</foreignObject>
|
|
183
198
|
{baseLineData &&
|
|
184
199
|
baseLineData.length > 0 &&
|
|
185
200
|
baseLineData.map((item, index) => {
|