@easyv/charts 1.4.37 → 1.4.39

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.
@@ -54,7 +54,7 @@ var defaultFormatter = function defaultFormatter(d, _ref) {
54
54
  return d + suffix;
55
55
  };
56
56
 
57
- var getAxesPath = function getAxesPath(orientation, _ref2) {
57
+ var getAxesPath = function getAxesPath(orientation, _ref2, cHeight) {
58
58
  var width = _ref2.width,
59
59
  height = _ref2.height;
60
60
 
@@ -65,7 +65,7 @@ var getAxesPath = function getAxesPath(orientation, _ref2) {
65
65
 
66
66
  case "left":
67
67
  case "right":
68
- return "M0, -0.5V" + (height + 0.5);
68
+ return "M0, -0.5V" + (height + 0.5 - cHeight);
69
69
  }
70
70
  };
71
71
  /**
@@ -119,14 +119,13 @@ var AxisLine = function AxisLine(_ref3) {
119
119
  show = _ref3$config.show,
120
120
  color = _ref3$config.color,
121
121
  lineWidth = _ref3$config.lineWidth,
122
+ cHeight = _ref3$config.cHeight,
122
123
  _ref3$isClipAxis = _ref3.isClipAxis,
123
124
  isClipAxis = _ref3$isClipAxis === void 0 ? false : _ref3$isClipAxis,
124
125
  _ref3$clipAxisRange = _ref3.clipAxisRange,
125
126
  clipAxisRange = _ref3$clipAxisRange === void 0 ? [] : _ref3$clipAxisRange;
126
127
  if (!show) return null;
127
128
  var context = (0, _react.useContext)(_context.chartContext);
128
- var width = context.width,
129
- height = context.height;
130
129
 
131
130
  if (isClipAxis) {
132
131
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, clipAxisRange.map(function (range, index) {
@@ -139,7 +138,7 @@ var AxisLine = function AxisLine(_ref3) {
139
138
  }));
140
139
  } else {
141
140
  return /*#__PURE__*/_react["default"].createElement("path", {
142
- d: getAxesPath(orientation, context),
141
+ d: getAxesPath(orientation, context, cHeight),
143
142
  stroke: color,
144
143
  strokeWidth: lineWidth
145
144
  });
@@ -262,7 +261,6 @@ var _default = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef
262
261
  tickLine = _ref6$config.tickLine,
263
262
  gridLine = _ref6$config.gridLine,
264
263
  unit = _ref6$config.unit,
265
- config = _ref6.config,
266
264
  positions = _ref6.positions,
267
265
  xLineRange = _ref6.xLineRange,
268
266
  range = _ref6.range,
@@ -373,7 +371,9 @@ var _default = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef
373
371
  transform: "translate(" + x + ", " + y + ")"
374
372
  }, /*#__PURE__*/_react["default"].createElement(AxisLine, {
375
373
  orientation: orientation,
376
- config: axisLine,
374
+ config: _objectSpread(_objectSpread({}, axisLine), {}, {
375
+ cHeight: cHeight
376
+ }),
377
377
  range: range
378
378
  }), tickLine && ticks.map(function (tick, index) {
379
379
  var coordinate = scaler(tick);
@@ -402,7 +402,9 @@ var _default = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef
402
402
  transform: "translate(" + x + ", " + y + ")"
403
403
  }, /*#__PURE__*/_react["default"].createElement(AxisLine, {
404
404
  orientation: orientation,
405
- config: axisLine,
405
+ config: _objectSpread(_objectSpread({}, axisLine), {}, {
406
+ cHeight: cHeight
407
+ }),
406
408
  isClipAxis: isClipAxis,
407
409
  clipAxisRange: clipAxisRange
408
410
  }), tickLine && drawAxisTickLine()))), /*#__PURE__*/_react["default"].createElement("svg", {
@@ -205,43 +205,46 @@ var _default = /*#__PURE__*/(0, _react.memo)(function (_ref3) {
205
205
  style: {
206
206
  overflow: "visible",
207
207
  position: "relative",
208
- pointerEvents: isControlChart ? "auto" : "none",
209
208
  cursor: "pointer"
210
209
  }
211
210
  }, attr, {
212
211
  onClick: triggerClick //enter和leave事件,用于控制图的提示框
213
212
  ,
214
213
  onMouseEnter: function onMouseEnter() {
215
- setCtlTip(function (pre) {
216
- return {
217
- show: true,
218
- x: xScaler(x),
219
- xName: data.x,
220
- indicatorList: pre.indicatorList.map(function (item) {
221
- if (item.tick === data.x) {
222
- return _objectSpread(_objectSpread({}, item), {}, {
223
- isShow: true
224
- });
225
- } else {
226
- return item;
227
- }
228
- })
229
- };
230
- });
214
+ if (isControlChart) {
215
+ setCtlTip(function (pre) {
216
+ return {
217
+ show: true,
218
+ x: xScaler(x),
219
+ xName: data.x,
220
+ indicatorList: pre.indicatorList.map(function (item) {
221
+ if (item.tick === data.x) {
222
+ return _objectSpread(_objectSpread({}, item), {}, {
223
+ isShow: true
224
+ });
225
+ } else {
226
+ return item;
227
+ }
228
+ })
229
+ };
230
+ });
231
+ }
231
232
  },
232
233
  onMouseLeave: function onMouseLeave() {
233
- setCtlTip(function (pre) {
234
- return {
235
- show: false,
236
- x: undefined,
237
- xName: undefined,
238
- indicatorList: pre.indicatorList.map(function (item) {
239
- return _objectSpread(_objectSpread({}, item), {}, {
240
- isShow: false
241
- });
242
- })
243
- };
244
- });
234
+ if (isControlChart) {
235
+ setCtlTip(function (pre) {
236
+ return {
237
+ show: false,
238
+ x: undefined,
239
+ xName: undefined,
240
+ indicatorList: pre.indicatorList.map(function (item) {
241
+ return _objectSpread(_objectSpread({}, item), {}, {
242
+ isShow: false
243
+ });
244
+ })
245
+ };
246
+ });
247
+ }
245
248
  },
246
249
  "data-data": JSON.stringify(data)
247
250
  }), headUrl && showHead && /*#__PURE__*/_react["default"].createElement("div", {
@@ -67,7 +67,7 @@ var _default = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef
67
67
  cursor: "col-resize",
68
68
  background: "rgb(2, 176, 249)",
69
69
  WebkitBackgroundClip: "content-box"
70
- };
70
+ }; //滑块的鼠标按下操作
71
71
 
72
72
  var down = function down() {
73
73
  var transform = ref.current.style.transform;
@@ -89,7 +89,15 @@ var _default = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef
89
89
  document.addEventListener("mousemove", mouseMoveHandle);
90
90
  document.addEventListener("mouseup", mouseUpHandle);
91
91
  setWorking(true);
92
- };
92
+ }; // //右手柄的鼠标按下逻辑
93
+ // const rightDown=()=>{
94
+ // const move=(e)=>{
95
+ // }
96
+ // const up=()=>{
97
+ // }
98
+ // document.addEventListener()
99
+ // }
100
+
93
101
 
94
102
  return /*#__PURE__*/_react["default"].createElement("div", {
95
103
  style: {
@@ -35,7 +35,13 @@ var getCount = function getCount(num) {
35
35
  };
36
36
 
37
37
  var getNewDomain = function getNewDomain(domain, mode, step) {
38
- var newDomain = [];
38
+ var extent = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
39
+ var _extent$min = extent.min,
40
+ bottom = _extent$min === void 0 ? "" : _extent$min,
41
+ _extent$max = extent.max,
42
+ top = _extent$max === void 0 ? "" : _extent$max;
43
+ var newDomain = []; //能进入这个函数,说明extent中min和max至少有一个是缺失的,如果max存在,意味着纵轴上限被固定
44
+
39
45
  var min = domain[0],
40
46
  max = domain[1];
41
47
  var minCount = Math.pow(10, getCount(min)),
@@ -43,17 +49,26 @@ var getNewDomain = function getNewDomain(domain, mode, step) {
43
49
 
44
50
  switch (mode) {
45
51
  case "count":
46
- newDomain[0] = Math.floor(domain[0] / minCount) * minCount;
47
- newDomain[1] = Math.ceil(domain[1] / maxCount) * maxCount;
52
+ newDomain[0] = bottom != "" ? bottom : Math.floor(domain[0] / minCount) * minCount;
53
+ newDomain[1] = top != "" ? top : Math.ceil(domain[1] / maxCount) * maxCount;
48
54
  break;
49
55
 
50
56
  case "step":
51
- newDomain = [domain[0], domain[0]];
57
+ if (top != "") {
58
+ newDomain = [domain[1], domain[1]];
59
+
60
+ while (newDomain[0] > domain[0]) {
61
+ newDomain[0] -= step;
62
+ }
63
+ } else {
64
+ newDomain = [domain[0], domain[0]];
52
65
 
53
- while (newDomain[1] < domain[1]) {
54
- newDomain[1] += step;
66
+ while (newDomain[1] < domain[1]) {
67
+ newDomain[1] += step;
68
+ }
55
69
  }
56
70
 
71
+ break;
57
72
  }
58
73
 
59
74
  return newDomain;
@@ -320,7 +335,7 @@ var _default = function _default(_ref) {
320
335
  var fixedDomain = extent && extent.min != "" && extent.max != ""; //判断配置项中是否强制了最大最小值,如果已经被强制了,就不计算newDomain
321
336
 
322
337
  if (type !== "ordinal" && !isNaN(domain[1]) && !auto && !fixedDomain) {
323
- newDomain = getNewDomain(domain, mode, _step);
338
+ newDomain = getNewDomain(domain, mode, _step, extent);
324
339
  }
325
340
 
326
341
  var scaler = scales[type]().domain(newDomain).range(range);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easyv/charts",
3
- "version": "1.4.37",
3
+ "version": "1.4.39",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -36,15 +36,16 @@ const defaultFormatter: (
36
36
 
37
37
  const getAxesPath: (
38
38
  orientation: Orientation,
39
- { width, height }: Context
40
- ) => string = (orientation, { width, height }) => {
39
+ { width, height }: Context,
40
+ cHeight:number
41
+ ) => string = (orientation, { width, height }, cHeight) => {
41
42
  switch (orientation) {
42
43
  case "top":
43
44
  case "bottom":
44
45
  return "M-0.5, 0H" + width;
45
46
  case "left":
46
47
  case "right":
47
- return "M0, -0.5V" + (height + 0.5);
48
+ return "M0, -0.5V" + (height + 0.5 - cHeight);
48
49
  }
49
50
  };
50
51
  /**
@@ -99,13 +100,12 @@ const AxisLine: ({
99
100
  clipAxisRange,
100
101
  }: any) => ReactComponentElement<ComponentType> | null = ({
101
102
  orientation = defaultOrientation,
102
- config: { show, color, lineWidth },
103
+ config: { show, color, lineWidth, cHeight },
103
104
  isClipAxis = false,
104
105
  clipAxisRange = [],
105
106
  }) => {
106
107
  if (!show) return null;
107
108
  const context: Context = useContext(chartContext);
108
- const { width, height } = context;
109
109
  if (isClipAxis) {
110
110
  return (
111
111
  <>
@@ -124,7 +124,7 @@ const AxisLine: ({
124
124
  } else {
125
125
  return (
126
126
  <path
127
- d={getAxesPath(orientation, context)}
127
+ d={getAxesPath(orientation, context, cHeight)}
128
128
  stroke={color}
129
129
  strokeWidth={lineWidth}
130
130
  />
@@ -263,7 +263,6 @@ export default memo(
263
263
  rotate,
264
264
  triggerClick,
265
265
  config: { on, label, axisLine, tickLine, gridLine, unit },
266
- config,
267
266
  positions,
268
267
  xLineRange,
269
268
  range,
@@ -398,7 +397,6 @@ export default memo(
398
397
  return <>{draw(ticks, scaler)}</>;
399
398
  }
400
399
  }
401
-
402
400
  return (
403
401
  <g>
404
402
  {/* 绘制轴线和刻度 */}
@@ -413,7 +411,7 @@ export default memo(
413
411
  >
414
412
  <AxisLine
415
413
  orientation={orientation}
416
- config={axisLine}
414
+ config={{...axisLine,cHeight}}
417
415
  range={range}
418
416
  />
419
417
  {tickLine &&
@@ -457,7 +455,7 @@ export default memo(
457
455
  <g transform={"translate(" + x + ", " + y + ")"}>
458
456
  <AxisLine
459
457
  orientation={orientation}
460
- config={axisLine}
458
+ config={{...axisLine,cHeight}}
461
459
  isClipAxis={isClipAxis}
462
460
  clipAxisRange={clipAxisRange}
463
461
  />
@@ -169,35 +169,38 @@ export default memo(
169
169
  style={{
170
170
  overflow: "visible",
171
171
  position: "relative",
172
- pointerEvents:isControlChart?"auto":"none",
173
172
  cursor: "pointer",
174
173
  }}
175
174
  {...attr}
176
175
  onClick={triggerClick}
177
176
  //enter和leave事件,用于控制图的提示框
178
177
  onMouseEnter={() => {
179
- setCtlTip((pre:any)=>({
180
- show:true,
181
- x:xScaler(x),
182
- xName:data.x,
183
- indicatorList:pre.indicatorList.map((item:any)=>{
184
- if (item.tick === data.x) {
185
- return { ...item, isShow: true };
186
- } else {
187
- return item;
188
- }
189
- })
190
- }))
178
+ if(isControlChart){
179
+ setCtlTip((pre:any)=>({
180
+ show:true,
181
+ x:xScaler(x),
182
+ xName:data.x,
183
+ indicatorList:pre.indicatorList.map((item:any)=>{
184
+ if (item.tick === data.x) {
185
+ return { ...item, isShow: true };
186
+ } else {
187
+ return item;
188
+ }
189
+ })
190
+ }))
191
+ }
191
192
  }}
192
193
  onMouseLeave={() => {
193
- setCtlTip((pre:any)=>({
194
- show:false,
195
- x:undefined,
196
- xName:undefined,
197
- indicatorList:pre.indicatorList.map((item:any)=>{
198
- return { ...item, isShow:false }
199
- })
200
- }))
194
+ if(isControlChart){
195
+ setCtlTip((pre:any)=>({
196
+ show:false,
197
+ x:undefined,
198
+ xName:undefined,
199
+ indicatorList:pre.indicatorList.map((item:any)=>{
200
+ return { ...item, isShow:false }
201
+ })
202
+ }))
203
+ }
201
204
  }}
202
205
  data-data={JSON.stringify(data)}
203
206
  >
@@ -34,6 +34,7 @@ export default memo(forwardRef((props, ref) => {
34
34
  background:"rgb(2, 176, 249)",
35
35
  WebkitBackgroundClip:"content-box",
36
36
  }
37
+ //滑块的鼠标按下操作
37
38
  const down=()=>{
38
39
  const transform = ref.current.style.transform;
39
40
  let movementX = 0;
@@ -52,6 +53,17 @@ export default memo(forwardRef((props, ref) => {
52
53
  document.addEventListener("mouseup", mouseUpHandle);
53
54
  setWorking(true);
54
55
  }
56
+ // //右手柄的鼠标按下逻辑
57
+ // const rightDown=()=>{
58
+
59
+ // const move=(e)=>{
60
+
61
+ // }
62
+ // const up=()=>{
63
+
64
+ // }
65
+ // document.addEventListener()
66
+ // }
55
67
  return (
56
68
  <div
57
69
  style={{
@@ -87,7 +99,7 @@ export default memo(forwardRef((props, ref) => {
87
99
  <div ref={ref} style={barStyle}>
88
100
  {/* <div style={{...controllerStyle,transform:"translateX(-6px)"}}></div> */}
89
101
  <div style={dragStyle} onMouseDown={down} ref={barRef}></div>
90
- {/* <div style={{...controllerStyle,transform:`translateX(6px)`}}></div> */}
102
+ {/* <div style={{...controllerStyle,transform:`translateX(6px)`}} onMouseDown={rightDown}></div> */}
91
103
  </div>
92
104
  </div>
93
105
  );
@@ -14,22 +14,32 @@ const getCount = (num) => {
14
14
  return i;
15
15
  };
16
16
 
17
- const getNewDomain = (domain, mode, step) => {
17
+ const getNewDomain = (domain, mode, step, extent={}) => {
18
+ const { min:bottom="", max:top="" } = extent;
18
19
  let newDomain = [];
20
+ //能进入这个函数,说明extent中min和max至少有一个是缺失的,如果max存在,意味着纵轴上限被固定
19
21
  let min = domain[0],
20
22
  max = domain[1];
21
23
  let minCount = Math.pow(10, getCount(min)),
22
24
  maxCount = Math.pow(10, getCount(max));
23
25
  switch (mode) {
24
26
  case "count":
25
- newDomain[0] = Math.floor(domain[0] / minCount) * minCount;
26
- newDomain[1] = Math.ceil(domain[1] / maxCount) * maxCount;
27
+ newDomain[0] = bottom!=""?bottom:Math.floor(domain[0] / minCount) * minCount;
28
+ newDomain[1] = top!=""?top:Math.ceil(domain[1] / maxCount) * maxCount;
27
29
  break;
28
30
  case "step":
29
- newDomain = [domain[0], domain[0]];
30
- while (newDomain[1] < domain[1]) {
31
- newDomain[1] += step;
31
+ if(top!=""){
32
+ newDomain = [domain[1], domain[1]];
33
+ while (newDomain[0] > domain[0]) {
34
+ newDomain[0] -= step;
35
+ }
36
+ }else{
37
+ newDomain = [domain[0], domain[0]];
38
+ while (newDomain[1] < domain[1]) {
39
+ newDomain[1] += step;
40
+ }
32
41
  }
42
+ break;
33
43
  }
34
44
  return newDomain;
35
45
  };
@@ -332,7 +342,7 @@ export default ({
332
342
  let newDomain = domain;
333
343
  const fixedDomain = extent && extent.min!="" && extent.max!=""; //判断配置项中是否强制了最大最小值,如果已经被强制了,就不计算newDomain
334
344
  if (type !== "ordinal" && !isNaN(domain[1]) && !auto && !fixedDomain) {
335
- newDomain = getNewDomain(domain, mode, _step);
345
+ newDomain = getNewDomain(domain, mode, _step, extent);
336
346
  }
337
347
  let scaler = scales[type]().domain(newDomain).range(range);
338
348