@easyv/charts 1.0.44 → 1.0.48

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.
Files changed (65) hide show
  1. package/.babelrc +8 -8
  2. package/lib/components/AnimateData.js +2 -2
  3. package/lib/components/Axis.js +12 -12
  4. package/lib/components/Background.js +2 -2
  5. package/lib/components/Carousel.js +4 -2
  6. package/lib/components/Chart.js +2 -2
  7. package/lib/components/ConicalGradient.js +21 -21
  8. package/lib/components/Indicator.js +2 -2
  9. package/lib/components/Label.js +1 -1
  10. package/lib/components/LinearGradient.js +2 -2
  11. package/lib/components/PieChart.js +326 -139
  12. package/lib/css/index.module.css +42 -42
  13. package/lib/css/piechart.module.css +27 -0
  14. package/lib/formatter/legend.js +3 -2
  15. package/lib/hooks/useAnimateData.js +5 -5
  16. package/lib/hooks/useAxes.js +5 -5
  17. package/lib/hooks/useCarouselAxisX.js +5 -5
  18. package/lib/hooks/useExtentData.js +6 -6
  19. package/lib/hooks/useFilterData.js +5 -5
  20. package/lib/hooks/useStackData.js +5 -5
  21. package/lib/hooks/useTooltip.js +10 -10
  22. package/lib/utils/index.js +1 -1
  23. package/package.json +34 -34
  24. package/src/components/AnimateData.tsx +24 -24
  25. package/src/components/Axis.tsx +333 -333
  26. package/src/components/Background.tsx +45 -45
  27. package/src/components/Band.tsx +160 -160
  28. package/src/components/Brush.js +159 -159
  29. package/src/components/Carousel.tsx +144 -142
  30. package/src/components/Chart.js +99 -101
  31. package/src/components/ChartContainer.tsx +63 -63
  32. package/src/components/ConicalGradient.js +258 -258
  33. package/src/components/ExtentData.js +17 -17
  34. package/src/components/FilterData.js +23 -23
  35. package/src/components/Indicator.js +13 -13
  36. package/src/components/Label.js +194 -194
  37. package/src/components/Legend.js +158 -158
  38. package/src/components/Lighter.jsx +162 -162
  39. package/src/components/Line.js +126 -126
  40. package/src/components/LinearGradient.js +29 -29
  41. package/src/components/Mapping.js +71 -72
  42. package/src/components/PieChart.js +876 -709
  43. package/src/components/StackData.js +20 -20
  44. package/src/components/StereoBar.tsx +298 -298
  45. package/src/components/Tooltip.js +116 -116
  46. package/src/components/index.js +49 -49
  47. package/src/context/index.js +2 -2
  48. package/src/css/index.module.css +42 -42
  49. package/src/css/piechart.module.css +27 -0
  50. package/src/element/Line.tsx +33 -33
  51. package/src/element/index.ts +3 -3
  52. package/src/formatter/index.js +1 -1
  53. package/src/formatter/legend.js +87 -87
  54. package/src/hooks/index.js +17 -17
  55. package/src/hooks/useAnimateData.ts +62 -62
  56. package/src/hooks/useAxes.js +143 -143
  57. package/src/hooks/useCarouselAxisX.js +163 -163
  58. package/src/hooks/useExtentData.js +88 -88
  59. package/src/hooks/useFilterData.js +65 -65
  60. package/src/hooks/useStackData.js +100 -100
  61. package/src/hooks/useTooltip.ts +96 -96
  62. package/src/index.js +6 -6
  63. package/src/types/index.d.ts +59 -59
  64. package/src/utils/index.js +640 -641
  65. package/tsconfig.json +22 -22
@@ -0,0 +1,27 @@
1
+ /*甜甜圈图专用css*/
2
+ .label-line {
3
+ stroke-dasharray: 100;
4
+ stroke-dashoffset: 100;
5
+ animation: dash 800ms ease forwards;
6
+ }
7
+
8
+ .label-text {
9
+ opacity: 0;
10
+ animation: show 800ms ease forwards;
11
+ }
12
+
13
+ .inner-arc {
14
+ animation: dash 2s ease forwards;
15
+ }
16
+
17
+ @keyframes dash {
18
+ 100% {
19
+ stroke-dashoffset: 0%;
20
+ }
21
+ }
22
+
23
+ @keyframes show {
24
+ 100% {
25
+ opacity: 1;
26
+ }
27
+ }
@@ -23,7 +23,8 @@ var pieLegendFormatter = function pieLegendFormatter(_ref, _ref2) {
23
23
  percent = _ref.percent,
24
24
  _ref$series = _ref.series,
25
25
  seriesColor = _ref$series.color,
26
- icon = _ref$series.icon;
26
+ _ref$series$icon = _ref$series.icon,
27
+ icon = _ref$series$icon === void 0 ? "" : _ref$series$icon;
27
28
  var _ref2$name = _ref2.name,
28
29
  showName = _ref2$name.show,
29
30
  nameFont = _ref2$name.font,
@@ -50,7 +51,7 @@ var pieLegendFormatter = function pieLegendFormatter(_ref, _ref2) {
50
51
 
51
52
  var _color = seriesColorType == 'pure' ? pure : stops[0].color;
52
53
 
53
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
54
+ return /*#__PURE__*/React.createElement(React.Fragment, null, icon && /*#__PURE__*/React.createElement("span", {
54
55
  style: _objectSpread(_objectSpread({}, icon), {}, {
55
56
  marginRight: icon.marginRight
56
57
  })
@@ -19,11 +19,11 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
19
19
 
20
20
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
21
21
 
22
- /**
23
- * 图表数据动画
24
- * @param {Array} data data列表
25
- * @param {boolean} dataAnimation 是否开启数据增长动画
26
- * @returns 改变后的数据
22
+ /**
23
+ * 图表数据动画
24
+ * @param {Array} data data列表
25
+ * @param {boolean} dataAnimation 是否开启数据增长动画
26
+ * @returns 改变后的数据
27
27
  */
28
28
  var _default = function _default(data, dataAnimation) {
29
29
  var _useState = (0, _react.useState)([]),
@@ -28,11 +28,11 @@ var scales = {
28
28
  utc: _d3Scale.scaleUtc,
29
29
  ordinal: _utils.band
30
30
  };
31
- /**
32
- * x/y/z轴
33
- * @param {Array} axes 轴列表数组
34
- * @param {Object} context 其中需要包括
35
- * @returns {Map} 返回所有轴
31
+ /**
32
+ * x/y/z轴
33
+ * @param {Array} axes 轴列表数组
34
+ * @param {Object} context 其中需要包括
35
+ * @returns {Map} 返回所有轴
36
36
  */
37
37
 
38
38
  var _default = function _default(_ref) {
@@ -25,11 +25,11 @@ var initialState = {
25
25
  currentIndex: null,
26
26
  flag: false
27
27
  };
28
- /**
29
- * x轴滚动逻辑
30
- * @param {Object} axis x轴配置项
31
- * @param {Object} config x轴轮播动画的配置项
32
- * @returns {Map} 返回经过改变后的x轴,主要是ticks和scaler的range发生了改变
28
+ /**
29
+ * x轴滚动逻辑
30
+ * @param {Object} axis x轴配置项
31
+ * @param {Object} config x轴轮播动画的配置项
32
+ * @returns {Map} 返回经过改变后的x轴,主要是ticks和scaler的range发生了改变
33
33
  */
34
34
 
35
35
  var _default = function _default(axis, config) {
@@ -61,12 +61,12 @@ var stackData = function stackData(data, series) {
61
61
  dataMap.clear();
62
62
  return [min, max];
63
63
  };
64
- /**
65
- * 计算轴的domain
66
- * @param {Array} axes x轴列表
67
- * @param {Object} series 图表的系列,主要是为了读取type, stack, yOrZ三个字段
68
- * @param {Object} data 数据列表
69
- * @returns {Array} 返回带domain的轴
64
+ /**
65
+ * 计算轴的domain
66
+ * @param {Array} axes x轴列表
67
+ * @param {Object} series 图表的系列,主要是为了读取type, stack, yOrZ三个字段
68
+ * @param {Object} data 数据列表
69
+ * @returns {Array} 返回带domain的轴
70
70
  */
71
71
 
72
72
 
@@ -56,11 +56,11 @@ var getSelected = function getSelected(selected, name) {
56
56
  });
57
57
  return tmp;
58
58
  };
59
- /**
60
- * 图例点击状态管理
61
- * @param {Array} data 数据
62
- * @param {Map} series 系列
63
- * @returns {Array} 返回筛选后的数据和是否选中状态,及控制选中函数
59
+ /**
60
+ * 图例点击状态管理
61
+ * @param {Array} data 数据
62
+ * @param {Map} series 系列
63
+ * @returns {Array} 返回筛选后的数据和是否选中状态,及控制选中函数
64
64
  */
65
65
 
66
66
 
@@ -87,11 +87,11 @@ var setStackData = function setStackData(data, series, stacks) {
87
87
  dataMap.clear();
88
88
  return series;
89
89
  };
90
- /**
91
- * 计算堆叠数据
92
- * @param {Array} data 数据
93
- * @param {Map} series 系列
94
- * @returns {Array} 返回堆叠后的数据,由一开始的{x, y, s}变成{data: {x, y, s}, bound: [start, end], index}
90
+ /**
91
+ * 计算堆叠数据
92
+ * @param {Array} data 数据
93
+ * @param {Map} series 系列
94
+ * @returns {Array} 返回堆叠后的数据,由一开始的{x, y, s}变成{data: {x, y, s}, bound: [start, end], index}
95
95
  */
96
96
 
97
97
 
@@ -14,16 +14,16 @@ var _react = require("react");
14
14
  var _utils = require("../utils");
15
15
 
16
16
  var callback = function callback() {};
17
- /**
18
- * 主要用于轴类图表,返回当前选中的是哪一个x
19
- * @param {Array} svg svg的dom实例
20
- * @param {Number} marginLeft 左间距
21
- * @param {Number} marginTop 上间距
22
- * @param {Number} width 宽
23
- * @param {Number} height 高
24
- * @param {Number} axisX 类目轴
25
- * @param {Object} config 轮播动画参数
26
- * @returns {Object} 返回被选中的名称,坐标,选中方法
17
+ /**
18
+ * 主要用于轴类图表,返回当前选中的是哪一个x
19
+ * @param {Array} svg svg的dom实例
20
+ * @param {Number} marginLeft 左间距
21
+ * @param {Number} marginTop 上间距
22
+ * @param {Number} width 宽
23
+ * @param {Number} height 高
24
+ * @param {Number} axisX 类目轴
25
+ * @param {Object} config 轮播动画参数
26
+ * @returns {Object} 返回被选中的名称,坐标,选中方法
27
27
  */
28
28
 
29
29
 
@@ -756,7 +756,7 @@ var getDataWithPercent = function getDataWithPercent() {
756
756
  });
757
757
  var votesPerQuota = data.map(function (d, index) {
758
758
  return _objectSpread(_objectSpread({}, d), {}, {
759
- vote: Math.floor(d.value / total * digits * 100),
759
+ vote: Math.round(d.value / total * digits * 100),
760
760
  index: index
761
761
  });
762
762
  });
package/package.json CHANGED
@@ -1,34 +1,34 @@
1
- {
2
- "name": "@easyv/charts",
3
- "version": "1.0.44",
4
- "description": "",
5
- "main": "lib/index.js",
6
- "scripts": {
7
- "make": "babel src -d lib --extensions .ts,.tsx,.js && cp -r src/css lib"
8
- },
9
- "keywords": [],
10
- "author": "",
11
- "license": "ISC",
12
- "devDependencies": {
13
- "@babel/cli": "^7.6.0",
14
- "@babel/core": "^7.11.5",
15
- "@babel/plugin-proposal-class-properties": "^7.10.4",
16
- "@babel/plugin-proposal-export-default-from": "^7.10.4",
17
- "@babel/plugin-transform-runtime": "^7.11.5",
18
- "@babel/preset-env": "^7.11.5",
19
- "@babel/preset-react": "^7.10.4",
20
- "@babel/preset-typescript": "^7.14.5",
21
- "@types/d3": "^7.0.0",
22
- "@types/react": "^17.0.14",
23
- "babel-plugin-transform-import-styles": "0.0.11",
24
- "babel-preset-env": "^1.7.0",
25
- "load-styles": "^2.0.0"
26
- },
27
- "dependencies": {
28
- "@easyv/utils": "^0.0.26",
29
- "d3v7": "npm:d3@^7.0.0",
30
- "popmotion": "^9.3.6",
31
- "react": "^17.0.2",
32
- "svg-points": "^6.0.1"
33
- }
34
- }
1
+ {
2
+ "name": "@easyv/charts",
3
+ "version": "1.0.48",
4
+ "description": "",
5
+ "main": "lib/index.js",
6
+ "scripts": {
7
+ "make": "babel src -d lib --extensions .ts,.tsx,.js && cp -r src/css lib"
8
+ },
9
+ "keywords": [],
10
+ "author": "",
11
+ "license": "ISC",
12
+ "devDependencies": {
13
+ "@babel/cli": "^7.6.0",
14
+ "@babel/core": "^7.11.5",
15
+ "@babel/plugin-proposal-class-properties": "^7.10.4",
16
+ "@babel/plugin-proposal-export-default-from": "^7.10.4",
17
+ "@babel/plugin-transform-runtime": "^7.11.5",
18
+ "@babel/preset-env": "^7.11.5",
19
+ "@babel/preset-react": "^7.10.4",
20
+ "@babel/preset-typescript": "^7.14.5",
21
+ "@types/d3": "^7.0.0",
22
+ "@types/react": "^17.0.14",
23
+ "babel-plugin-transform-import-styles": "0.0.11",
24
+ "babel-preset-env": "^1.7.0",
25
+ "load-styles": "^2.0.0"
26
+ },
27
+ "dependencies": {
28
+ "@easyv/utils": "^0.0.26",
29
+ "d3v7": "npm:d3@^7.0.0",
30
+ "popmotion": "^9.3.6",
31
+ "react": "^17.0.2",
32
+ "svg-points": "^6.0.1"
33
+ }
34
+ }
@@ -1,24 +1,24 @@
1
- /**
2
- * 用来做图表数据改变(增长)动画(HOC)
3
- */
4
- import React, { memo, ComponentType } from 'react';
5
- import { useAnimateData } from '../hooks';
6
-
7
- export default (Component: ComponentType<any>) =>
8
- memo(
9
- ({
10
- data,
11
- config: { dataAnimation, ...config },
12
- ...rest
13
- }: {
14
- data: DataType[];
15
- config: { dataAnimation: boolean; [key: string]: any };
16
- [key: string]: any;
17
- }) => (
18
- <Component
19
- {...rest}
20
- config={config}
21
- data={useAnimateData(data, dataAnimation)}
22
- />
23
- )
24
- );
1
+ /**
2
+ * 用来做图表数据改变(增长)动画(HOC)
3
+ */
4
+ import React, { memo, ComponentType } from 'react';
5
+ import { useAnimateData } from '../hooks';
6
+
7
+ export default (Component: ComponentType<any>) =>
8
+ memo(
9
+ ({
10
+ data,
11
+ config: { dataAnimation, ...config },
12
+ ...rest
13
+ }: {
14
+ data: DataType[];
15
+ config: { dataAnimation: boolean; [key: string]: any };
16
+ [key: string]: any;
17
+ }) => (
18
+ <Component
19
+ {...rest}
20
+ config={config}
21
+ data={useAnimateData(data, dataAnimation)}
22
+ />
23
+ )
24
+ );