Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita6c5cf3

Browse files
committed
[Fix]:#1836 race condition barchart
1 parentf4f6941 commita6c5cf3

File tree

3 files changed

+40
-3
lines changed

3 files changed

+40
-3
lines changed

‎client/packages/lowcoder-comps/src/comps/barChartComp/barChartComp.tsx‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ BarChartTmpComp = withViewFn(BarChartTmpComp, (comp) => {
6161
const[chartSize,setChartSize]=useState<ChartSize>();
6262
constfirstResize=useRef(true);
6363
consttheme=useContext(ThemeContext);
64+
const[chartKey,setChartKey]=useState(0);
65+
constprevRaceMode=useRef<boolean>();
6466
constdefaultChartTheme={
6567
color:chartColorPalette,
6668
backgroundColor:"#fff",
@@ -73,6 +75,16 @@ BarChartTmpComp = withViewFn(BarChartTmpComp, (comp) => {
7375
log.error('theme chart error: ',error);
7476
}
7577

78+
// Detect race mode changes and force chart recreation
79+
constcurrentRaceMode=comp.children.chartConfig?.children?.comp?.children?.race?.getView();
80+
useEffect(()=>{
81+
if(prevRaceMode.current!==undefined&&prevRaceMode.current!==currentRaceMode){
82+
// Force chart recreation when race mode changes
83+
setChartKey(prev=>prev+1);
84+
}
85+
prevRaceMode.current=currentRaceMode;
86+
},[currentRaceMode]);
87+
7688
consttriggerClickEvent=async(dispatch:any,action:CompAction<JSONValue>)=>{
7789
awaitgetPromiseAfterDispatch(
7890
dispatch,
@@ -176,10 +188,11 @@ BarChartTmpComp = withViewFn(BarChartTmpComp, (comp) => {
176188
return(
177189
<divref={containerRef}style={{height:'100%'}}>
178190
<ReactECharts
191+
key={chartKey}
179192
ref={(e)=>(echartsCompRef.current=e)}
180193
style={{height:"100%"}}
181-
notMerge
182-
lazyUpdate
194+
notMerge={!currentRaceMode}
195+
lazyUpdate={!currentRaceMode}
183196
opts={{locale:getEchartsLocale()}}
184197
option={option}
185198
mode={mode}

‎client/packages/lowcoder-comps/src/comps/barChartComp/barChartUtils.ts‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,15 @@ export function getEchartsConfig(
201201
animationEasing:'linear',
202202
animationEasingUpdate:'linear',
203203
}
204+
}else{
205+
// Ensure proper animation settings when race is disabled
206+
config={
207+
...config,
208+
animationDuration:1000,
209+
animationDurationUpdate:1000,
210+
animationEasing:'cubicOut',
211+
animationEasingUpdate:'cubicOut',
212+
}
204213
}
205214
if(props.data.length<=0){
206215
// no data
@@ -333,6 +342,21 @@ export function getEchartsConfig(
333342
animationDurationUpdate:300
334343
},
335344
}
345+
}else{
346+
// Reset axis animations when race is disabled
347+
config={
348+
...config,
349+
xAxis:{
350+
...config.xAxis,
351+
animationDuration:undefined,
352+
animationDurationUpdate:undefined
353+
},
354+
yAxis:{
355+
...config.yAxis,
356+
animationDuration:undefined,
357+
animationDurationUpdate:undefined
358+
},
359+
}
336360
}
337361
}
338362
// console.log("Echarts transformedData and config", transformedData, config);

‎client/packages/lowcoder-comps/src/comps/basicChartComp/chartConfigs/barChartConfig.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export const BarChartConfig = (function () {
5353
type:"bar",
5454
subtype:props.type,
5555
realtimeSort:props.race,
56-
seriesLayoutBy:props.race?'column':undefined,
56+
seriesLayoutBy:props.race?'column':'row',
5757
label:{
5858
show:props.showLabel,
5959
position:"top",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp