我正在使用 react-d3-speedometer 在我的 React Web 應用程式上顯示速度計,但我遇到了問題。
我想使用百分比作為速度表之一的值,但默認情況下 svg 中的所有數字都有大約 8 位小數。它看起來像這樣:
我用于此車速表的代碼如下:
<ReactSpeedometer
maxValue={1}
value={0.5924}
valueFormat="%"
width={250}
height={150}
/>
我認為這不應該是默認行為,并且我可能錯誤地設定了一個值,但我在本網站或開發人員中找不到其他有此問題的人。我希望你們中的一個可愛的 Stack Overflow 人能來救援。提前感謝任何回答的人!
uj5u.com熱心網友回復:
取自這里:https ://github.com/d3/d3-format#locale_format :
If the precision is not specified, it defaults to 6 for all types except ? (none), which defaults to 12。
因此,您應該嘗試 .2%在valueFormat點后獲得 2 位數字。
<ReactSpeedometer
maxValue={1}
value={0.5924}
valueFormat=".2%"
width={250}
height={150}
/>
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/463795.html
