7***@qq.com
7***@qq.com
  • 发布:2023-11-24 14:07
  • 更新:2023-11-24 14:07
  • 阅读:127

使用ucharts动态新增数据,想实现点击按钮,就会继续增加线段,但结果是把已经显示的线段和新的线段一起加载,每点击一次都是

分类:uni-app
<view class="chart1"> <qiun-data-charts type="line" opts="opts" chartData="chartData1" />
</view>
<button type="primary" @click="test"></button>
<script>
data(){
return{
chart1: [ ],
chartData1:{
categories: Array(1000).fill("0"),
series: [
{
data: [ ]
}
]
},
}
},
methods:{
test() {
uni.request({
url: 'http://xxxx',
success: (res1) => {
const newData = res1.data.data[0]
this.chart1 = [...this.chart1, ...newData];
if (this.chart1.length >= this.dataNum) {
this.chart1 = this.chart1.slice(this.chart1.length - this.dataNum);
}
this.chartData1.series[0].data = this.chart1;
}
});
}

</script>

2023-11-24 14:07 负责人:无 分享
已邀请:

要回复问题请先登录注册