Commit 00f944c0583cf97dbb7d3a9238c9ad8e8d43b9ef
1 parent
2af1a411
fix: visual board DashBoardComponent dynamic update max value
Showing
1 changed file
with
25 additions
and
3 deletions
... | ... | @@ -261,7 +261,15 @@ const handleValue = (value: any) => { |
261 | 261 | |
262 | 262 | export const update_instrument_1_value = (params: DashBoardValue) => { |
263 | 263 | const { value = 0, unit = '°C', fontColor } = params; |
264 | - let max = value > 1 ? Number(1 + Array(String(value).length).fill(0).join('')) / 2 : 100 / 2; | |
264 | + let max = | |
265 | + value > 1 | |
266 | + ? Number( | |
267 | + 1 + | |
268 | + Array(String(Math.floor(value)).length) | |
269 | + .fill(0) | |
270 | + .join('') | |
271 | + ) / 2 | |
272 | + : 100 / 2; | |
265 | 273 | max = value > max ? max * 2 : max; |
266 | 274 | return { |
267 | 275 | series: [ |
... | ... | @@ -288,8 +296,22 @@ export const update_instrument_2_value = (params: DashBoardValue) => { |
288 | 296 | const thirdRecord = getGradient(Gradient.THIRD, gradientInfo); |
289 | 297 | |
290 | 298 | let max = thirdRecord?.value || secondRecord?.value || firstRecord?.value || 70; |
291 | - max = Number(1 + Array(String(max).length).fill(0).join('')); | |
292 | - max = value > 1 ? Number(1 + Array(String(value).length).fill(0).join('')) / 2 : 100 / 2; | |
299 | + max = Number( | |
300 | + 1 + | |
301 | + Array(String(Math.floor(max)).length) | |
302 | + .fill(0) | |
303 | + .join('') | |
304 | + ); | |
305 | + | |
306 | + max = | |
307 | + value > 1 | |
308 | + ? Number( | |
309 | + 1 + | |
310 | + Array(String(Math.floor(value)).length) | |
311 | + .fill(0) | |
312 | + .join('') | |
313 | + ) / 2 | |
314 | + : 100 / 2; | |
293 | 315 | max = value > max ? max * 2 : max; |
294 | 316 | |
295 | 317 | const firstGradient = firstRecord?.value ? firstRecord.value / max : 0.3; | ... | ... |