[英]Chartjs line graph point hover animation buggy / jumpy
我正在嘗試在 chart.js 中制作折線圖,以顯示 hover 超過索引時的點。 如果您快速移動鼠標,似乎 hover animation 可能會出錯並在您顯然沒有懸停的點上播放 animation。 You can see what I'm referring to here https://jsfiddle.net/yoh9L1km/3/ as well as https://www.chartjs.org/samples/latest/scales/linear/step-size.html but it在他們的示例中很難看到,因為 hover animation 很小。
我嘗試將模式更改為 x 或 x-index ,但沒有成功。 It would be acceptable to me if there was no point hover animation, but when I set the hover animationDuration to 0, the tooltip animation is also instant which I don't want.
它不會讓我在不添加一些代碼的情況下發布,所以
hover: {
mode: 'index',
intersect: false,
animationDuration: 0
},
tooltips: {
mode: 'index',
intersect: false
}
編輯:想出了下一節。
此外,不相關但如果有人對如何添加一條垂直虛線連接我懸停的點和 x 軸索引有任何想法,我很想聽聽他們的意見!
這將在最新版本的 Chart.js 中得到修復。 我從 Github 中提取了最新版本,構建並測試了它,您看到的問題不再存在。 小提琴在https://jsfiddle.net/8rc6y9zg/提供。
我認為正是這個提交修復了它(但還沒有通過 repo 檢查。)。
最新的公開版本是 2.9.3,如果您等不及下一個版本,您可以構建和自托管 3.0 alpha 版本。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.