@publishfx/publish-chart 1.4.0 → 1.4.3
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/dist/components/composite/GroupBar.d.ts +2 -1
- package/dist/components/composite/GroupBar.js +8 -3
- package/dist/components/composite/GroupBarLine.js +45 -3
- package/dist/components/composite/GroupCompare.d.ts +1 -0
- package/dist/components/composite/GroupCompare.js +3 -12
- package/dist/components/composite/GroupLine.js +3 -2
- package/dist/components/composite/GroupLineCompare.js +3 -2
- package/dist/components/composite/MultipleCompareLine.js +3 -2
- package/dist/components/composite/MultipleLine.js +3 -2
- package/dist/components/shared/NodeGeom.js +4 -0
- package/package.json +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
export declare const newThemeColors: string[];
|
|
2
|
-
declare const _default:
|
|
3
|
+
declare const _default: React.MemoExoticComponent<({ height, data, x, y, legend, indicatorMap, config, auxiliaryLineData, nodeSetting, highlightDate, }: any) => JSX.Element>;
|
|
3
4
|
export default _default;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { memo, useEffect, useMemo, useState } from "react";
|
|
2
|
+
import react, { memo, useEffect, useMemo, useState } from "react";
|
|
3
3
|
import { Axis, Chart, Coordinate, Interval, Legend, Tooltip, View } from "bizcharts";
|
|
4
4
|
import lib from "@antv/data-set/lib";
|
|
5
5
|
import { formatIndicatorV2 } from "../../utils/formatters.js";
|
|
@@ -34,8 +34,8 @@ const GroupBar = ({ height, data, x = 'groupName', y = '', legend = 'groupType',
|
|
|
34
34
|
const ds = new lib();
|
|
35
35
|
const dv = ds.createView().source(data);
|
|
36
36
|
const tdv = ds.createView().source(data);
|
|
37
|
+
const [_filterData, setFilterData] = react.useState(dv.rows);
|
|
37
38
|
const [chartInsWidth, setChartInsWidth] = useState(0);
|
|
38
|
-
const [axisHorPadding, setAxisHorPadding] = useState(0);
|
|
39
39
|
const [padding, setPadding] = useState([
|
|
40
40
|
20,
|
|
41
41
|
10,
|
|
@@ -182,6 +182,9 @@ const GroupBar = ({ height, data, x = 'groupName', y = '', legend = 'groupType',
|
|
|
182
182
|
}, [
|
|
183
183
|
transformData
|
|
184
184
|
]);
|
|
185
|
+
const axisHorPadding = useMemo(()=>getAxisHorPaddingByText(maxY, indicatorMap, y) - 25, [
|
|
186
|
+
maxY
|
|
187
|
+
]);
|
|
185
188
|
return /*#__PURE__*/ jsxs(Chart, {
|
|
186
189
|
height: height || 300,
|
|
187
190
|
data: transformData,
|
|
@@ -365,6 +368,9 @@ const GroupBar = ({ height, data, x = 'groupName', y = '', legend = 'groupType',
|
|
|
365
368
|
maxItemWidth: 1,
|
|
366
369
|
visible: isLegend,
|
|
367
370
|
itemHeight: 14,
|
|
371
|
+
onChange: (ev)=>{
|
|
372
|
+
setFilterData(ev.view?.filteredData);
|
|
373
|
+
},
|
|
368
374
|
name: legend
|
|
369
375
|
}),
|
|
370
376
|
/*#__PURE__*/ jsx(Legend, {
|
|
@@ -375,7 +381,6 @@ const GroupBar = ({ height, data, x = 'groupName', y = '', legend = 'groupType',
|
|
|
375
381
|
name: yAxis,
|
|
376
382
|
label: {
|
|
377
383
|
formatter (val) {
|
|
378
|
-
setAxisHorPadding(getAxisHorPaddingByText(val, indicatorMap, y) - 25);
|
|
379
384
|
return getAxisFormat(val, indicatorMap, y);
|
|
380
385
|
}
|
|
381
386
|
}
|
|
@@ -202,6 +202,22 @@ const GroupBarLine = ({ height = 300, data, x = "groupName", y = "", legend = "g
|
|
|
202
202
|
const filterFn = useMemo(()=>(item)=>highlightDate.includes(item.groupName) ?? false, [
|
|
203
203
|
highlightDate
|
|
204
204
|
]);
|
|
205
|
+
const nodeViewData = useMemo(()=>{
|
|
206
|
+
const uniqueMap = new Map();
|
|
207
|
+
transformData.forEach((item)=>{
|
|
208
|
+
const hasNode = (item?.nodeInfos?.info?.length || 0) > 0 || (item?.nodeInfos?.infosCompare?.length || 0) > 0;
|
|
209
|
+
if (hasNode && !uniqueMap.has(item.groupName)) uniqueMap.set(item.groupName, {
|
|
210
|
+
groupName: item.groupName,
|
|
211
|
+
node: 0,
|
|
212
|
+
nodeInfos: item.nodeInfos,
|
|
213
|
+
color: item.color,
|
|
214
|
+
[legend]: 'NodeEvent'
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
return Array.from(uniqueMap.values());
|
|
218
|
+
}, [
|
|
219
|
+
transformData
|
|
220
|
+
]);
|
|
205
221
|
return /*#__PURE__*/ jsxs(Chart, {
|
|
206
222
|
height: height,
|
|
207
223
|
padding: [
|
|
@@ -496,6 +512,10 @@ const GroupBarLine = ({ height = 300, data, x = "groupName", y = "", legend = "g
|
|
|
496
512
|
chartIns.render(true);
|
|
497
513
|
}
|
|
498
514
|
}),
|
|
515
|
+
/*#__PURE__*/ jsx(Legend, {
|
|
516
|
+
name: "color",
|
|
517
|
+
visible: false
|
|
518
|
+
}),
|
|
499
519
|
leftAuxi && leftAuxi.length > 0 && /*#__PURE__*/ jsxs(View, {
|
|
500
520
|
data: leftData,
|
|
501
521
|
scale: scale,
|
|
@@ -526,9 +546,31 @@ const GroupBarLine = ({ height = 300, data, x = "groupName", y = "", legend = "g
|
|
|
526
546
|
]
|
|
527
547
|
}, offsetLeft),
|
|
528
548
|
dv.rows.some((item)=>item?.nodeInfos?.info?.length > 0 || item?.nodeInfos?.infosCompare?.length > 0) ? /*#__PURE__*/ jsx(Fragment, {
|
|
529
|
-
children: 1 == nodeSetting.showType && NodeGeom ? /*#__PURE__*/
|
|
530
|
-
|
|
531
|
-
|
|
549
|
+
children: 1 == nodeSetting.showType && NodeGeom ? /*#__PURE__*/ jsxs(View, {
|
|
550
|
+
data: nodeViewData,
|
|
551
|
+
scale: {
|
|
552
|
+
node: {
|
|
553
|
+
min: 0,
|
|
554
|
+
max: 1
|
|
555
|
+
},
|
|
556
|
+
groupName: {
|
|
557
|
+
type: 'cat'
|
|
558
|
+
}
|
|
559
|
+
},
|
|
560
|
+
children: [
|
|
561
|
+
/*#__PURE__*/ jsx(Axis, {
|
|
562
|
+
name: "node",
|
|
563
|
+
visible: false
|
|
564
|
+
}),
|
|
565
|
+
/*#__PURE__*/ jsx(Legend, {
|
|
566
|
+
name: "color",
|
|
567
|
+
visible: false
|
|
568
|
+
}),
|
|
569
|
+
/*#__PURE__*/ jsx(NodeGeom, {
|
|
570
|
+
pointData: pointData,
|
|
571
|
+
pointP: pointP
|
|
572
|
+
})
|
|
573
|
+
]
|
|
532
574
|
}) : 2 == nodeSetting.showType && NodeDetail ? 0 == chartOffset || chartOffset ? /*#__PURE__*/ jsx(NodeDetail, {
|
|
533
575
|
chartWidth: chartWidth,
|
|
534
576
|
chartOffset: chartOffset,
|
|
@@ -5,6 +5,7 @@ import React from "react";
|
|
|
5
5
|
import type { BaseChartProps } from "../../core/ChartTypes";
|
|
6
6
|
interface GroupCompareProps extends BaseChartProps {
|
|
7
7
|
legend?: string;
|
|
8
|
+
indicatorMap?: any;
|
|
8
9
|
}
|
|
9
10
|
declare const _default: React.NamedExoticComponent<GroupCompareProps>;
|
|
10
11
|
export default _default;
|
|
@@ -27,7 +27,6 @@ const GroupCompare = ({ height = 300, data, x = "", y = "", indicatorMap, onChar
|
|
|
27
27
|
const HOR_BAR_PADDING_RIGHT = mergedConfig.layout.horBarPaddingRight || 50;
|
|
28
28
|
const { isDescend = false, isLegend = true, isHorizontal = false, isDataTag = false, isHighlight = true } = config || {};
|
|
29
29
|
const [chartInsWidth, setChartInsWidth] = useState(0);
|
|
30
|
-
const [axisHorPadding, setAxisHorPadding] = useState(0);
|
|
31
30
|
const [mainBarSize, setMainBarSize] = useState(void 0);
|
|
32
31
|
const [backgroundHeight, setBackgroundHeight] = useState(1000);
|
|
33
32
|
const legendMapRef = useRef({});
|
|
@@ -178,17 +177,6 @@ const GroupCompare = ({ height = 300, data, x = "", y = "", indicatorMap, onChar
|
|
|
178
177
|
maxYValue,
|
|
179
178
|
isHor
|
|
180
179
|
]);
|
|
181
|
-
useEffect(()=>{
|
|
182
|
-
if (isHorizontal) {
|
|
183
|
-
const calculatedPadding = getAxisHorPaddingByText(maxY, safeIndicatorMap, y) - 22;
|
|
184
|
-
setAxisHorPadding(calculatedPadding);
|
|
185
|
-
}
|
|
186
|
-
}, [
|
|
187
|
-
maxY,
|
|
188
|
-
isHorizontal,
|
|
189
|
-
safeIndicatorMap,
|
|
190
|
-
y
|
|
191
|
-
]);
|
|
192
180
|
const filterFn = useMemo(()=>(item)=>highlightDate?.includes(item.groupName) ?? false, [
|
|
193
181
|
highlightDate
|
|
194
182
|
]);
|
|
@@ -210,6 +198,9 @@ const GroupCompare = ({ height = 300, data, x = "", y = "", indicatorMap, onChar
|
|
|
210
198
|
transformData.length,
|
|
211
199
|
themeColor0
|
|
212
200
|
]);
|
|
201
|
+
const axisHorPadding = useMemo(()=>getAxisHorPaddingByText(maxY, indicatorMap, y) - 22, [
|
|
202
|
+
maxY
|
|
203
|
+
]);
|
|
213
204
|
return /*#__PURE__*/ jsxs(Chart, {
|
|
214
205
|
height: height,
|
|
215
206
|
data: transformData,
|
|
@@ -14,7 +14,6 @@ const GroupLine = ({ height, data, x = 'groupName', y = '', legend = 'groupType'
|
|
|
14
14
|
}, highlightDate })=>{
|
|
15
15
|
const yAxis = 'groupValue';
|
|
16
16
|
const { isDataTag = true, isLegend = true, isHighlight = true } = config || {};
|
|
17
|
-
const [axisHorPadding, setAxisHorPadding] = useState(0);
|
|
18
17
|
const [padding, setPadding] = useState([
|
|
19
18
|
20,
|
|
20
19
|
10,
|
|
@@ -106,6 +105,9 @@ const GroupLine = ({ height, data, x = 'groupName', y = '', legend = 'groupType'
|
|
|
106
105
|
}, [
|
|
107
106
|
transformData
|
|
108
107
|
]);
|
|
108
|
+
const axisHorPadding = useMemo(()=>getAxisHorPaddingByText(maxY, indicatorMap, y) - 22, [
|
|
109
|
+
maxY
|
|
110
|
+
]);
|
|
109
111
|
return /*#__PURE__*/ jsxs(Chart, {
|
|
110
112
|
height: height || 300,
|
|
111
113
|
data: transformData,
|
|
@@ -271,7 +273,6 @@ const GroupLine = ({ height, data, x = 'groupName', y = '', legend = 'groupType'
|
|
|
271
273
|
name: yAxis,
|
|
272
274
|
label: {
|
|
273
275
|
formatter (val) {
|
|
274
|
-
setAxisHorPadding(getAxisHorPaddingByText(val, indicatorMap, y) - 22);
|
|
275
276
|
return getAxisFormat(val, indicatorMap, y);
|
|
276
277
|
}
|
|
277
278
|
}
|
|
@@ -56,7 +56,6 @@ const GroupLineCompare = ({ height, data, x = 'groupName', y = '', legend = 'gro
|
|
|
56
56
|
const [colorMap, setColorMap] = useState({});
|
|
57
57
|
const [checkedLegendItems, setCheckedLegendItems] = useState(new Set());
|
|
58
58
|
const [legendItems, setLegendItems] = useState([]);
|
|
59
|
-
const [axisHorPadding, setAxisHorPadding] = useState(0);
|
|
60
59
|
const [padding, setPadding] = useState([
|
|
61
60
|
20,
|
|
62
61
|
10,
|
|
@@ -210,6 +209,9 @@ const GroupLineCompare = ({ height, data, x = 'groupName', y = '', legend = 'gro
|
|
|
210
209
|
}, [
|
|
211
210
|
transformData
|
|
212
211
|
]);
|
|
212
|
+
const axisHorPadding = useMemo(()=>getAxisHorPaddingByText(maxY, indicatorMap, y) - 22, [
|
|
213
|
+
maxY
|
|
214
|
+
]);
|
|
213
215
|
return /*#__PURE__*/ jsxs(Chart, {
|
|
214
216
|
height: height || 300,
|
|
215
217
|
data: transformData,
|
|
@@ -451,7 +453,6 @@ const GroupLineCompare = ({ height, data, x = 'groupName', y = '', legend = 'gro
|
|
|
451
453
|
name: yAxis,
|
|
452
454
|
label: {
|
|
453
455
|
formatter (val) {
|
|
454
|
-
setAxisHorPadding(getAxisHorPaddingByText(val, indicatorMap, y) - 22);
|
|
455
456
|
return getAxisFormat(val, indicatorMap, y);
|
|
456
457
|
}
|
|
457
458
|
}
|
|
@@ -15,7 +15,6 @@ const MultipleCompareLine = ({ height, data, x = 'groupName', legend = 'groupTyp
|
|
|
15
15
|
}, highlightDate, timeRange })=>{
|
|
16
16
|
const yAxis = 'groupValue';
|
|
17
17
|
const { isDataTag = true, isLegend = true, isHighlight = true } = config || {};
|
|
18
|
-
const [axisHorPadding, setAxisHorPadding] = useState(0);
|
|
19
18
|
const [padding, setPadding] = useState([
|
|
20
19
|
20,
|
|
21
20
|
10,
|
|
@@ -99,6 +98,9 @@ const MultipleCompareLine = ({ height, data, x = 'groupName', legend = 'groupTyp
|
|
|
99
98
|
}, [
|
|
100
99
|
transformData
|
|
101
100
|
]);
|
|
101
|
+
const axisHorPadding = useMemo(()=>getAxisHorPaddingByText(maxY, indicatorMap, '') - 22, [
|
|
102
|
+
maxY
|
|
103
|
+
]);
|
|
102
104
|
return /*#__PURE__*/ jsxs(Chart, {
|
|
103
105
|
height: height || 300,
|
|
104
106
|
data: transformData,
|
|
@@ -317,7 +319,6 @@ const MultipleCompareLine = ({ height, data, x = 'groupName', legend = 'groupTyp
|
|
|
317
319
|
name: yAxis,
|
|
318
320
|
label: {
|
|
319
321
|
formatter (val) {
|
|
320
|
-
setAxisHorPadding(getAxisHorPaddingByText(val, indicatorMap, '') - 22);
|
|
321
322
|
return getAxisFormat(val, indicatorMap, '');
|
|
322
323
|
}
|
|
323
324
|
}
|
|
@@ -15,7 +15,6 @@ const MultipleLine = ({ height, data, x = 'groupName', legend = 'groupType', ind
|
|
|
15
15
|
}, highlightDate })=>{
|
|
16
16
|
const yAxis = 'groupValue';
|
|
17
17
|
const { isDataTag = true, isLegend = true, isHighlight = true } = config || {};
|
|
18
|
-
const [axisHorPadding, setAxisHorPadding] = useState(0);
|
|
19
18
|
const [padding, setPadding] = useState([
|
|
20
19
|
20,
|
|
21
20
|
10,
|
|
@@ -99,6 +98,9 @@ const MultipleLine = ({ height, data, x = 'groupName', legend = 'groupType', ind
|
|
|
99
98
|
}, [
|
|
100
99
|
transformData
|
|
101
100
|
]);
|
|
101
|
+
const axisHorPadding = useMemo(()=>getAxisHorPaddingByText(maxY, indicatorMap, '') - 22, [
|
|
102
|
+
maxY
|
|
103
|
+
]);
|
|
102
104
|
return /*#__PURE__*/ jsxs(Chart, {
|
|
103
105
|
height: height || 300,
|
|
104
106
|
data: transformData,
|
|
@@ -274,7 +276,6 @@ const MultipleLine = ({ height, data, x = 'groupName', legend = 'groupType', ind
|
|
|
274
276
|
name: yAxis,
|
|
275
277
|
label: {
|
|
276
278
|
formatter (val) {
|
|
277
|
-
setAxisHorPadding(getAxisHorPaddingByText(val, indicatorMap, '') - 22);
|
|
278
279
|
return getAxisFormat(val, indicatorMap, '');
|
|
279
280
|
}
|
|
280
281
|
}
|
|
@@ -22,6 +22,10 @@ const NodeGeom = ({ pointData, pointP, isLegend = true })=>/*#__PURE__*/ jsxs(Fr
|
|
|
22
22
|
name: "node",
|
|
23
23
|
visible: false
|
|
24
24
|
}),
|
|
25
|
+
/*#__PURE__*/ jsx(Axis, {
|
|
26
|
+
name: "groupName",
|
|
27
|
+
visible: false
|
|
28
|
+
}),
|
|
25
29
|
isLegend && /*#__PURE__*/ jsx(Legend, {
|
|
26
30
|
name: "color",
|
|
27
31
|
visible: false
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@publishfx/publish-chart",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.3",
|
|
4
4
|
"description": "A React chart component library for the Publish platform, including BarChart, LineChart, BarLineChart and other visualization components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|