使用ngx-echarts设置定时器,原想把定时器放到charts中,但发现不行,后来就想可以把charts分段写,把需要的定时的放在定时器中,其他的不变,直接上源码
ngOnInit() { this.chartOptionsong = { tooltip : { formatter: '{a} <br/>{b} : {c}%' }, toolbox: { feature: { restore: {}, saveAsImage: {} } }, }; setInterval(() => { let random1 = parseFloat((Math.random() * 100).toFixed(2)); this.chartOptionsong = { series: [ { name: '业务指标', type: 'gauge', detail: { formatter: '{value}%', fontSize: 9 }, data: [{value: random1, name: '完成率'}], axisLabel: { fontSize: 8 }, title: { fontSize: 9, padding: [138, 4, 5, 6] } // markPoint: { // symbolSize: 25 // } } ] }; }, 2000); }