@easyv/charts 1.2.5 → 1.2.6
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/AnimateData.js +11 -7
- package/lib/components/Axis.js +8 -4
- package/lib/components/Band.js +8 -4
- package/lib/components/BaseLine.js +76 -0
- package/lib/components/Brush.js +2 -2
- package/lib/components/Carousel.js +13 -6
- package/lib/components/CartesianChart.js +26 -7
- package/lib/components/Chart.js +9 -6
- package/lib/components/ChartContainer.js +8 -4
- package/lib/components/ConicalGradient.js +6 -2
- package/lib/components/ExtentData.js +7 -4
- package/lib/components/FilterData.js +7 -4
- package/lib/components/Label.js +2 -2
- package/lib/components/Legend.js +11 -5
- package/lib/components/Line.js +11 -5
- package/lib/components/Mapping.js +8 -5
- package/lib/components/Marquee.js +2 -2
- package/lib/components/PieChart.js +17 -8
- package/lib/components/StackData.js +7 -4
- package/lib/components/StereoBar.js +8 -4
- package/lib/components/TextOverflow.js +2 -2
- package/lib/components/Tooltip.js +2 -2
- package/lib/components/index.js +55 -47
- package/lib/formatter/legend.js +2 -2
- package/lib/hooks/index.js +14 -14
- package/lib/hooks/useAnimateData.js +2 -2
- package/lib/hooks/useAxes.js +2 -2
- package/lib/hooks/useCarouselAxisX.js +2 -2
- package/lib/hooks/useExtentData.js +2 -2
- package/lib/hooks/useFilterData.js +3 -3
- package/lib/hooks/useStackData.js +5 -3
- package/lib/index.js +6 -2
- package/lib/utils/index.js +29 -6
- package/package.json +1 -1
- package/src/components/BaseLine.js +76 -0
- package/src/components/CartesianChart.js +22 -5
- package/src/components/index.js +2 -0
- package/src/utils/index.js +25 -6
package/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
4
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
@@ -82,4 +82,8 @@ Object.keys(_utils3).forEach(function (key) {
|
|
|
82
82
|
return _utils3[key];
|
|
83
83
|
}
|
|
84
84
|
});
|
|
85
|
-
});
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
88
|
+
|
|
89
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
package/lib/utils/index.js
CHANGED
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.band = band;
|
|
9
|
-
exports.
|
|
9
|
+
exports.sortPie = exports.seriesYOrZ = exports.resetStacks = exports.reduceConfig = exports.isValidHttpUrl = exports.identity = exports.getTranslate3d = exports.getTranslate2d = exports.getTicksOfAxis = exports.getTickCoord = exports.getStacks = exports.getMousePos = exports.getMargin = exports.getIcon = exports.getGridCoord = exports.getFontStyle = exports.getDomPath = exports.getDataWithPercent = exports.getCurrentStack = exports.getColorList = exports.getChildren = exports.getBreakWord = exports.getBandwidth = exports.getBandSeriesStepAndWidth = exports.getBandBackground = exports.filterChildren = exports.dateFormat = exports.dataYOrZ = void 0;
|
|
10
10
|
|
|
11
11
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
12
12
|
|
|
@@ -26,9 +26,12 @@ var _server = require("react-dom/server");
|
|
|
26
26
|
|
|
27
27
|
var _svgPoints = require("svg-points");
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
var _excluded = ["backgroundSize"],
|
|
30
|
+
_excluded2 = ["vote", "value"];
|
|
30
31
|
|
|
31
|
-
function
|
|
32
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
33
|
+
|
|
34
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
32
35
|
|
|
33
36
|
var defaultSize = 10;
|
|
34
37
|
var defaultBackground = '#000000';
|
|
@@ -590,7 +593,7 @@ var getBandBackground = function getBandBackground(pattern, fill) {
|
|
|
590
593
|
|
|
591
594
|
var _pattern$backgroundSi = pattern.backgroundSize,
|
|
592
595
|
backgroundSize = _pattern$backgroundSi === void 0 ? '100% 100%' : _pattern$backgroundSi,
|
|
593
|
-
_pattern = (0, _objectWithoutProperties2["default"])(pattern,
|
|
596
|
+
_pattern = (0, _objectWithoutProperties2["default"])(pattern, _excluded);
|
|
594
597
|
|
|
595
598
|
return 'center top / ' + backgroundSize + ' url("data:image/svg+xml,' + encodeURIComponent((0, _server.renderToStaticMarkup)( /*#__PURE__*/React.createElement(SvgBackground, {
|
|
596
599
|
fill: fill,
|
|
@@ -814,7 +817,7 @@ var getDataWithPercent = function getDataWithPercent() {
|
|
|
814
817
|
var tmp = votesPerQuota.map(function (_ref28, index) {
|
|
815
818
|
var vote = _ref28.vote,
|
|
816
819
|
value = _ref28.value,
|
|
817
|
-
data = (0, _objectWithoutProperties2["default"])(_ref28,
|
|
820
|
+
data = (0, _objectWithoutProperties2["default"])(_ref28, _excluded2);
|
|
818
821
|
|
|
819
822
|
var obj = _objectSpread(_objectSpread({}, data), {}, {
|
|
820
823
|
value: value,
|
|
@@ -830,4 +833,24 @@ var getDataWithPercent = function getDataWithPercent() {
|
|
|
830
833
|
return tmp;
|
|
831
834
|
};
|
|
832
835
|
|
|
833
|
-
exports.getDataWithPercent = getDataWithPercent;
|
|
836
|
+
exports.getDataWithPercent = getDataWithPercent;
|
|
837
|
+
var excludeTypes = ['array', 'object', 'group', 'modal', 'colors'];
|
|
838
|
+
|
|
839
|
+
var reduceConfig = function reduceConfig() {
|
|
840
|
+
var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
841
|
+
|
|
842
|
+
if (!Array.isArray(config)) {
|
|
843
|
+
return config;
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
var output = {};
|
|
847
|
+
|
|
848
|
+
for (var i = 0, len = config.length; i < len; i++) {
|
|
849
|
+
var type = config[i]._type;
|
|
850
|
+
output[config[i]._name] = type && !excludeTypes.includes(type) ? config[i]._value : reduceConfig(config[i]._value);
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
return output;
|
|
854
|
+
};
|
|
855
|
+
|
|
856
|
+
exports.reduceConfig = reduceConfig;
|
package/package.json
CHANGED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 参考线
|
|
3
|
+
*/
|
|
4
|
+
import React, { memo } from 'react';
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export default memo(
|
|
8
|
+
({
|
|
9
|
+
width,
|
|
10
|
+
config: {
|
|
11
|
+
dataStyle: {
|
|
12
|
+
data: {
|
|
13
|
+
show: dataShow,
|
|
14
|
+
dataStyle,
|
|
15
|
+
translate: dataTranslate
|
|
16
|
+
},
|
|
17
|
+
label: {
|
|
18
|
+
label,
|
|
19
|
+
show: labelShow,
|
|
20
|
+
textStyle,
|
|
21
|
+
translate: labelTranslate,
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
line: {
|
|
25
|
+
color,
|
|
26
|
+
lineType,
|
|
27
|
+
lineWidth,
|
|
28
|
+
margin: {
|
|
29
|
+
marginLeft,
|
|
30
|
+
marginRight
|
|
31
|
+
},
|
|
32
|
+
strokeDasharray,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
yAxis: { scaler: yScaler },
|
|
36
|
+
data
|
|
37
|
+
}) => {
|
|
38
|
+
if (!data.value) return null;
|
|
39
|
+
return (
|
|
40
|
+
<>
|
|
41
|
+
<g className='__easyv-baseLine' >
|
|
42
|
+
<line
|
|
43
|
+
x1={marginLeft}
|
|
44
|
+
x2={width - marginRight}
|
|
45
|
+
y1={yScaler(data.value)}
|
|
46
|
+
y2={yScaler(data.value)}
|
|
47
|
+
stroke={color}
|
|
48
|
+
fill='none'
|
|
49
|
+
strokeDasharray={lineType === 'dash' ? strokeDasharray : null}
|
|
50
|
+
strokeWidth={lineWidth}
|
|
51
|
+
/>
|
|
52
|
+
</g>
|
|
53
|
+
{labelShow &&
|
|
54
|
+
<foreignObject
|
|
55
|
+
width={100}
|
|
56
|
+
height={100}
|
|
57
|
+
x={width - marginRight + labelTranslate.x}
|
|
58
|
+
y={yScaler(data.value) - textStyle.fontSize + labelTranslate.y}>
|
|
59
|
+
<div>
|
|
60
|
+
<span style={{ ...textStyle }}>{label}</span>
|
|
61
|
+
</div>
|
|
62
|
+
</foreignObject>}
|
|
63
|
+
{dataShow &&
|
|
64
|
+
<foreignObject
|
|
65
|
+
width={100}
|
|
66
|
+
height={100}
|
|
67
|
+
x={width - marginRight + dataTranslate.x}
|
|
68
|
+
y={yScaler(data.value) + dataTranslate.y}>
|
|
69
|
+
<div>
|
|
70
|
+
<span style={{ ...dataStyle }}>{data.value}</span>
|
|
71
|
+
</div>
|
|
72
|
+
</foreignObject>}
|
|
73
|
+
</>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
);
|
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
Brush,
|
|
25
25
|
Label,
|
|
26
26
|
Mapping,
|
|
27
|
+
BaseLine
|
|
27
28
|
} from '.';
|
|
28
29
|
|
|
29
30
|
const Chart = memo(
|
|
@@ -41,6 +42,10 @@ const Chart = memo(
|
|
|
41
42
|
},
|
|
42
43
|
series,
|
|
43
44
|
tooltip,
|
|
45
|
+
baseLine: {
|
|
46
|
+
config: baseLineConfig = {},
|
|
47
|
+
data: baseLineData = []
|
|
48
|
+
},
|
|
44
49
|
tooltip: {
|
|
45
50
|
config: tooltipConfig = {},
|
|
46
51
|
config: { auto, manual, indicator = {} } = {},
|
|
@@ -49,7 +54,7 @@ const Chart = memo(
|
|
|
49
54
|
},
|
|
50
55
|
style,
|
|
51
56
|
data,
|
|
52
|
-
filterData
|
|
57
|
+
filterData
|
|
53
58
|
}) => {
|
|
54
59
|
const context = useContext(chartContext);
|
|
55
60
|
const {
|
|
@@ -95,10 +100,10 @@ const Chart = memo(
|
|
|
95
100
|
const indicatorAttr = isVertical
|
|
96
101
|
? { width: chartWidth, height: indicatorWidth, y: position }
|
|
97
102
|
: {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
103
|
+
height: chartHeight,
|
|
104
|
+
width: indicatorWidth,
|
|
105
|
+
x: position,
|
|
106
|
+
};
|
|
102
107
|
|
|
103
108
|
const onInteraction = useCallback(
|
|
104
109
|
(e) => {
|
|
@@ -167,6 +172,18 @@ const Chart = memo(
|
|
|
167
172
|
)
|
|
168
173
|
);
|
|
169
174
|
})}
|
|
175
|
+
{baseLineData && baseLineData.length > 0 && baseLineData.map((item, index) => {
|
|
176
|
+
const { line: { yOrZ } } = baseLineConfig[index];
|
|
177
|
+
const yAxis = axes.get(yOrZ);
|
|
178
|
+
return (
|
|
179
|
+
yAxis && (<BaseLine
|
|
180
|
+
width={width}
|
|
181
|
+
key={index}
|
|
182
|
+
config={baseLineConfig[index]}
|
|
183
|
+
yAxis={yAxis}
|
|
184
|
+
data={item} />)
|
|
185
|
+
)
|
|
186
|
+
})}
|
|
170
187
|
</ChartContainer>
|
|
171
188
|
<Legend {...legend} filterData={filterData} series={series} />
|
|
172
189
|
{showTooltip && (
|
package/src/components/index.js
CHANGED
|
@@ -22,6 +22,7 @@ import ConicalGradient from './ConicalGradient';
|
|
|
22
22
|
import CartesianChart from './CartesianChart';
|
|
23
23
|
import PieChart from './PieChart';
|
|
24
24
|
import TextOverflow from './TextOverflow';
|
|
25
|
+
import BaseLine from './BaseLine';
|
|
25
26
|
|
|
26
27
|
const Area = Line;
|
|
27
28
|
export {
|
|
@@ -50,4 +51,5 @@ export {
|
|
|
50
51
|
TextOverflow,
|
|
51
52
|
Chart,
|
|
52
53
|
ConicalGradient,
|
|
54
|
+
BaseLine,
|
|
53
55
|
};
|
package/src/utils/index.js
CHANGED
|
@@ -86,16 +86,16 @@ const getIcon = (type, icon) => {
|
|
|
86
86
|
case 'line':
|
|
87
87
|
return icon
|
|
88
88
|
? {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
89
|
+
...defaultLineIcon,
|
|
90
|
+
...icon,
|
|
91
|
+
}
|
|
92
92
|
: defaultLineIcon;
|
|
93
93
|
default:
|
|
94
94
|
return icon
|
|
95
95
|
? {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
96
|
+
...defaultIcon,
|
|
97
|
+
...icon,
|
|
98
|
+
}
|
|
99
99
|
: defaultIcon;
|
|
100
100
|
}
|
|
101
101
|
};
|
|
@@ -663,6 +663,24 @@ const getDataWithPercent = (data = [], precision = 0) => {
|
|
|
663
663
|
return tmp;
|
|
664
664
|
};
|
|
665
665
|
|
|
666
|
+
|
|
667
|
+
const excludeTypes = ['array', 'object', 'group', 'modal', 'colors'];
|
|
668
|
+
const reduceConfig = (config = []) => {
|
|
669
|
+
if (!Array.isArray(config)) {
|
|
670
|
+
return config;
|
|
671
|
+
}
|
|
672
|
+
let output = {};
|
|
673
|
+
for (let i = 0, len = config.length; i < len; i++) {
|
|
674
|
+
let type = config[i]._type;
|
|
675
|
+
|
|
676
|
+
output[config[i]._name] =
|
|
677
|
+
type && !excludeTypes.includes(type)
|
|
678
|
+
? config[i]._value
|
|
679
|
+
: reduceConfig(config[i]._value);
|
|
680
|
+
}
|
|
681
|
+
return output;
|
|
682
|
+
}
|
|
683
|
+
|
|
666
684
|
export {
|
|
667
685
|
dateFormat,
|
|
668
686
|
getBreakWord,
|
|
@@ -692,4 +710,5 @@ export {
|
|
|
692
710
|
getDomPath,
|
|
693
711
|
sortPie,
|
|
694
712
|
getDataWithPercent,
|
|
713
|
+
reduceConfig,
|
|
695
714
|
};
|