@easyv/charts 1.3.34 → 1.3.35

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.
@@ -244,7 +244,8 @@ 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;
248
249
  if (!(on && ticks.length > 0)) return null;
249
250
 
250
251
  var _useContext = (0, _react.useContext)(_context.chartContext),
@@ -268,7 +269,13 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref6) {
268
269
 
269
270
  var _tickSize = tickLine.tickSize || tickSize;
270
271
 
271
- return /*#__PURE__*/_react["default"].createElement(_element.Line, (0, _extends2["default"])({
272
+ var gridCoord = (0, _utils.getGridCoord)({
273
+ orientation: orientation,
274
+ coordinate: coordinate,
275
+ end: orientation == 'left' || orientation == 'right' ? width : height
276
+ });
277
+ var x1 = gridCoord.x1;
278
+ return !(orientation == "bottom" && (x1 < 0 || x1 > xLineRange)) && /*#__PURE__*/_react["default"].createElement(_element.Line, (0, _extends2["default"])({
272
279
  className: "__easyv-tickLine",
273
280
  key: index,
274
281
  config: tickLine
@@ -289,7 +296,13 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref6) {
289
296
 
290
297
  var _tickSize = tickLine.tickSize || tickSize;
291
298
 
292
- return /*#__PURE__*/_react["default"].createElement(_element.Line, (0, _extends2["default"])({
299
+ var gridCoord = (0, _utils.getGridCoord)({
300
+ orientation: orientation,
301
+ coordinate: coordinate,
302
+ end: orientation == 'left' || orientation == 'right' ? width : height
303
+ });
304
+ var x1 = gridCoord.x1;
305
+ return !(orientation == "bottom" && (x1 < 0 || x1 > xLineRange)) && /*#__PURE__*/_react["default"].createElement(_element.Line, (0, _extends2["default"])({
293
306
  className: "__easyv-tickLine",
294
307
  key: index,
295
308
  config: tickLine
@@ -306,7 +319,13 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref6) {
306
319
 
307
320
  var _tickSize = tickLine.tickSize || tickSize;
308
321
 
309
- return /*#__PURE__*/_react["default"].createElement("g", {
322
+ var gridCoord = (0, _utils.getGridCoord)({
323
+ orientation: orientation,
324
+ coordinate: coordinate,
325
+ end: orientation == 'left' || orientation == 'right' ? width : height
326
+ });
327
+ var x1 = gridCoord.x1;
328
+ return !(orientation == "bottom" && (x1 < 0 || x1 > xLineRange)) && /*#__PURE__*/_react["default"].createElement("g", {
310
329
  key: index
311
330
  }, label && /*#__PURE__*/_react["default"].createElement(Label, {
312
331
  className: "__easyv-label",
@@ -321,11 +340,7 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref6) {
321
340
  }), gridLine && /*#__PURE__*/_react["default"].createElement(_element.Line, (0, _extends2["default"])({
322
341
  className: "__easyv-gridLine",
323
342
  config: gridLine
324
- }, (0, _utils.getGridCoord)({
325
- orientation: orientation,
326
- coordinate: coordinate,
327
- end: orientation == 'left' || orientation == 'right' ? width : height
328
- }))));
343
+ }, gridCoord)));
329
344
  }), unit && /*#__PURE__*/_react["default"].createElement(Unit, {
330
345
  config: unit
331
346
  })));
@@ -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,7 @@ 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;
91
94
 
92
95
  var _useTooltip = (0, _hooks.useTooltip)({
93
96
  svg: svg,
@@ -152,11 +155,20 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
152
155
  }), (0, _toConsumableArray2["default"])(axes.values()).reverse().map(function (item, index) {
153
156
  var config = item.axisType == 'x' ? axisX : item;
154
157
  return /*#__PURE__*/_react["default"].createElement(_.Axis, (0, _extends2["default"])({
155
- triggerClick: onInteraction
158
+ triggerClick: onInteraction,
159
+ xLineRange: xLineRange
156
160
  }, config, {
157
161
  key: index
158
162
  }));
159
- }), showTooltip && /*#__PURE__*/_react["default"].createElement(_.Indicator, (0, _extends2["default"])({}, indicator, indicatorAttr)), series.map(function (_ref2, index) {
163
+ }), showTooltip && /*#__PURE__*/_react["default"].createElement(_.Indicator, (0, _extends2["default"])({}, indicator, indicatorAttr)), /*#__PURE__*/_react["default"].createElement("foreignObject", {
164
+ style: {
165
+ width: width - marginLeft - marginRight,
166
+ height: height - marginTop - marginBottom
167
+ }
168
+ }, /*#__PURE__*/_react["default"].createElement("svg", {
169
+ width: "100%",
170
+ height: "100%"
171
+ }, series.map(function (_ref2, index) {
160
172
  var Component = _ref2.Component,
161
173
  yOrZ = _ref2.yOrZ,
162
174
  config = (0, _objectWithoutProperties2["default"])(_ref2, _excluded);
@@ -182,7 +194,7 @@ var Chart = /*#__PURE__*/(0, _react.memo)(function (_ref) {
182
194
  yAxis: yAxis,
183
195
  triggerClick: onInteraction
184
196
  }));
185
- }), baseLineData && baseLineData.length > 0 && baseLineData.map(function (item, index) {
197
+ }))), baseLineData && baseLineData.length > 0 && baseLineData.map(function (item, index) {
186
198
  var yOrZ = baseLineConfig[index].line.yOrZ;
187
199
  var yAxis = axes.get(yOrZ);
188
200
  return yAxis && /*#__PURE__*/_react["default"].createElement(_.BaseLine, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easyv/charts",
3
- "version": "1.3.34",
3
+ "version": "1.3.35",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -229,11 +229,13 @@ export default memo(
229
229
  triggerClick,
230
230
  config: { on, label, axisLine, tickLine, gridLine, unit },
231
231
  positions,
232
+ xLineRange
232
233
  }: any) => {
233
234
  if (!(on && ticks.length > 0)) return null;
234
235
  const { width, height } = useContext(chartContext);
235
236
  const x = orientation == 'right' ? width : 0;
236
237
  const y = orientation == 'bottom' ? height : 0;
238
+
237
239
  return (
238
240
  <>
239
241
  {axisLine && tickLine && (
@@ -248,8 +250,17 @@ export default memo(
248
250
  const coordinate = scaler(tick);
249
251
  if (isNaN(coordinate)) return null;
250
252
  const _tickSize = tickLine.tickSize || tickSize;
253
+ const gridCoord = getGridCoord({
254
+ orientation,
255
+ coordinate,
256
+ end:
257
+ orientation == 'left' || orientation == 'right'
258
+ ? width
259
+ : height,
260
+ });
261
+ const x1 = gridCoord.x1;
251
262
  return (
252
- <Line
263
+ !(orientation=="bottom" && (x1<0 || x1>xLineRange)) && <Line
253
264
  className='__easyv-tickLine'
254
265
  key={index}
255
266
  config={tickLine}
@@ -271,8 +282,17 @@ export default memo(
271
282
  const coordinate = scaler(tick);
272
283
  if (isNaN(coordinate)) return null;
273
284
  const _tickSize = tickLine.tickSize || tickSize;
285
+ const gridCoord = getGridCoord({
286
+ orientation,
287
+ coordinate,
288
+ end:
289
+ orientation == 'left' || orientation == 'right'
290
+ ? width
291
+ : height,
292
+ });
293
+ const x1 = gridCoord.x1;
274
294
  return (
275
- <Line
295
+ !(orientation=="bottom" && (x1<0 || x1>xLineRange)) && <Line
276
296
  className='__easyv-tickLine'
277
297
  key={index}
278
298
  config={tickLine}
@@ -295,8 +315,17 @@ export default memo(
295
315
  const coordinate = scaler(tick);
296
316
  if (isNaN(coordinate)) return null;
297
317
  const _tickSize = tickLine.tickSize || tickSize;
318
+ const gridCoord = getGridCoord({
319
+ orientation,
320
+ coordinate,
321
+ end:
322
+ orientation == 'left' || orientation == 'right'
323
+ ? width
324
+ : height,
325
+ });
326
+ const x1 = gridCoord.x1;
298
327
  return (
299
- <g key={index}>
328
+ !(orientation=="bottom" && (x1<0 || x1>xLineRange)) && <g key={index}>
300
329
  {label && (
301
330
  <Label
302
331
  className='__easyv-label'
@@ -314,14 +343,7 @@ export default memo(
314
343
  <Line
315
344
  className='__easyv-gridLine'
316
345
  config={gridLine}
317
- {...getGridCoord({
318
- orientation,
319
- coordinate,
320
- end:
321
- orientation == 'left' || orientation == 'right'
322
- ? width
323
- : height,
324
- })}
346
+ {...gridCoord}
325
347
  />
326
348
  )}
327
349
  </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,7 @@ 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;
74
75
 
75
76
  const {
76
77
  x: tooltipX,
@@ -143,43 +144,49 @@ const Chart = memo(
143
144
  {[...axes.values()].reverse().map((item, index) => {
144
145
  const config = item.axisType == 'x' ? axisX : item;
145
146
  return (
146
- <Axis triggerClick={onInteraction} {...config} key={index} />
147
+ <Axis triggerClick={onInteraction} xLineRange={xLineRange} {...config} key={index} />
147
148
  );
148
149
  })}
149
150
 
150
151
  {showTooltip && <Indicator {...indicator} {...indicatorAttr} />}
151
-
152
- {series.map(({ Component, yOrZ, ...config }, index) => {
153
- const yAxis = axes.get(yOrZ);
154
- return (
155
- yAxis &&
156
- Component && (
157
- <Component
158
- key={index}
159
- {...config}
160
- bandLength={bandLength}
161
- xAxis={axisX}
162
- yAxis={yAxis}
163
- triggerClick={onInteraction}
164
- />
165
- )
166
- );
167
- })}
168
- {series.map(({ Component, yOrZ, ...config }, index) => {
169
- const yAxis = axes.get(yOrZ);
170
- return (
171
- yAxis && (
172
- <Label
173
- key={index}
174
- {...config}
175
- bandLength={bandLength}
176
- xAxis={axisX}
177
- yAxis={yAxis}
178
- triggerClick={onInteraction}
179
- />
180
- )
181
- );
182
- })}
152
+ <foreignObject style={{
153
+ width:width-marginLeft-marginRight,
154
+ height:height-marginTop-marginBottom
155
+ }}>
156
+ <svg width="100%" height="100%">
157
+ {series.map(({ Component, yOrZ, ...config }, index) => {
158
+ const yAxis = axes.get(yOrZ);
159
+ return (
160
+ yAxis &&
161
+ Component && (
162
+ <Component
163
+ key={index}
164
+ {...config}
165
+ bandLength={bandLength}
166
+ xAxis={axisX}
167
+ yAxis={yAxis}
168
+ triggerClick={onInteraction}
169
+ />
170
+ )
171
+ );
172
+ })}
173
+ {series.map(({ Component, yOrZ, ...config }, index) => {
174
+ const yAxis = axes.get(yOrZ);
175
+ return (
176
+ yAxis && (
177
+ <Label
178
+ key={index}
179
+ {...config}
180
+ bandLength={bandLength}
181
+ xAxis={axisX}
182
+ yAxis={yAxis}
183
+ triggerClick={onInteraction}
184
+ />
185
+ )
186
+ );
187
+ })}
188
+ </svg>
189
+ </foreignObject>
183
190
  {baseLineData &&
184
191
  baseLineData.length > 0 &&
185
192
  baseLineData.map((item, index) => {