fix: force full ECharts re-mount on wordcloud config change
React key now includes shape+size+gridSize+customImage, ensuring the echarts instance is fully destroyed and recreated when switching shapes. This bypasses the wordcloud plugin's internal mask cache. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
abe696deb5
commit
95bd6c4f55
|
|
@ -272,8 +272,11 @@ export function buildWordcloudOption(
|
|||
data: wordData,
|
||||
};
|
||||
|
||||
// Always set maskImage explicitly — undefined clears previous mask
|
||||
series.maskImage = maskImage ?? undefined;
|
||||
if (maskImage) {
|
||||
series.maskImage = maskImage;
|
||||
}
|
||||
// For rectangle: no maskImage, no shape — pure default fills the container
|
||||
// For other shapes with mask: maskImage handles the shape
|
||||
|
||||
option.series = [series];
|
||||
return option;
|
||||
|
|
|
|||
|
|
@ -38,9 +38,11 @@ export const ChartRenderer: React.FC<ChartRendererProps> = ({ chart, data, chart
|
|||
default:
|
||||
const borderRadius = chart.style?.background?.borderRadius ?? 0;
|
||||
const overflow = borderRadius > 0 ? 'hidden' as const : undefined;
|
||||
// Force re-mount when wordcloud shape changes (plugin caches mask internally)
|
||||
const wcShape = (chart.style as any)?.wordcloud?.shape ?? 'default';
|
||||
const echartsKey = chart.type === 'wordcloud' ? `${chartId}-${wcShape}` : chartId;
|
||||
// Force re-mount when wordcloud config changes (plugin caches mask internally)
|
||||
const wcConfig = (chart.style as any)?.wordcloud;
|
||||
const echartsKey = chart.type === 'wordcloud' && wcConfig
|
||||
? `${chartId}-${wcConfig.shape}-${wcConfig.sizeMin}-${wcConfig.sizeMax}-${wcConfig.gridSize}-${wcConfig.customImageUrl ? 'img' : 'no'}`
|
||||
: chartId;
|
||||
return echartsOption
|
||||
? <EChartsBase key={echartsKey} chartId={chartId} option={echartsOption} style={{ width: '100%', height: '100%', minHeight: 250, borderRadius, overflow }} />
|
||||
: <div style={{ padding: 16, color: '#999', textAlign: 'center' }}>请绑定数据字段</div>;
|
||||
|
|
|
|||
Loading…
Reference in New Issue