@publishfx/publish-chart 2.1.18 → 2.1.20
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 +11 -0
- package/dist/components/g2/base/G2BarChart.js +0 -12
- package/dist/components/g2/base/G2CombineChart.js +0 -13
- package/dist/components/g2/base/G2LineChart.js +0 -11
- package/dist/components/g2/base/g2Helpers.d.ts +0 -1
- package/dist/components/g2/base/g2Helpers.js +1 -9
- package/dist/components/g2/base/g2bar.d.ts +0 -2
- package/dist/components/g2/base/g2bar.js +2 -3
- package/dist/components/g2/base/g2combine.d.ts +0 -2
- package/dist/components/g2/base/g2combine.js +46 -125
- package/dist/components/g2/base/g2groupbar.js +3 -4
- package/dist/components/g2/base/g2line.d.ts +0 -2
- package/dist/components/g2/base/g2line.js +2 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
**2.1.20** fix(chart): TS错误去除
|
|
2
|
+
- 2026-03-07T04:44:58+08:00 [fix(chart): TS错误去除](http://lf.git.oa.mt/publish_platform/web/publish/commit/d81fbe1bc27f08b5e0c6749ee1334a54a0f5202a)
|
|
3
|
+
- 2026-03-07T04:43:55+08:00 [fix(chart): 堆积图height模式修改](http://lf.git.oa.mt/publish_platform/web/publish/commit/f46992872461144f696f5478c2c70d83bd162fb0)
|
|
4
|
+
- 2026-03-07T04:35:13+08:00 [fix(chart): 组合图的tooltip也使用组件库自带的bounding](http://lf.git.oa.mt/publish_platform/web/publish/commit/82df0547a9a0a05208f2fcbbee22bfab40f769a8)
|
|
5
|
+
- 2026-03-07T04:28:41+08:00 [fix(chart): 全面取消height参数](http://lf.git.oa.mt/publish_platform/web/publish/commit/d3d89c59770c6882dd8279285aadd079d5ee81af)
|
|
6
|
+
- 2026-03-07T04:20:14+08:00 [fix(chart): 移除自定义label部分](http://lf.git.oa.mt/publish_platform/web/publish/commit/f745b401fabaa821caf5d4f05fa3512d30e630d8)
|
|
7
|
+
- 2026-03-07T04:11:59+08:00 [fix(chart): 取消height参数](http://lf.git.oa.mt/publish_platform/web/publish/commit/f26b361d5091b467b39d255cc99e421e8496f597)
|
|
8
|
+
- 2026-03-07T04:09:01+08:00 [fix(chart): G2的自适应不需要再传height了,直接控制容器的尺寸即可](http://lf.git.oa.mt/publish_platform/web/publish/commit/0fb36917b7cf5cffcee7fb52793be6d7fe8a55e9)
|
|
9
|
+
- 2026-03-06T23:17:24+08:00 [fix(chart): 移除无用代码](http://lf.git.oa.mt/publish_platform/web/publish/commit/1e9fe9f4f291fbbaa7af0b96201ce1d6035ce0ab)
|
|
10
|
+
- 2026-03-06T23:14:40+08:00 [fix(chart): 侦听window.resize,超时timeout](http://lf.git.oa.mt/publish_platform/web/publish/commit/4894c21327f75fac047876a0db8410f7c5ac6b9f)
|
|
11
|
+
|
|
1
12
|
**2.1.14** fix(chart): 修复组合图折线指标传空判断
|
|
2
13
|
- 2026-03-05T02:35:21+08:00 [fix(chart): 修复组合图折线指标传空判断](http://lf.git.oa.mt/publish_platform/web/publish/commit/abad3dc8688a3a06d57e2ef1c3884593f5bba88e)
|
|
3
14
|
- 2026-03-05T02:30:07+08:00 [fix(chart): 副轴和非副轴分别定义偏移](http://lf.git.oa.mt/publish_platform/web/publish/commit/6390674b94bcffb02e2145ecc51927a20d89d4a0)
|
|
@@ -130,7 +130,6 @@ const G2BarChart = ({ height = 300, data, x = "", y = "", indicatorMap, onChartC
|
|
|
130
130
|
const v = d[safeY];
|
|
131
131
|
return "-" === v || null == v ? "" : formatter.formatIndicator(v, safeIndicatorMap[safeLegend]);
|
|
132
132
|
} : void 0,
|
|
133
|
-
height: height - canvasMarginBottom,
|
|
134
133
|
tooltipRender: (title, items)=>{
|
|
135
134
|
currentTooltipTitleRef.current = title;
|
|
136
135
|
const container = tooltipContainerRef.current;
|
|
@@ -167,16 +166,6 @@ const G2BarChart = ({ height = 300, data, x = "", y = "", indicatorMap, onChartC
|
|
|
167
166
|
title: tooltipTitle
|
|
168
167
|
});
|
|
169
168
|
});
|
|
170
|
-
const handleWindowResize = ()=>{
|
|
171
|
-
setTimeout(()=>{
|
|
172
|
-
if (chartRef.current && containerRef.current) {
|
|
173
|
-
const width = containerRef.current.clientWidth;
|
|
174
|
-
const height = containerRef.current.clientHeight;
|
|
175
|
-
chartRef.current.changeSize(width, height);
|
|
176
|
-
}
|
|
177
|
-
}, 100);
|
|
178
|
-
};
|
|
179
|
-
window.addEventListener("resize", handleWindowResize);
|
|
180
169
|
return ()=>{
|
|
181
170
|
if (chartRef.current) {
|
|
182
171
|
chartRef.current.off("plot:click");
|
|
@@ -186,7 +175,6 @@ const G2BarChart = ({ height = 300, data, x = "", y = "", indicatorMap, onChartC
|
|
|
186
175
|
};
|
|
187
176
|
}, [
|
|
188
177
|
filteredData,
|
|
189
|
-
height,
|
|
190
178
|
x,
|
|
191
179
|
y,
|
|
192
180
|
safeLegend,
|
|
@@ -260,7 +260,6 @@ const G2CombineChart = ({ height = 300, data, x = "", y = "", z = "", indicatorM
|
|
|
260
260
|
isCompare,
|
|
261
261
|
isHighlight,
|
|
262
262
|
isClickable: !!onChartClick,
|
|
263
|
-
height: height - canvasMarginBottom,
|
|
264
263
|
formatLabel: (isDataTag || isCombineDataTag) && !isOldData ? (d)=>{
|
|
265
264
|
const indicatorId = d.groupType.split("_")[0];
|
|
266
265
|
const key = isGroupRef.current && !d.isCombine ? "total" : indicatorId;
|
|
@@ -314,27 +313,15 @@ const G2CombineChart = ({ height = 300, data, x = "", y = "", z = "", indicatorM
|
|
|
314
313
|
title: tooltipTitle
|
|
315
314
|
});
|
|
316
315
|
});
|
|
317
|
-
const handleWindowResize = ()=>{
|
|
318
|
-
setTimeout(()=>{
|
|
319
|
-
if (chartRef.current && containerRef.current) {
|
|
320
|
-
const width = containerRef.current.clientWidth;
|
|
321
|
-
const height = containerRef.current.clientHeight;
|
|
322
|
-
chartRef.current.changeSize(width, height);
|
|
323
|
-
}
|
|
324
|
-
}, 100);
|
|
325
|
-
};
|
|
326
|
-
window.addEventListener("resize", handleWindowResize);
|
|
327
316
|
return ()=>{
|
|
328
317
|
if (chartRef.current) {
|
|
329
318
|
chartRef.current.off("plot:click");
|
|
330
319
|
chartRef.current.destroy();
|
|
331
320
|
chartRef.current = null;
|
|
332
321
|
}
|
|
333
|
-
window.removeEventListener("resize", handleWindowResize);
|
|
334
322
|
};
|
|
335
323
|
}, [
|
|
336
324
|
filteredData,
|
|
337
|
-
height,
|
|
338
325
|
x,
|
|
339
326
|
y,
|
|
340
327
|
z,
|
|
@@ -152,7 +152,6 @@ const G2LineChart = ({ height = 300, data, x = "", y = "", z = "", indicatorMap,
|
|
|
152
152
|
const indicatorId = d.groupType.split("_")[0];
|
|
153
153
|
return "-" === formatter.formatIndicator(d.groupValue, safeIndicatorMap[indicatorId]) ? "" : formatter.formatIndicator(d.groupValue, safeIndicatorMap[indicatorId]);
|
|
154
154
|
} : void 0,
|
|
155
|
-
height: height - canvasMarginBottom,
|
|
156
155
|
tooltipRender: (title, items)=>{
|
|
157
156
|
currentTooltipTitleRef.current = title;
|
|
158
157
|
const container = tooltipContainerRef.current;
|
|
@@ -194,16 +193,6 @@ const G2LineChart = ({ height = 300, data, x = "", y = "", z = "", indicatorMap,
|
|
|
194
193
|
});
|
|
195
194
|
chart.on("plot:pointerenter:", (event)=>{});
|
|
196
195
|
}
|
|
197
|
-
const handleWindowResize = ()=>{
|
|
198
|
-
setTimeout(()=>{
|
|
199
|
-
if (chartRef.current && containerRef.current) {
|
|
200
|
-
const width = containerRef.current.clientWidth;
|
|
201
|
-
const height = containerRef.current.clientHeight;
|
|
202
|
-
chartRef.current.changeSize(width, height);
|
|
203
|
-
}
|
|
204
|
-
}, 100);
|
|
205
|
-
};
|
|
206
|
-
window.addEventListener("resize", handleWindowResize);
|
|
207
196
|
return ()=>{
|
|
208
197
|
if (chartRef.current) {
|
|
209
198
|
chartRef.current.off("plot:click");
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { Chart } from "@antv/g2";
|
|
2
2
|
import { splitTextToMultiline } from "../../../utils/chartHelpers.js";
|
|
3
3
|
function createChart(options) {
|
|
4
|
-
const { container,
|
|
4
|
+
const { container, autoFit = true } = options;
|
|
5
5
|
return new Chart({
|
|
6
6
|
container,
|
|
7
|
-
height,
|
|
8
7
|
autoFit,
|
|
9
8
|
margin: 0
|
|
10
9
|
});
|
|
@@ -73,7 +72,6 @@ function applyAxisX(mark, options = {}) {
|
|
|
73
72
|
labelAutoRotate: false,
|
|
74
73
|
labelFontSize: fontSize,
|
|
75
74
|
labelFontColor: '#000',
|
|
76
|
-
size: isHorizontal ? Math.floor(containerWidth / 5) : 30,
|
|
77
75
|
labelAutoEllipsis: {
|
|
78
76
|
type: 'ellipsis',
|
|
79
77
|
minLength: 80,
|
|
@@ -81,12 +79,6 @@ function applyAxisX(mark, options = {}) {
|
|
|
81
79
|
},
|
|
82
80
|
labelAlign: 'horizontal',
|
|
83
81
|
labelDx: (_datum, _index, _data)=>0,
|
|
84
|
-
labelRender: isHorizontal ? void 0 : (datum)=>{
|
|
85
|
-
let left = '0%';
|
|
86
|
-
if (datum.value > 0.9) left = '-13%';
|
|
87
|
-
else if (datum.value < 0.1) left = '10%';
|
|
88
|
-
return `<div style="transform: translateX(${left});">${datum.label}</div>`;
|
|
89
|
-
},
|
|
90
82
|
labelOpacity: 0.6,
|
|
91
83
|
...axisFilter && {
|
|
92
84
|
tickFilter: axisFilter('tick'),
|
|
@@ -40,8 +40,6 @@ export interface RenderG2BarChartOptions {
|
|
|
40
40
|
legend?: string;
|
|
41
41
|
/** 数据标签格式化:formatLabel(datum) */
|
|
42
42
|
formatLabel?: (datum: any) => string;
|
|
43
|
-
/** 图表高度 */
|
|
44
|
-
height?: number;
|
|
45
43
|
/** Tooltip 自定义渲染:返回挂载的 DOM */
|
|
46
44
|
tooltipRender?: (title: string, items: Array<{
|
|
47
45
|
color?: string;
|
|
@@ -3,7 +3,7 @@ import { applyAuxiliaryLineY, applyAxisX, applyAxisY, applyHighlightDate, applyN
|
|
|
3
3
|
const Y_AXIS_FIELD = 'groupValue';
|
|
4
4
|
const CLOSE_HIGHLIGHT_DEBUG = false;
|
|
5
5
|
function renderG2BarChart(container, options) {
|
|
6
|
-
const { data, nodeData, x, y, maxY, timeRange: _timeRange, themeColors, indicators = [], indicatorMap: _indicatorMap = {}, formatAxis, highlightDate = [], isDataTag = false, isLegend = true, isHorizontal = false, isHighlight = true, isCompare = false, isClickable = false, legend, formatLabel,
|
|
6
|
+
const { data, nodeData, x, y, maxY, timeRange: _timeRange, themeColors, indicators = [], indicatorMap: _indicatorMap = {}, formatAxis, highlightDate = [], isDataTag = false, isLegend = true, isHorizontal = false, isHighlight = true, isCompare = false, isClickable = false, legend, formatLabel, tooltipRender, auxiliaryLineData = [], onNodeListChange, onChartRender } = options;
|
|
7
7
|
const colorOpts = {
|
|
8
8
|
themeColors,
|
|
9
9
|
primaryKey: y,
|
|
@@ -11,7 +11,6 @@ function renderG2BarChart(container, options) {
|
|
|
11
11
|
};
|
|
12
12
|
const chart = createChart({
|
|
13
13
|
container,
|
|
14
|
-
height,
|
|
15
14
|
autoFit: true
|
|
16
15
|
});
|
|
17
16
|
chart.options({
|
|
@@ -119,7 +118,7 @@ function renderG2BarChart(container, options) {
|
|
|
119
118
|
x: 0,
|
|
120
119
|
y: 0,
|
|
121
120
|
width: container.clientWidth || container.offsetWidth,
|
|
122
|
-
height:
|
|
121
|
+
height: container.clientHeight || container.offsetHeight
|
|
123
122
|
};
|
|
124
123
|
if (tooltipRender) view.interaction('tooltip', {
|
|
125
124
|
shared: true,
|
|
@@ -46,8 +46,6 @@ export interface RenderG2CombineChartOptions {
|
|
|
46
46
|
isClickable?: boolean;
|
|
47
47
|
/** 数据标签格式化:formatLabel(datum) */
|
|
48
48
|
formatLabel?: (datum: any) => string;
|
|
49
|
-
/** 图表高度 */
|
|
50
|
-
height?: number;
|
|
51
49
|
/** 时间范围(目前仅可选,预留与对比期相关的扩展) */
|
|
52
50
|
timeRange?: ChartTimeRange;
|
|
53
51
|
/** 多指标 id 列表,用于按顺序取色 */
|
|
@@ -5,10 +5,9 @@ const Y_AXIS_FIELD = 'groupValue';
|
|
|
5
5
|
const BAR_Y_FIELD = 'barValue';
|
|
6
6
|
const LINE_Y_FIELD = 'lineValue';
|
|
7
7
|
function renderG2CombineChart(container, options) {
|
|
8
|
-
const { data, nodeData, x, z: _z, maxLeft, maxRight, themeColors, indicatorMap: _indicatorMap, formatAxis, formatLineAxis, isDataTag = true, isCombineDataTag = true, isLegend: _isLegend = false, isCompare = false, formatLabel, highlightDate = [],
|
|
8
|
+
const { data, nodeData, x, z: _z, maxLeft, maxRight, themeColors, indicatorMap: _indicatorMap, formatAxis, formatLineAxis, isDataTag = true, isCombineDataTag = true, isLegend: _isLegend = false, isCompare = false, formatLabel, highlightDate = [], isHighlight = true, isClickable = false, indicators = [], tooltipRender, auxiliaryLineData = [], onNodeListChange, lineColors, onChartRender, isGroup, legendItems = [], indicatorId, isTooltipContent = false } = options;
|
|
9
9
|
const chart = createChart({
|
|
10
10
|
container,
|
|
11
|
-
height,
|
|
12
11
|
autoFit: true
|
|
13
12
|
});
|
|
14
13
|
chart.options({
|
|
@@ -254,130 +253,52 @@ function renderG2CombineChart(container, options) {
|
|
|
254
253
|
} : false
|
|
255
254
|
].filter(Boolean)
|
|
256
255
|
});
|
|
257
|
-
if (tooltipRender)
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
const
|
|
279
|
-
const
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
const offsetX = 12;
|
|
301
|
-
const offsetY = 12;
|
|
302
|
-
const applyPosition = ()=>{
|
|
303
|
-
let el = content;
|
|
304
|
-
while(el && el.parentElement){
|
|
305
|
-
const p = el.parentElement;
|
|
306
|
-
if (p.classList?.contains('g2-tooltip')) {
|
|
307
|
-
el = p;
|
|
308
|
-
break;
|
|
309
|
-
}
|
|
310
|
-
el = p;
|
|
311
|
-
}
|
|
312
|
-
const wrapper = el && el.classList?.contains('g2-tooltip') ? el : null;
|
|
313
|
-
if (!wrapper) return;
|
|
314
|
-
const wRect = wrapper.getBoundingClientRect();
|
|
315
|
-
const tooltipW = wRect.width || 260;
|
|
316
|
-
const tooltipH = wRect.height || 300;
|
|
317
|
-
const viewportWidth = window.innerWidth;
|
|
318
|
-
const viewportHeight = window.innerHeight;
|
|
319
|
-
let left = clientX + offsetX;
|
|
320
|
-
let top = clientY + offsetY;
|
|
321
|
-
if (left + tooltipW > viewportWidth - 10) left = clientX - tooltipW - offsetX;
|
|
322
|
-
if (top + tooltipH > viewportHeight - 10) top = clientY - tooltipH - offsetY;
|
|
323
|
-
if (left < 10) left = 10;
|
|
324
|
-
if (top < 10) top = 10;
|
|
325
|
-
wrapper.style.position = 'fixed';
|
|
326
|
-
wrapper.style.left = `${left}px`;
|
|
327
|
-
wrapper.style.top = `${top}px`;
|
|
328
|
-
wrapper.style.transform = 'none';
|
|
329
|
-
wrapper.style.pointerEvents = 'none';
|
|
330
|
-
wrapper.style.zIndex = '99999';
|
|
331
|
-
};
|
|
332
|
-
try {
|
|
333
|
-
applyPosition();
|
|
334
|
-
requestAnimationFrame(applyPosition);
|
|
335
|
-
} catch {}
|
|
336
|
-
} else if (content && !isTooltipContent) {
|
|
337
|
-
const domEvent = event?.event ?? event;
|
|
338
|
-
const clientX = domEvent?.clientX ?? domEvent?.x ?? 0;
|
|
339
|
-
const clientY = domEvent?.clientY ?? domEvent?.y ?? 0;
|
|
340
|
-
const rect = container.getBoundingClientRect();
|
|
341
|
-
const offsetX = 12;
|
|
342
|
-
const offsetY = 12;
|
|
343
|
-
const applyClamp = ()=>{
|
|
344
|
-
let el = content;
|
|
345
|
-
while(el && el.parentElement){
|
|
346
|
-
const p = el.parentElement;
|
|
347
|
-
if (p.classList?.contains('g2-tooltip')) {
|
|
348
|
-
el = p;
|
|
349
|
-
break;
|
|
350
|
-
}
|
|
351
|
-
el = p;
|
|
352
|
-
}
|
|
353
|
-
const wrapper = el && el.classList?.contains('g2-tooltip') ? el : null;
|
|
354
|
-
if (!wrapper) return;
|
|
355
|
-
const wRect = wrapper.getBoundingClientRect();
|
|
356
|
-
const tooltipW = wRect.width || 260;
|
|
357
|
-
const tooltipH = wRect.height || 300;
|
|
358
|
-
const minLeft = rect.left;
|
|
359
|
-
const maxLeft = rect.right - tooltipW;
|
|
360
|
-
const minTop = rect.top;
|
|
361
|
-
const maxTop = rect.bottom - tooltipH;
|
|
362
|
-
const desiredLeft = clientX + offsetX;
|
|
363
|
-
const desiredTop = clientY + offsetY;
|
|
364
|
-
const left = Math.min(Math.max(desiredLeft, minLeft), Math.max(maxLeft, minLeft));
|
|
365
|
-
const top = Math.min(Math.max(desiredTop, minTop), Math.max(maxTop, minTop));
|
|
366
|
-
wrapper.style.position = 'fixed';
|
|
367
|
-
wrapper.style.left = `${left}px`;
|
|
368
|
-
wrapper.style.top = `${top}px`;
|
|
369
|
-
wrapper.style.transform = 'translate(0px, 0px)';
|
|
370
|
-
wrapper.style.pointerEvents = 'none';
|
|
371
|
-
wrapper.style.zIndex = '9999';
|
|
372
|
-
};
|
|
373
|
-
try {
|
|
374
|
-
applyClamp();
|
|
375
|
-
requestAnimationFrame(applyClamp);
|
|
376
|
-
} catch {}
|
|
256
|
+
if (tooltipRender) {
|
|
257
|
+
const tooltipBounding = {
|
|
258
|
+
x: 0,
|
|
259
|
+
y: 0,
|
|
260
|
+
width: container.clientWidth || container.offsetWidth,
|
|
261
|
+
height: container.clientHeight || container.offsetHeight
|
|
262
|
+
};
|
|
263
|
+
view.interaction('tooltip', {
|
|
264
|
+
shared: true,
|
|
265
|
+
crosshairsY: true,
|
|
266
|
+
marker: false,
|
|
267
|
+
bounding: tooltipBounding,
|
|
268
|
+
...isTooltipContent ? {
|
|
269
|
+
mount: 'body'
|
|
270
|
+
} : {},
|
|
271
|
+
render: (payload)=>{
|
|
272
|
+
const { title, items } = payload;
|
|
273
|
+
let safeTitle = title.replace(/,.*$/, '');
|
|
274
|
+
const baseItems = items.filter((item)=>item.hasOwnProperty('isCombine') && !item.isCombine);
|
|
275
|
+
const safeItems = fillMissingIndicator(baseItems, safeTitle, isCompare, isGroup);
|
|
276
|
+
const combineItems = items.filter((item)=>item.hasOwnProperty('isCombine') && item.isCombine);
|
|
277
|
+
const safeCombineItems = fillMissingIndicator(combineItems, safeTitle, isCompare, isGroup);
|
|
278
|
+
const indicatorOrder = new Map(indicators.map((id, i)=>[
|
|
279
|
+
id,
|
|
280
|
+
i
|
|
281
|
+
]));
|
|
282
|
+
const sortedCombineItems = [
|
|
283
|
+
...safeCombineItems
|
|
284
|
+
].sort((a, b)=>{
|
|
285
|
+
const orderA = indicatorOrder.get(a.indicatorId) ?? 1 / 0;
|
|
286
|
+
const orderB = indicatorOrder.get(b.indicatorId) ?? 1 / 0;
|
|
287
|
+
if (orderA !== orderB) return orderA - orderB;
|
|
288
|
+
const typeRank = (item)=>{
|
|
289
|
+
if (item.isChange) return 2;
|
|
290
|
+
if ('compareline' === item.tipType) return 1;
|
|
291
|
+
return 0;
|
|
292
|
+
};
|
|
293
|
+
return typeRank(a) - typeRank(b);
|
|
294
|
+
});
|
|
295
|
+
return tooltipRender(safeTitle, [
|
|
296
|
+
...safeItems,
|
|
297
|
+
...sortedCombineItems
|
|
298
|
+
]) ?? null;
|
|
377
299
|
}
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
});
|
|
300
|
+
});
|
|
301
|
+
}
|
|
381
302
|
view.legend(false);
|
|
382
303
|
view.interaction('poptip', {
|
|
383
304
|
offsetY: -20,
|
|
@@ -2,10 +2,9 @@ import { lines } from "@antv/g-pattern";
|
|
|
2
2
|
import { applyAuxiliaryLineY, applyAxisX, applyAxisY, applyHighlightDate, applyScaleYLinear, createChart, getMainView } from "./g2Helpers.js";
|
|
3
3
|
const Y_AXIS_FIELD = 'groupValue';
|
|
4
4
|
function renderG2GroupBarChart(container, options) {
|
|
5
|
-
const { data, x, y, maxY, timeRange: _timeRange, themeColors, indicators: _indicators = [], indicatorMap: _indicatorMap = {}, formatAxis, highlightDate = [], isDataTag = false, isLegend = true, isHorizontal = false, isHighlight = true, isCompare: _isCompare = false, legend, formatLabel,
|
|
5
|
+
const { data, x, y, maxY, timeRange: _timeRange, themeColors, indicators: _indicators = [], indicatorMap: _indicatorMap = {}, formatAxis, highlightDate = [], isDataTag = false, isLegend = true, isHorizontal = false, isHighlight = true, isCompare: _isCompare = false, legend, formatLabel, tooltipRender, auxiliaryLineData = [], onNodeListChange, legendItems = [], indicatorId } = options;
|
|
6
6
|
const chart = createChart({
|
|
7
7
|
container,
|
|
8
|
-
height,
|
|
9
8
|
autoFit: true
|
|
10
9
|
});
|
|
11
10
|
chart.options({
|
|
@@ -93,7 +92,7 @@ function renderG2GroupBarChart(container, options) {
|
|
|
93
92
|
x: 0,
|
|
94
93
|
y: 0,
|
|
95
94
|
width: container.clientWidth || container.offsetWidth,
|
|
96
|
-
height:
|
|
95
|
+
height: container.clientHeight || container.offsetHeight
|
|
97
96
|
};
|
|
98
97
|
interval.interaction('tooltip', {
|
|
99
98
|
shared: true,
|
|
@@ -114,7 +113,7 @@ function renderG2GroupBarChart(container, options) {
|
|
|
114
113
|
x: 0,
|
|
115
114
|
y: 0,
|
|
116
115
|
width: container.clientWidth || container.offsetWidth,
|
|
117
|
-
height:
|
|
116
|
+
height: container.clientHeight || container.offsetHeight
|
|
118
117
|
};
|
|
119
118
|
view.interaction('tooltip', {
|
|
120
119
|
bounding: tooltipBounding
|
|
@@ -45,8 +45,6 @@ export interface RenderG2LineChartOptions {
|
|
|
45
45
|
isHighlight?: boolean;
|
|
46
46
|
/** 数据标签格式化:formatLabel(datum) */
|
|
47
47
|
formatLabel?: (datum: any) => string;
|
|
48
|
-
/** 图表高度 */
|
|
49
|
-
height?: number;
|
|
50
48
|
/** 图例宽度(像素,position 为 bottom 时生效) */
|
|
51
49
|
legendLength?: number;
|
|
52
50
|
/** 图例区域高度(像素,可选) */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { applyAuxiliaryLineY, applyAxisX, applyAxisY, applyHighlightDate, applyNodeData, applyScaleYLinear, createChart, getColorByGroupType, getMainView } from "./g2Helpers.js";
|
|
2
2
|
const Y_AXIS_FIELD = 'groupValue';
|
|
3
3
|
function renderG2LineChart(container, options) {
|
|
4
|
-
const { data, nodeData, x, y, minY, maxY, timeRange: _timeRange, themeColors, indicators = [], indicatorMap: _indicatorMap = {}, formatAxis, highlightDate = [], auxiliaryLineData = [], isDataTag = false, isLegend = true, isHighlight = true, formatLabel,
|
|
4
|
+
const { data, nodeData, x, y, minY, maxY, timeRange: _timeRange, themeColors, indicators = [], indicatorMap: _indicatorMap = {}, formatAxis, highlightDate = [], auxiliaryLineData = [], isDataTag = false, isLegend = true, isHighlight = true, formatLabel, legendLength: _legendLength, legendSize: _legendSize, tooltipRender, onNodeListChange, onChartRender } = options;
|
|
5
5
|
const colorOpts = {
|
|
6
6
|
themeColors,
|
|
7
7
|
primaryKey: y,
|
|
@@ -9,7 +9,6 @@ function renderG2LineChart(container, options) {
|
|
|
9
9
|
};
|
|
10
10
|
const chart = createChart({
|
|
11
11
|
container,
|
|
12
|
-
height,
|
|
13
12
|
autoFit: true
|
|
14
13
|
});
|
|
15
14
|
chart.options({
|
|
@@ -84,7 +83,7 @@ function renderG2LineChart(container, options) {
|
|
|
84
83
|
x: 0,
|
|
85
84
|
y: 0,
|
|
86
85
|
width: container.clientWidth || container.offsetWidth,
|
|
87
|
-
height:
|
|
86
|
+
height: container.clientHeight || container.offsetHeight
|
|
88
87
|
};
|
|
89
88
|
if (tooltipRender) view.interaction('tooltip', {
|
|
90
89
|
shared: true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@publishfx/publish-chart",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.20",
|
|
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": [
|