@easyv/charts 1.4.29 → 1.4.31

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 (90) hide show
  1. package/.babelrc +8 -8
  2. package/.husky/commit-msg +3 -3
  3. package/CHANGELOG.md +18 -18
  4. package/commitlint.config.js +1 -1
  5. package/lib/components/AnimateData.js +16 -8
  6. package/lib/components/Axis.js +134 -87
  7. package/lib/components/Background.js +26 -18
  8. package/lib/components/Band.js +98 -72
  9. package/lib/components/BaseLine.js +46 -33
  10. package/lib/components/Brush.js +46 -29
  11. package/lib/components/Carousel.js +40 -13
  12. package/lib/components/CartesianChart.js +146 -97
  13. package/lib/components/Chart.js +39 -26
  14. package/lib/components/ChartContainer.js +27 -18
  15. package/lib/components/ConicalGradient.js +89 -56
  16. package/lib/components/Control.js +28 -12
  17. package/lib/components/ExtentData.js +17 -9
  18. package/lib/components/FilterData.js +27 -16
  19. package/lib/components/Indicator.js +30 -23
  20. package/lib/components/Label.js +126 -96
  21. package/lib/components/Legend.js +66 -41
  22. package/lib/components/Lighter.js +50 -21
  23. package/lib/components/Line.js +59 -39
  24. package/lib/components/LinearGradient.js +22 -16
  25. package/lib/components/Mapping.js +34 -9
  26. package/lib/components/Marquee.js +30 -14
  27. package/lib/components/PieChart.js +420 -318
  28. package/lib/components/StackData.js +18 -8
  29. package/lib/components/StereoBar.js +105 -65
  30. package/lib/components/TextOverflow.js +21 -8
  31. package/lib/components/Tooltip.js +55 -41
  32. package/lib/components/index.js +29 -0
  33. package/lib/components/pieTooltip.js +67 -40
  34. package/lib/context/index.js +2 -0
  35. package/lib/css/index.module.css +42 -42
  36. package/lib/css/piechart.module.css +26 -26
  37. package/lib/element/ConicGradient.js +35 -29
  38. package/lib/element/Line.js +13 -9
  39. package/lib/element/index.js +2 -0
  40. package/lib/formatter/index.js +2 -0
  41. package/lib/formatter/legend.js +41 -30
  42. package/lib/hooks/index.js +9 -0
  43. package/lib/hooks/useAiData.js +20 -12
  44. package/lib/hooks/useAnimateData.js +21 -8
  45. package/lib/hooks/useAxes.js +117 -67
  46. package/lib/hooks/useCarouselAxisX.js +59 -26
  47. package/lib/hooks/useExtentData.js +47 -15
  48. package/lib/hooks/useFilterData.js +34 -13
  49. package/lib/hooks/useStackData.js +35 -12
  50. package/lib/hooks/useTooltip.js +53 -36
  51. package/lib/index.js +15 -0
  52. package/lib/utils/index.js +247 -95
  53. package/package.json +55 -55
  54. package/src/components/Axis.tsx +1 -1
  55. package/src/components/Background.tsx +61 -61
  56. package/src/components/Band.tsx +274 -274
  57. package/src/components/Brush.js +159 -159
  58. package/src/components/CartesianChart.js +1 -0
  59. package/src/components/Chart.js +100 -101
  60. package/src/components/ChartContainer.tsx +71 -71
  61. package/src/components/ConicalGradient.js +258 -258
  62. package/src/components/Control.jsx +51 -51
  63. package/src/components/ExtentData.js +17 -17
  64. package/src/components/Indicator.js +61 -61
  65. package/src/components/Label.js +275 -275
  66. package/src/components/Legend.js +165 -165
  67. package/src/components/Lighter.jsx +173 -173
  68. package/src/components/Line.js +150 -150
  69. package/src/components/LinearGradient.js +29 -29
  70. package/src/components/PieTooltip.jsx +160 -160
  71. package/src/components/StereoBar.tsx +307 -307
  72. package/src/components/index.js +59 -59
  73. package/src/context/index.js +2 -2
  74. package/src/css/index.module.css +42 -42
  75. package/src/css/piechart.module.css +26 -26
  76. package/src/element/ConicGradient.jsx +55 -55
  77. package/src/element/Line.tsx +33 -33
  78. package/src/element/index.ts +3 -3
  79. package/src/formatter/index.js +1 -1
  80. package/src/formatter/legend.js +92 -92
  81. package/src/hooks/index.js +20 -20
  82. package/src/hooks/useAnimateData.ts +67 -67
  83. package/src/hooks/useExtentData.js +1 -1
  84. package/src/hooks/useFilterData.js +72 -72
  85. package/src/hooks/useStackData.js +101 -101
  86. package/src/hooks/useTooltip.ts +100 -100
  87. package/src/index.js +6 -6
  88. package/src/types/index.d.ts +67 -67
  89. package/src/utils/index.js +757 -757
  90. package/tsconfig.json +23 -23
@@ -1,59 +1,59 @@
1
- import Mapping from './Mapping';
2
- import AnimateData from './AnimateData';
3
- import FilterData from './FilterData';
4
- import ExtentData from './ExtentData';
5
- import StackData from './StackData';
6
- import ChartContainer from './ChartContainer';
7
- import Legend from './Legend';
8
- import Axis from './Axis';
9
- import Tooltip from './Tooltip';
10
- import Indicator from './Indicator';
11
- import Band from './Band';
12
- import Lighter from './Lighter';
13
- import Line from './Line';
14
- import Background from './Background';
15
- import LinearGradient from './LinearGradient';
16
- import Brush from './Brush';
17
- import Label from './Label';
18
- import StereoBar from './StereoBar';
19
- import Carousel from './Carousel';
20
- import Chart from './Chart';
21
- import ConicalGradient from './ConicalGradient';
22
- import CartesianChart from './CartesianChart';
23
- import PieChart from './PieChart';
24
- import TextOverflow from './TextOverflow';
25
- import BaseLine from './BaseLine';
26
- import Control from './Control';
27
- import { PieTooltip } from './PieTooltip';
28
-
29
- const Area = Line;
30
- export {
31
- Control,
32
- Mapping,
33
- AnimateData,
34
- FilterData,
35
- StackData,
36
- ExtentData,
37
- ChartContainer,
38
- Legend,
39
- Tooltip,
40
- Axis,
41
- Indicator,
42
- Band,
43
- Lighter,
44
- Line,
45
- Area,
46
- Background,
47
- LinearGradient,
48
- Brush,
49
- Label,
50
- StereoBar,
51
- Carousel,
52
- CartesianChart,
53
- PieChart,
54
- TextOverflow,
55
- Chart,
56
- ConicalGradient,
57
- BaseLine,
58
- PieTooltip
59
- };
1
+ import Mapping from './Mapping';
2
+ import AnimateData from './AnimateData';
3
+ import FilterData from './FilterData';
4
+ import ExtentData from './ExtentData';
5
+ import StackData from './StackData';
6
+ import ChartContainer from './ChartContainer';
7
+ import Legend from './Legend';
8
+ import Axis from './Axis';
9
+ import Tooltip from './Tooltip';
10
+ import Indicator from './Indicator';
11
+ import Band from './Band';
12
+ import Lighter from './Lighter';
13
+ import Line from './Line';
14
+ import Background from './Background';
15
+ import LinearGradient from './LinearGradient';
16
+ import Brush from './Brush';
17
+ import Label from './Label';
18
+ import StereoBar from './StereoBar';
19
+ import Carousel from './Carousel';
20
+ import Chart from './Chart';
21
+ import ConicalGradient from './ConicalGradient';
22
+ import CartesianChart from './CartesianChart';
23
+ import PieChart from './PieChart';
24
+ import TextOverflow from './TextOverflow';
25
+ import BaseLine from './BaseLine';
26
+ import Control from './Control';
27
+ import { PieTooltip } from './PieTooltip';
28
+
29
+ const Area = Line;
30
+ export {
31
+ Control,
32
+ Mapping,
33
+ AnimateData,
34
+ FilterData,
35
+ StackData,
36
+ ExtentData,
37
+ ChartContainer,
38
+ Legend,
39
+ Tooltip,
40
+ Axis,
41
+ Indicator,
42
+ Band,
43
+ Lighter,
44
+ Line,
45
+ Area,
46
+ Background,
47
+ LinearGradient,
48
+ Brush,
49
+ Label,
50
+ StereoBar,
51
+ Carousel,
52
+ CartesianChart,
53
+ PieChart,
54
+ TextOverflow,
55
+ Chart,
56
+ ConicalGradient,
57
+ BaseLine,
58
+ PieTooltip
59
+ };
@@ -1,2 +1,2 @@
1
- import { createContext } from 'react';
2
- export const chartContext = createContext();
1
+ import { createContext } from 'react';
2
+ export const chartContext = createContext();
@@ -1,43 +1,43 @@
1
- .rotateClockwise {
2
- animation-name: rotateClockwise;
3
- }
4
-
5
- @keyframes rotateClockwise {
6
- 0% {
7
- transform: rotate(0deg);
8
- }
9
- 100% {
10
- transform: rotate(360deg);
11
- }
12
- }
13
-
14
- .rotateCounterClockwise {
15
- animation-name: rotateCounterClockwise;
16
- }
17
-
18
- @keyframes rotateCounterClockwise {
19
- 0% {
20
- transform: rotate(360deg);
21
- }
22
- 100% {
23
- transform: rotate(0deg);
24
- }
25
- }
26
-
27
- .showAllStyle {
28
- display: grid;
29
- width: 100%;
30
- grid-template-columns: 40% 30% 30%;
31
- align-items: center;
32
- flex-direction: row;
33
- justify-content: space-between;
34
- }
35
-
36
- .notShowAllStyle {
37
- display: flex;
38
- /* width: 100%; */
39
- /* flex:1; */
40
- align-items: center;
41
- flex-direction: row;
42
- justify-content: space-between;
1
+ .rotateClockwise {
2
+ animation-name: rotateClockwise;
3
+ }
4
+
5
+ @keyframes rotateClockwise {
6
+ 0% {
7
+ transform: rotate(0deg);
8
+ }
9
+ 100% {
10
+ transform: rotate(360deg);
11
+ }
12
+ }
13
+
14
+ .rotateCounterClockwise {
15
+ animation-name: rotateCounterClockwise;
16
+ }
17
+
18
+ @keyframes rotateCounterClockwise {
19
+ 0% {
20
+ transform: rotate(360deg);
21
+ }
22
+ 100% {
23
+ transform: rotate(0deg);
24
+ }
25
+ }
26
+
27
+ .showAllStyle {
28
+ display: grid;
29
+ width: 100%;
30
+ grid-template-columns: 40% 30% 30%;
31
+ align-items: center;
32
+ flex-direction: row;
33
+ justify-content: space-between;
34
+ }
35
+
36
+ .notShowAllStyle {
37
+ display: flex;
38
+ /* width: 100%; */
39
+ /* flex:1; */
40
+ align-items: center;
41
+ flex-direction: row;
42
+ justify-content: space-between;
43
43
  }
@@ -1,27 +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
- }
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
27
  }
@@ -1,56 +1,56 @@
1
- import * as d3 from 'd3';
2
-
3
- //只支持在svg中使用
4
- //在<clipPath>标签中绘制圆环路径,在<foreignObject>中使用conic-gradient来制作角向渐变
5
- //然后在foreignObject中调用clipPath来剪切dom元素,实现环形渐变效果
6
- export default function ConicGradient(props){
7
- const {
8
- gradientId, //渐变ID,每一个环形渐变都需要使用独有的id,防止大屏中存在多个环形渐变时,出现渐变混用的情况。
9
- colorConfig={},
10
- circleConfig={}
11
- } = props,
12
- {
13
- colorType = "linear", //渐变类型
14
- colors = [{offset:0,color:"rgba(255,0,0,0.5)"},
15
- {offset:50,color:"rgba(0,255,0,0.5)"},
16
- {offset:100,color:"rgba(0,0,255,0.5)"}] //渐变颜色
17
- } = colorConfig,
18
- {
19
- innerRadius = 80, //圆环内半径
20
- outerRadius = 100, //圆环外半径
21
- startAngle = 0, //初始角度
22
- endAngle = 360, //结束角度
23
- cornerRadius = 0, //圆环两端的圆角
24
- padAngle = 0 //圆环内边距,用于多个圆环之间的间距
25
- } = circleConfig;
26
- const arc = d3
27
- .arc()
28
- .innerRadius(innerRadius)
29
- .outerRadius(outerRadius)
30
- .startAngle((startAngle * Math.PI) / 180)
31
- .endAngle((endAngle * Math.PI) / 180)
32
- .cornerRadius(cornerRadius)
33
- .padAngle(padAngle);
34
- return <g>
35
- <clipPath id={""+gradientId} style={{transform:`translate(50%,50%)`}}>
36
- <path d={arc()}></path>
37
- </clipPath>
38
- <foreignObject style={{
39
- width:"100%",
40
- height:"100%",
41
- transform:`translate(-50%,-50%)`,
42
- background:colorType==="pure"?
43
- colors : `conic-gradient(${colorsToString(colors)})`,
44
- clipPath:`url(${'#'+gradientId})`
45
- }}></foreignObject>
46
- </g>
47
- }
48
- function colorsToString(colors){
49
- let s="";
50
- colors.sort((a,b)=>{
51
- return a.offset-b.offset;
52
- }).map(d=>{
53
- s=s+d.color+" "+d.offset+"%,";
54
- })
55
- return s.slice(0,-1)
1
+ import * as d3 from 'd3';
2
+
3
+ //只支持在svg中使用
4
+ //在<clipPath>标签中绘制圆环路径,在<foreignObject>中使用conic-gradient来制作角向渐变
5
+ //然后在foreignObject中调用clipPath来剪切dom元素,实现环形渐变效果
6
+ export default function ConicGradient(props){
7
+ const {
8
+ gradientId, //渐变ID,每一个环形渐变都需要使用独有的id,防止大屏中存在多个环形渐变时,出现渐变混用的情况。
9
+ colorConfig={},
10
+ circleConfig={}
11
+ } = props,
12
+ {
13
+ colorType = "linear", //渐变类型
14
+ colors = [{offset:0,color:"rgba(255,0,0,0.5)"},
15
+ {offset:50,color:"rgba(0,255,0,0.5)"},
16
+ {offset:100,color:"rgba(0,0,255,0.5)"}] //渐变颜色
17
+ } = colorConfig,
18
+ {
19
+ innerRadius = 80, //圆环内半径
20
+ outerRadius = 100, //圆环外半径
21
+ startAngle = 0, //初始角度
22
+ endAngle = 360, //结束角度
23
+ cornerRadius = 0, //圆环两端的圆角
24
+ padAngle = 0 //圆环内边距,用于多个圆环之间的间距
25
+ } = circleConfig;
26
+ const arc = d3
27
+ .arc()
28
+ .innerRadius(innerRadius)
29
+ .outerRadius(outerRadius)
30
+ .startAngle((startAngle * Math.PI) / 180)
31
+ .endAngle((endAngle * Math.PI) / 180)
32
+ .cornerRadius(cornerRadius)
33
+ .padAngle(padAngle);
34
+ return <g>
35
+ <clipPath id={""+gradientId} style={{transform:`translate(50%,50%)`}}>
36
+ <path d={arc()}></path>
37
+ </clipPath>
38
+ <foreignObject style={{
39
+ width:"100%",
40
+ height:"100%",
41
+ transform:`translate(-50%,-50%)`,
42
+ background:colorType==="pure"?
43
+ colors : `conic-gradient(${colorsToString(colors)})`,
44
+ clipPath:`url(${'#'+gradientId})`
45
+ }}></foreignObject>
46
+ </g>
47
+ }
48
+ function colorsToString(colors){
49
+ let s="";
50
+ colors.sort((a,b)=>{
51
+ return a.offset-b.offset;
52
+ }).map(d=>{
53
+ s=s+d.color+" "+d.offset+"%,";
54
+ })
55
+ return s.slice(0,-1)
56
56
  }
@@ -1,33 +1,33 @@
1
- import React from 'react';
2
-
3
- type Props = {
4
- config: ChartLine;
5
- x1: number;
6
- x2: number;
7
- y1: number;
8
- y2: number;
9
- className: string;
10
- };
11
-
12
- export default ({
13
- config: { show, color, lineWidth, strokeDasharray },
14
- x1,
15
- x2,
16
- y1,
17
- y2,
18
- className,
19
- }: Props) => {
20
- if (!show) return null;
21
- return (
22
- <line
23
- className={className}
24
- x1={x1}
25
- x2={x2}
26
- y1={y1}
27
- y2={y2}
28
- stroke={color}
29
- strokeWidth={lineWidth}
30
- strokeDasharray={strokeDasharray}
31
- />
32
- );
33
- };
1
+ import React from 'react';
2
+
3
+ type Props = {
4
+ config: ChartLine;
5
+ x1: number;
6
+ x2: number;
7
+ y1: number;
8
+ y2: number;
9
+ className: string;
10
+ };
11
+
12
+ export default ({
13
+ config: { show, color, lineWidth, strokeDasharray },
14
+ x1,
15
+ x2,
16
+ y1,
17
+ y2,
18
+ className,
19
+ }: Props) => {
20
+ if (!show) return null;
21
+ return (
22
+ <line
23
+ className={className}
24
+ x1={x1}
25
+ x2={x2}
26
+ y1={y1}
27
+ y2={y2}
28
+ stroke={color}
29
+ strokeWidth={lineWidth}
30
+ strokeDasharray={strokeDasharray}
31
+ />
32
+ );
33
+ };
@@ -1,3 +1,3 @@
1
- import Line from './Line';
2
-
3
- export { Line };
1
+ import Line from './Line';
2
+
3
+ export { Line };
@@ -1 +1 @@
1
- export * from './legend';
1
+ export * from './legend';
@@ -1,92 +1,92 @@
1
- import css from '../css/index.module.css';
2
- import { getFontStyle } from '../utils';
3
- import { TextOverflow } from '../components';
4
-
5
- export const pieLegendFormatter = (
6
- { displayName, data, percent, series: { color: seriesColor, icon="" } },
7
- {
8
- name: { show: showName, font: nameFont, textOverflow, speed, maxWidth },
9
- value: {
10
- show: showValue,
11
- font: valueFont,
12
- sameColor: valueSameColor,
13
- gap: valueGap,
14
- suffix: {
15
- show: showSuffix,
16
- text,
17
- fontSize,
18
- translate: { x, y },
19
- },
20
- },
21
- percent: {
22
- show: showPercent,
23
- font: percentFont,
24
- sameColor: percentSameColor,
25
- gap: percentGap,
26
- },
27
- }
28
- ) => {
29
- const {
30
- type: seriesColorType,
31
- pure,
32
- linear: { stops },
33
- } = seriesColor;
34
-
35
- const _color = seriesColorType == 'pure' ? pure : stops[0].color;
36
- return (
37
- <>
38
- {icon &&<span style={{ ...icon, marginRight: icon.marginRight }} />}
39
- <div
40
- className={
41
- showName && showValue && showPercent
42
- ? css.showAllStyle
43
- : css.notShowAllStyle
44
- }
45
- >
46
- {showName && (
47
- <TextOverflow value={displayName} type={textOverflow} speed={speed} style={{
48
- width:maxWidth, marginLeft: 5, ...getFontStyle(nameFont)
49
- }}></TextOverflow>
50
- )}
51
- {showValue && (
52
- <span
53
- style={{
54
- whiteSpace:"nowrap",
55
- ...getFontStyle(valueFont),
56
- marginLeft: valueGap,
57
- display: 'flex',
58
- color: valueSameColor ? _color : valueFont.color,
59
- alignItems: 'center',
60
- justifyContent: 'flex-start',
61
- }}
62
- >
63
- <span>{data.y}</span>
64
- {showSuffix && (
65
- <span
66
- style={{
67
- whiteSpace:"nowrap",
68
- fontSize,
69
- transform: 'translate3d(' + x + 'px, ' + y + 'px, 0px)',
70
- }}
71
- >
72
- {text}
73
- </span>
74
- )}
75
- </span>
76
- )}
77
- {showPercent && (
78
- <span
79
- style={{
80
- whiteSpace:"nowrap",
81
- ...getFontStyle(percentFont),
82
- marginLeft: percentGap,
83
- color: percentSameColor ? _color : percentFont.color,
84
- }}
85
- >
86
- {percent + '%'}
87
- </span>
88
- )}
89
- </div>
90
- </>
91
- );
92
- };
1
+ import css from '../css/index.module.css';
2
+ import { getFontStyle } from '../utils';
3
+ import { TextOverflow } from '../components';
4
+
5
+ export const pieLegendFormatter = (
6
+ { displayName, data, percent, series: { color: seriesColor, icon="" } },
7
+ {
8
+ name: { show: showName, font: nameFont, textOverflow, speed, maxWidth },
9
+ value: {
10
+ show: showValue,
11
+ font: valueFont,
12
+ sameColor: valueSameColor,
13
+ gap: valueGap,
14
+ suffix: {
15
+ show: showSuffix,
16
+ text,
17
+ fontSize,
18
+ translate: { x, y },
19
+ },
20
+ },
21
+ percent: {
22
+ show: showPercent,
23
+ font: percentFont,
24
+ sameColor: percentSameColor,
25
+ gap: percentGap,
26
+ },
27
+ }
28
+ ) => {
29
+ const {
30
+ type: seriesColorType,
31
+ pure,
32
+ linear: { stops },
33
+ } = seriesColor;
34
+
35
+ const _color = seriesColorType == 'pure' ? pure : stops[0].color;
36
+ return (
37
+ <>
38
+ {icon &&<span style={{ ...icon, marginRight: icon.marginRight }} />}
39
+ <div
40
+ className={
41
+ showName && showValue && showPercent
42
+ ? css.showAllStyle
43
+ : css.notShowAllStyle
44
+ }
45
+ >
46
+ {showName && (
47
+ <TextOverflow value={displayName} type={textOverflow} speed={speed} style={{
48
+ width:maxWidth, marginLeft: 5, ...getFontStyle(nameFont)
49
+ }}></TextOverflow>
50
+ )}
51
+ {showValue && (
52
+ <span
53
+ style={{
54
+ whiteSpace:"nowrap",
55
+ ...getFontStyle(valueFont),
56
+ marginLeft: valueGap,
57
+ display: 'flex',
58
+ color: valueSameColor ? _color : valueFont.color,
59
+ alignItems: 'center',
60
+ justifyContent: 'flex-start',
61
+ }}
62
+ >
63
+ <span>{data.y}</span>
64
+ {showSuffix && (
65
+ <span
66
+ style={{
67
+ whiteSpace:"nowrap",
68
+ fontSize,
69
+ transform: 'translate3d(' + x + 'px, ' + y + 'px, 0px)',
70
+ }}
71
+ >
72
+ {text}
73
+ </span>
74
+ )}
75
+ </span>
76
+ )}
77
+ {showPercent && (
78
+ <span
79
+ style={{
80
+ whiteSpace:"nowrap",
81
+ ...getFontStyle(percentFont),
82
+ marginLeft: percentGap,
83
+ color: percentSameColor ? _color : percentFont.color,
84
+ }}
85
+ >
86
+ {percent + '%'}
87
+ </span>
88
+ )}
89
+ </div>
90
+ </>
91
+ );
92
+ };