@publishfx/publish-chart 2.1.8 → 2.1.9
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/CHANGELOG.md +9 -0
- package/dist/components/g2/base/G2CombineChart.js +3 -3
- package/dist/components/g2/base/g2Helpers.js +1 -1
- package/dist/components/g2/base/g2bar.js +3 -0
- package/dist/components/g2/base/g2combine.js +41 -24
- package/dist/components/g2/base/g2line.js +6 -0
- package/dist/components/g2/shared/G2CompareTooltip.js +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
**2.1.9** feat(chart): 组合图折线色彩设置
|
|
2
|
+
- 2026-03-04T16:45:43+08:00 [feat(chart): 组合图折线色彩设置](http://lf.git.oa.mt/publish_platform/web/publish/commit/2d456a5bd13fbed534b125a71955e8d18f62bbfc)
|
|
3
|
+
- 2026-03-04T16:42:51+08:00 [feat(chart): 组合图副轴最大值逻辑复原](http://lf.git.oa.mt/publish_platform/web/publish/commit/6a1e758f64f6e7ef202c8089afecdd49580cf133)
|
|
4
|
+
- 2026-03-04T16:28:16+08:00 [fix(chart): 解决缺数据场景下的tooltip问题](http://lf.git.oa.mt/publish_platform/web/publish/commit/163c2e4e4ca33c92179a505b18f8f4e03d4d5229)
|
|
5
|
+
- 2026-03-04T16:18:04+08:00 [feat(chart): 固定组合图副轴最大值](http://lf.git.oa.mt/publish_platform/web/publish/commit/1dde15ae135b27676db7d57940dee63fb0c7d4cb)
|
|
6
|
+
- 2026-03-04T16:06:17+08:00 [fix(chart): 修复空数据导致的tooltip异常问题](http://lf.git.oa.mt/publish_platform/web/publish/commit/59ddceb66f4bf9dc893cf68eb2be15464a53303c)
|
|
7
|
+
- 2026-03-04T15:42:22+08:00 [feat(chart): 数据标签加粗](http://lf.git.oa.mt/publish_platform/web/publish/commit/3ab4756a4fdea0979e56de01e5e9581bed568625)
|
|
8
|
+
- 2026-03-04T15:12:27+08:00 [feat(chart): 组合图颜色](http://lf.git.oa.mt/publish_platform/web/publish/commit/d448d5203de936018e95d8bcc301aaa877a64666)
|
|
9
|
+
|
|
1
10
|
**2.1.8** feat(chart): 柱状、折线、组合图的节点单独传递
|
|
2
11
|
- 2026-03-04T11:59:34+08:00 [feat(chart): 柱状、折线、组合图的节点单独传递](http://lf.git.oa.mt/publish_platform/web/publish/commit/5ef7b6c79b51438f7ae49edce74e060e5ffbd595)
|
|
3
12
|
- 2026-03-04T11:45:15+08:00 [fix(chart): 将node信息单独传递](http://lf.git.oa.mt/publish_platform/web/publish/commit/20b4209876bd464ff63674480eb3a308e7007a02)
|
|
@@ -54,9 +54,9 @@ const transformDataToGroupBarLineFormat = (data, x = "groupName", y = "", indica
|
|
|
54
54
|
}).flat();
|
|
55
55
|
};
|
|
56
56
|
const lineColors = [
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
'#FA8C16',
|
|
58
|
+
'#7CB305',
|
|
59
|
+
'#5CDBD3'
|
|
60
60
|
];
|
|
61
61
|
const G2CombineChart = ({ height = 300, data, x = "", y = "", z = "", indicatorMap, onChartClick, legend = "", config, nodeSetting = {
|
|
62
62
|
showType: 0,
|
|
@@ -214,7 +214,7 @@ function applyHighlightDate(view, x, data, highlightDate, isHighlight) {
|
|
|
214
214
|
}
|
|
215
215
|
function applyNodeData(view, nodeData, x, y) {
|
|
216
216
|
const nodeList = [];
|
|
217
|
-
nodeData
|
|
217
|
+
nodeData?.forEach((item)=>{
|
|
218
218
|
view.shape().data([
|
|
219
219
|
{
|
|
220
220
|
[x]: item[x],
|
|
@@ -151,6 +151,9 @@ function renderG2BarChart(container, options) {
|
|
|
151
151
|
onNodeListChange?.(nodeList);
|
|
152
152
|
}
|
|
153
153
|
if (isDataTag && formatLabel) interval.label({
|
|
154
|
+
style: {
|
|
155
|
+
fontWeight: 600
|
|
156
|
+
},
|
|
154
157
|
text: (d)=>formatLabel(d),
|
|
155
158
|
position: isHorizontal ? 'right' : 'top',
|
|
156
159
|
offset: 0,
|
|
@@ -128,7 +128,8 @@ function renderG2CombineChart(container, options) {
|
|
|
128
128
|
indicatorId: datum['groupType'],
|
|
129
129
|
channel: Y_AXIS_FIELD,
|
|
130
130
|
color: barColor || 'transparent',
|
|
131
|
-
isCombine: false
|
|
131
|
+
isCombine: false,
|
|
132
|
+
x: datum[x]
|
|
132
133
|
},
|
|
133
134
|
isCompare ? (datum)=>datum.groupType.includes('_compare') ? {
|
|
134
135
|
value: datum[BAR_Y_FIELD],
|
|
@@ -149,12 +150,12 @@ function renderG2CombineChart(container, options) {
|
|
|
149
150
|
} : false : false
|
|
150
151
|
].filter(Boolean)
|
|
151
152
|
});
|
|
152
|
-
const lineData = data.filter((item)=>item.isCombine && !item.groupType.includes('_compare')).map((item)=>({
|
|
153
|
+
const lineData = data.filter((item)=>item.isCombine && !item.groupType.includes('_compare')).filter((item)=>'' !== item[Y_AXIS_FIELD]).map((item)=>({
|
|
153
154
|
...item,
|
|
154
155
|
[LINE_Y_FIELD]: item[Y_AXIS_FIELD]
|
|
155
156
|
}));
|
|
156
157
|
console.log('renderG2CombineChart: line data:', lineData);
|
|
157
|
-
const compareLineData = data.filter((item)=>item.isCombine && item.groupType.includes('_compare')).map((item)=>({
|
|
158
|
+
const compareLineData = data.filter((item)=>item.isCombine && item.groupType.includes('_compare')).filter((item)=>'' !== item[Y_AXIS_FIELD]).map((item)=>({
|
|
158
159
|
...item,
|
|
159
160
|
[LINE_Y_FIELD]: item[Y_AXIS_FIELD]
|
|
160
161
|
}));
|
|
@@ -163,36 +164,28 @@ function renderG2CombineChart(container, options) {
|
|
|
163
164
|
const compareLineMaxY = compareLineData.reduce((max, item)=>Math.max(max, item[LINE_Y_FIELD]), 0);
|
|
164
165
|
const lineFinalMaxY = Math.max(lineMaxY, compareLineMaxY) || 1;
|
|
165
166
|
const finalLineMax = Math.max(lineFinalMaxY, maxAux);
|
|
167
|
+
console.log('lineData:', lineData);
|
|
166
168
|
const line = view.line().data(lineData).encode("x", x).encode("y", LINE_Y_FIELD).encode('color', 'groupType').style({
|
|
167
169
|
lineWidth: 2,
|
|
168
170
|
stroke: (datum)=>{
|
|
169
|
-
const
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
];
|
|
173
|
-
const groupType = String(datum[0]?.groupType ?? '');
|
|
174
|
-
const index = groupTypeArr.findIndex((item)=>item === groupType);
|
|
175
|
-
const color = lineColors[index] || lineColors[0];
|
|
176
|
-
return color;
|
|
171
|
+
const currentDatum = datum[0];
|
|
172
|
+
const item = legendItems.find((item)=>item.id === `${currentDatum?.groupType}_${currentDatum?.isCombine}`);
|
|
173
|
+
return item?.color || lineColors[0];
|
|
177
174
|
}
|
|
178
175
|
});
|
|
179
176
|
line.tooltip({
|
|
180
177
|
items: [
|
|
181
178
|
(datum)=>{
|
|
182
|
-
const
|
|
183
|
-
const groupTypeArr = [
|
|
184
|
-
...groupTypeSet
|
|
185
|
-
];
|
|
186
|
-
const groupType = String(datum?.groupType ?? '');
|
|
187
|
-
const index = groupTypeArr.findIndex((item)=>item === groupType);
|
|
179
|
+
const item = legendItems.find((item)=>item.id === `${datum?.groupType}_${datum?.isCombine}`);
|
|
188
180
|
return {
|
|
189
181
|
value: datum[LINE_Y_FIELD],
|
|
190
182
|
name: getIndicatorCompareName(_indicatorMap, datum['groupType']),
|
|
191
183
|
indicatorId: datum['groupType'],
|
|
192
184
|
channel: Y_AXIS_FIELD,
|
|
193
|
-
color:
|
|
185
|
+
color: item?.color || lineColors[0],
|
|
194
186
|
isCombine: true,
|
|
195
|
-
tipType: 'line'
|
|
187
|
+
tipType: 'line',
|
|
188
|
+
x: datum[x]
|
|
196
189
|
};
|
|
197
190
|
}
|
|
198
191
|
]
|
|
@@ -257,7 +250,8 @@ function renderG2CombineChart(container, options) {
|
|
|
257
250
|
channel: Y_AXIS_FIELD,
|
|
258
251
|
color: lineColors[indicators.slice(1).indexOf(String(datum['groupType'])) ?? 0] || 'transparent',
|
|
259
252
|
isCombine: true,
|
|
260
|
-
tipType: 'compareline'
|
|
253
|
+
tipType: 'compareline',
|
|
254
|
+
x: datum[x]
|
|
261
255
|
} : false,
|
|
262
256
|
(datum)=>datum.groupType.includes('_compare') ? {
|
|
263
257
|
name: datum['groupType'].replace('_compare', '_change'),
|
|
@@ -266,7 +260,8 @@ function renderG2CombineChart(container, options) {
|
|
|
266
260
|
value: datum?.change,
|
|
267
261
|
isChange: true,
|
|
268
262
|
isCombine: true,
|
|
269
|
-
tipType: 'compareline'
|
|
263
|
+
tipType: 'compareline',
|
|
264
|
+
x: datum[x]
|
|
270
265
|
} : false
|
|
271
266
|
].filter(Boolean)
|
|
272
267
|
});
|
|
@@ -276,14 +271,30 @@ function renderG2CombineChart(container, options) {
|
|
|
276
271
|
marker: false,
|
|
277
272
|
render: (event, payload)=>{
|
|
278
273
|
const { title, items } = payload;
|
|
274
|
+
console.log('tooltipRender:', title, items);
|
|
275
|
+
let safeTitle = title.replace(/,.*$/, '');
|
|
279
276
|
const baseItems = items.filter((item)=>!item.isCombine);
|
|
277
|
+
const safeItems = baseItems.map((item)=>{
|
|
278
|
+
if (item.x !== safeTitle) return {
|
|
279
|
+
...item,
|
|
280
|
+
value: '-'
|
|
281
|
+
};
|
|
282
|
+
return item;
|
|
283
|
+
});
|
|
280
284
|
const combineItems = items.filter((item)=>item.isCombine);
|
|
285
|
+
const safeCombineItems = combineItems.map((item)=>{
|
|
286
|
+
if (item.x !== safeTitle) return {
|
|
287
|
+
...item,
|
|
288
|
+
value: '-'
|
|
289
|
+
};
|
|
290
|
+
return item;
|
|
291
|
+
});
|
|
281
292
|
const indicatorOrder = new Map(indicators.map((id, i)=>[
|
|
282
293
|
id,
|
|
283
294
|
i
|
|
284
295
|
]));
|
|
285
296
|
const sortedCombineItems = [
|
|
286
|
-
...
|
|
297
|
+
...safeCombineItems
|
|
287
298
|
].sort((a, b)=>{
|
|
288
299
|
const orderA = indicatorOrder.get(a.indicatorId) ?? 1 / 0;
|
|
289
300
|
const orderB = indicatorOrder.get(b.indicatorId) ?? 1 / 0;
|
|
@@ -295,8 +306,8 @@ function renderG2CombineChart(container, options) {
|
|
|
295
306
|
};
|
|
296
307
|
return typeRank(a) - typeRank(b);
|
|
297
308
|
});
|
|
298
|
-
const content = tooltipRender(
|
|
299
|
-
...
|
|
309
|
+
const content = tooltipRender(safeTitle, [
|
|
310
|
+
...safeItems,
|
|
300
311
|
...sortedCombineItems
|
|
301
312
|
]) ?? null;
|
|
302
313
|
if (content) {
|
|
@@ -375,6 +386,9 @@ function renderG2CombineChart(container, options) {
|
|
|
375
386
|
dy: -16,
|
|
376
387
|
dx: -10,
|
|
377
388
|
offset: 0,
|
|
389
|
+
style: {
|
|
390
|
+
fontWeight: 600
|
|
391
|
+
},
|
|
378
392
|
text: (d)=>{
|
|
379
393
|
if (!isGroup) return formatLabel(d);
|
|
380
394
|
if (lastItemsInEachStack.has(d)) return formatLabel(d);
|
|
@@ -386,6 +400,9 @@ function renderG2CombineChart(container, options) {
|
|
|
386
400
|
dy: -10,
|
|
387
401
|
dx: 10,
|
|
388
402
|
offset: 0,
|
|
403
|
+
style: {
|
|
404
|
+
fontWeight: 600
|
|
405
|
+
},
|
|
389
406
|
text: (d)=>formatLabel(d)
|
|
390
407
|
});
|
|
391
408
|
view.labelTransform([
|
|
@@ -139,12 +139,18 @@ function renderG2LineChart(container, options) {
|
|
|
139
139
|
dy: -10,
|
|
140
140
|
dx: -10,
|
|
141
141
|
offset: 0,
|
|
142
|
+
style: {
|
|
143
|
+
fontWeight: 600
|
|
144
|
+
},
|
|
142
145
|
text: (d)=>formatLabel(d)
|
|
143
146
|
});
|
|
144
147
|
compareLine.label({
|
|
145
148
|
dy: -10,
|
|
146
149
|
dx: -10,
|
|
147
150
|
offset: 0,
|
|
151
|
+
style: {
|
|
152
|
+
fontWeight: 600
|
|
153
|
+
},
|
|
148
154
|
text: (d)=>formatLabel(d)
|
|
149
155
|
});
|
|
150
156
|
view.labelTransform([
|
|
@@ -4,6 +4,7 @@ import { CompareChange } from "@publishfx/publish-components";
|
|
|
4
4
|
import { getIndicatorCompareName } from "../../../utils/indicatorHelpers.js";
|
|
5
5
|
const G2CompareTooltip = ({ isGroupBar = false, title, items, safeIndicatorMap, formatter, safeLegend, auxiliaryLineData })=>{
|
|
6
6
|
let auxiIndicatorId = "";
|
|
7
|
+
console.log('G2CompareTooltip:', items);
|
|
7
8
|
const uniqueColors = [];
|
|
8
9
|
return /*#__PURE__*/ jsxs("div", {
|
|
9
10
|
style: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@publishfx/publish-chart",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.9",
|
|
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": [
|