uniapp+echarts开发APP版本教程
2023-12-29 13:53:07
需求
需要在uniapp+echarts展示图表功能,是APP版本,不是小程序。找了好多教程都乱七八糟的,无法实现。以下是效果图
教程
1、安装插件
HBuilder安装echarts插件,插件地址如下。安装完成后在uni_modules/lime-echart文件夹下
https://ext.dcloud.net.cn/plugin?id=4899
2,代码
<template>
<view class="app-container" style="padding-bottom: 0;">
<view class="myBody">
<uni-row style="margin-top: 20px;">
<uni-col :span="24">
<view style="width: 100%; height: 220px;background: #fafafa;">
<l-echart ref="deviceTypesChart" @finished="deviceTypeInit"></l-echart>
</view>
</uni-col>
</uni-row>
</view>
</view>
</template>
<script>
import * as echarts from '@/uni_modules/lime-echart/static/echarts.min';
export default {
name: "IndexPhone",
components: {
},
data() {
return {
}
},
created() {
},
onReady() {
},
onLoad() {
},
methods: {
deviceTypeInit() {
var _this = this;
uni.request({
url: _this.api + '/getDeviceStatusNum',
method: 'get',
data: '',
header: {
'Content-Type': 'application/json',
'Authorization': "Bearer " + uni.getStorageSync("loginToken"),
'language': uni.getStorageSync("flowinnIotLanguage")
},
success: function(res) {
var response = res.data;
let deviceTypes = response.rows;
let option = {
tooltip: {
trigger: 'item'
},
legend: {
top: '3px',
left: 'center'
},
// 关闭,远控,禁用,近控
color:['#a0a1a3','#4fb989','#f55b83','#58c3fb'],
series: [
{
name: "设备使能状态统计",
type: 'pie',
radius: ['38%', '60%'],
avoidLabelOverlap: false,
itemStyle: {
borderRadius: 10,
borderColor: '#fff',
borderWidth: 2
},
label: {
show: false,
position: 'center'
},
emphasis: {
label: {
show: true,
fontSize: 20,
fontWeight: 'bold'
}
},
labelLine: {
show: false
},
data: deviceTypes
}
]
};
_this.$refs.deviceTypesChart.init(echarts, chartObj => {
chartObj.setOption(option);
});
},
fail: function(err) {
console.error(err);
}
});
},
},
mounted() {
},
};
</script>
<style rel="stylesheet/scss">
</style>
3、option官网
打开echarts官网,然后选择自己的图表
https://echarts.apache.org/examples/zh/index.html
打开后, 直接复制option,然后替换data就行。
?
结束
-----华丽的分割线,以下是凑字数,大家不用花时间看,快去改代码-----
-----华丽的分割线,以下是凑字数,大家不用花时间看,快去改代码-----
-----华丽的分割线,以下是凑字数,大家不用花时间看,快去改代码-----
package cn.renkai721.bean.vo;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class MakeUpTheWordCount {
private String make_up_the_word_count_column_999999999_1;
private String make_up_the_word_count_column_999999999_2;
private String make_up_the_word_count_column_999999999_3;
private String make_up_the_word_count_column_999999999_4;
private String make_up_the_word_count_column_999999999_5;
private String make_up_the_word_count_column_999999999_6;
private String make_up_the_word_count_column_999999999_7;
private String make_up_the_word_count_column_999999999_8;
private String make_up_the_word_count_column_999999999_9;
private String make_up_the_word_count_column_999999999_10;
private String make_up_the_word_count_column_999999999_11;
private String make_up_the_word_count_column_999999999_12;
private String make_up_the_word_count_column_999999999_13;
private String make_up_the_word_count_column_999999999_14;
private String make_up_the_word_count_column_999999999_15;
private String make_up_the_word_count_column_999999999_16;
private String make_up_the_word_count_column_999999999_17;
private String make_up_the_word_count_column_999999999_18;
private String make_up_the_word_count_column_999999999_19;
private String make_up_the_word_count_column_999999999_20;
public String getMake_up_the_word_count_column_999999999_1() {
return make_up_the_word_count_column_999999999_1;
}
public void setMake_up_the_word_count_column_999999999_1(String make_up_the_word_count_column_999999999_1) {
this.make_up_the_word_count_column_999999999_1 = make_up_the_word_count_column_999999999_1;
}
public String getMake_up_the_word_count_column_999999999_2() {
return make_up_the_word_count_column_999999999_2;
}
public void setMake_up_the_word_count_column_999999999_2(String make_up_the_word_count_column_999999999_2) {
this.make_up_the_word_count_column_999999999_2 = make_up_the_word_count_column_999999999_2;
}
public String getMake_up_the_word_count_column_999999999_3() {
return make_up_the_word_count_column_999999999_3;
}
public void setMake_up_the_word_count_column_999999999_3(String make_up_the_word_count_column_999999999_3) {
this.make_up_the_word_count_column_999999999_3 = make_up_the_word_count_column_999999999_3;
}
public String getMake_up_the_word_count_column_999999999_4() {
return make_up_the_word_count_column_999999999_4;
}
public void setMake_up_the_word_count_column_999999999_4(String make_up_the_word_count_column_999999999_4) {
this.make_up_the_word_count_column_999999999_4 = make_up_the_word_count_column_999999999_4;
}
public String getMake_up_the_word_count_column_999999999_5() {
return make_up_the_word_count_column_999999999_5;
}
public void setMake_up_the_word_count_column_999999999_5(String make_up_the_word_count_column_999999999_5) {
this.make_up_the_word_count_column_999999999_5 = make_up_the_word_count_column_999999999_5;
}
public String getMake_up_the_word_count_column_999999999_6() {
return make_up_the_word_count_column_999999999_6;
}
public void setMake_up_the_word_count_column_999999999_6(String make_up_the_word_count_column_999999999_6) {
this.make_up_the_word_count_column_999999999_6 = make_up_the_word_count_column_999999999_6;
}
public String getMake_up_the_word_count_column_999999999_7() {
return make_up_the_word_count_column_999999999_7;
}
public void setMake_up_the_word_count_column_999999999_7(String make_up_the_word_count_column_999999999_7) {
this.make_up_the_word_count_column_999999999_7 = make_up_the_word_count_column_999999999_7;
}
public String getMake_up_the_word_count_column_999999999_8() {
return make_up_the_word_count_column_999999999_8;
}
public void setMake_up_the_word_count_column_999999999_8(String make_up_the_word_count_column_999999999_8) {
this.make_up_the_word_count_column_999999999_8 = make_up_the_word_count_column_999999999_8;
}
public String getMake_up_the_word_count_column_999999999_9() {
return make_up_the_word_count_column_999999999_9;
}
public void setMake_up_the_word_count_column_999999999_9(String make_up_the_word_count_column_999999999_9) {
this.make_up_the_word_count_column_999999999_9 = make_up_the_word_count_column_999999999_9;
}
public String getMake_up_the_word_count_column_999999999_10() {
return make_up_the_word_count_column_999999999_10;
}
public void setMake_up_the_word_count_column_999999999_10(String make_up_the_word_count_column_999999999_10) {
this.make_up_the_word_count_column_999999999_10 = make_up_the_word_count_column_999999999_10;
}
public String getMake_up_the_word_count_column_999999999_11() {
return make_up_the_word_count_column_999999999_11;
}
public void setMake_up_the_word_count_column_999999999_11(String make_up_the_word_count_column_999999999_11) {
this.make_up_the_word_count_column_999999999_11 = make_up_the_word_count_column_999999999_11;
}
public String getMake_up_the_word_count_column_999999999_12() {
return make_up_the_word_count_column_999999999_12;
}
public void setMake_up_the_word_count_column_999999999_12(String make_up_the_word_count_column_999999999_12) {
this.make_up_the_word_count_column_999999999_12 = make_up_the_word_count_column_999999999_12;
}
public String getMake_up_the_word_count_column_999999999_13() {
return make_up_the_word_count_column_999999999_13;
}
public void setMake_up_the_word_count_column_999999999_13(String make_up_the_word_count_column_999999999_13) {
this.make_up_the_word_count_column_999999999_13 = make_up_the_word_count_column_999999999_13;
}
public String getMake_up_the_word_count_column_999999999_14() {
return make_up_the_word_count_column_999999999_14;
}
public void setMake_up_the_word_count_column_999999999_14(String make_up_the_word_count_column_999999999_14) {
this.make_up_the_word_count_column_999999999_14 = make_up_the_word_count_column_999999999_14;
}
public String getMake_up_the_word_count_column_999999999_15() {
return make_up_the_word_count_column_999999999_15;
}
public void setMake_up_the_word_count_column_999999999_15(String make_up_the_word_count_column_999999999_15) {
this.make_up_the_word_count_column_999999999_15 = make_up_the_word_count_column_999999999_15;
}
public String getMake_up_the_word_count_column_999999999_16() {
return make_up_the_word_count_column_999999999_16;
}
public void setMake_up_the_word_count_column_999999999_16(String make_up_the_word_count_column_999999999_16) {
this.make_up_the_word_count_column_999999999_16 = make_up_the_word_count_column_999999999_16;
}
public String getMake_up_the_word_count_column_999999999_17() {
return make_up_the_word_count_column_999999999_17;
}
public void setMake_up_the_word_count_column_999999999_17(String make_up_the_word_count_column_999999999_17) {
this.make_up_the_word_count_column_999999999_17 = make_up_the_word_count_column_999999999_17;
}
public String getMake_up_the_word_count_column_999999999_18() {
return make_up_the_word_count_column_999999999_18;
}
public void setMake_up_the_word_count_column_999999999_18(String make_up_the_word_count_column_999999999_18) {
this.make_up_the_word_count_column_999999999_18 = make_up_the_word_count_column_999999999_18;
}
public String getMake_up_the_word_count_column_999999999_19() {
return make_up_the_word_count_column_999999999_19;
}
public void setMake_up_the_word_count_column_999999999_19(String make_up_the_word_count_column_999999999_19) {
this.make_up_the_word_count_column_999999999_19 = make_up_the_word_count_column_999999999_19;
}
public String getMake_up_the_word_count_column_999999999_20() {
return make_up_the_word_count_column_999999999_20;
}
public void setMake_up_the_word_count_column_999999999_20(String make_up_the_word_count_column_999999999_20) {
this.make_up_the_word_count_column_999999999_20 = make_up_the_word_count_column_999999999_20;
}
}
文章来源:https://blog.csdn.net/renkai721/article/details/135285872
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。 如若内容造成侵权/违法违规/事实不符,请联系我的编程经验分享网邮箱:veading@qq.com进行投诉反馈,一经查实,立即删除!
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。 如若内容造成侵权/违法违规/事实不符,请联系我的编程经验分享网邮箱:veading@qq.com进行投诉反馈,一经查实,立即删除!