延迟chart.js的动画

Delay animation of chart.js

本文关键字:动画 js chart 延迟      更新时间:2023-09-26

我是这方面的新手,当页面加载时,我的图表会自动启动,所以我的问题是如何延迟动画,直到它进入视图端口,执行此操作的代码是什么,以及它在chart.js中的确切位置?

谢谢。

您首先需要安装:此处延迟的chartjs插件然后添加到您的商品

plugins: {
    deferred: {           // enabled by default
        xOffset: 150,     // defer until 150px of the canvas width are inside the viewport
        yOffset: '50%',   // defer until 50% of the canvas height are inside the viewport
        delay: 500        // delay of 500 ms after the canvas is considered inside the viewport
    }
}