123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328 |
- <template>
- <view>
- <view class="all">
- <view class="chart">
- <view class="charts-box">
- <best-gauge :config="gaugeOption"></best-gauge>
- </view>
- <view class="charts-box">
- <best-gauge :config="gaugeOption2"></best-gauge>
- </view>
- </view>
- <view class="white">
- <view class="title1">
- <text class="param">空调排风温度变化</text>
- <view class="tiao"></view>
- </view>
- <view>
- <canvas canvas-id="canvasLineA" id="canvasLineA" class="charts" @touchmove="moveLineA"
- @touchend="moveLineA"></canvas>
- <!-- 画布,图表的HTML部分-->
- </view>
- </view>
- <view class="white1">
- <view class="title1">
- <text class="param">空调排风湿度变化</text>
- <view class="tiao"></view>
- </view>
- <view>
- <canvas canvas-id="canvasLineA11" id="canvasLineA11" class="charts" @touchmove="moveLineA11"
- @touchend="moveLineA11"></canvas>
- <!-- 画布,图表的HTML部分-->
- </view>
- </view>
- <view class="anniu">
- <image class="anniu" src="../../static/设备菜单/前往列表@2x.png" @tap="back"></image>
- </view>
- </view>
- </view>
- </template>
- <script>
- //仪表盘组件
- import bestGauge from '@/components/best-gauge/best-gauge.vue'
- //引入u-charts组件
- import uCharts from '@/components/u-charts/u-charts.js'
- var _self; //用于全局使用this
- var _self11; //用于全局使用this
- var canvaLineA = null; //uCharts实例
- var canvaLineA11 = null; //uCharts实例
- export default {
- components: {
- bestGauge,
- },
- data() {
- let _width = uni.upx2px(350);
- return {
- formData: {
- WD_1: '',
- SD_1: '',
- },
- cWidth: '',
- cHeight: '', //画布的宽高
- //仪表盘部分
- gaugeOption: { //定义参数
- id: 'gaugeId0',
- value: '',
- axisTickLength: 2 //该属性与axisTick互斥,存在axisTickLength并大于0,axisTick就无效
- },
- gaugeOption2: { //定义参数
- name: 'CK01排风湿度显示',
- id: 'gaugeId1',
- value: '',
- unit: '%',
- axisTickLength: 2 //该属性与axisTick互斥,存在axisTickLength并大于0,axisTick就无效
- },
- //折线图部分
- //温度
- data: { //数据
- categories: ["周一", "周二", "周三", "周四", "周五", "周六", "周日"],
- series: [{
- name: "温度",
- data: [40, 30, 36, 44, 34, 30, 22],
- }]
- },
- //湿度
- data11: { //数据
- categories11: ["周一", "周二", "周三", "周四", "周五", "周六", "周日"],
- series11: [{
- name: "湿度",
- data: [40, 30, 36, 44, 38, 34, 30],
- }]
- },
- }
- },
- onLoad() {
- this.getWD_1()
- this.getSD_1()
- this.cWidth = uni.upx2px(702);
- this.cHeight = uni.upx2px(500); //设置宽高
- _self = this //声明this
- _self.showLineA("canvasLineA", _self.data); //触发执行函数
- _self11 = this //声明this
- _self11.showLineA11("canvasLineA11", _self11.data11); //触发执行函数
- },
- methods: {
- back() {
- uni.navigateTo({
- url: '/pages/device/deviceInfo/deviceInfo'
- })
- },
- showLineA(canvasId, chartData) {
- canvaLineA = new uCharts({ //这些配置项的意思看这:https://www.kancloud.cn/qiun/ucharts/1172125
- $this: _self, //指针
- canvasId: canvasId, //id
- type: 'line', //类型
- colors: ['#F45E41'], //每一条的颜色
- fontSize: 14, //字体大小
- padding: [15, 15, 0, 15], //空白区域值
- legend: { //图例相关配置
- show: true,
- padding: 5,
- lineHeight: 11,
- margin: 0,
- },
- dataLabel: false, //显示数据标签内容值
- categories: chartData.categories, //数据类别
- series: chartData.series, //数据列表
- xAxis: { //X轴配置
- gridColor: '#CCCCCC', //X轴网格颜色
- gridType: 'dash', //X轴网格线型 'solid'为实线、'dash'为虚线`
- dashLength: 8, //X轴网格为虚线时,单段虚线长度
- },
- yAxis: { //y轴配置
- gridType: 'dash',
- gridColor: '#CCCCCC',
- dashLength: 8,
- },
- width: _self.cWidth, //canvas宽度,单位为px
- height: _self.cHeight, //canvas高度,单位为px
- extra: { //扩展配置
- line: {
- type: 'curve' //曲线 curve曲线,straight直线
- }
- }
- });
- },
- moveLineA(e) {
- canvaLineA.showToolTip(e, { //详情框
- format: function(item, category) {
- return category + ' ' + item.name + ':' + item.data + '℃'
- }
- });
- },
- //湿度
- showLineA11(canvasId, chartData) {
- canvaLineA11 = new uCharts({ //这些配置项的意思看这:https://www.kancloud.cn/qiun/ucharts/1172125
- $this: _self11, //指针
- canvasId: canvasId, //id
- type: 'line', //类型
- colors: ['#007AFF'], //每一条的颜色
- fontSize: 14, //字体大小
- padding: [15, 15, 0, 15], //空白区域值
- legend: { //图例相关配置
- show: true,
- padding: 5,
- lineHeight: 11,
- margin: 0,
- },
- dataLabel: false, //显示数据标签内容值
- categories: chartData.categories11, //数据类别
- series: chartData.series11, //数据列表
- xAxis: { //X轴配置
- gridColor: '#CCCCCC', //X轴网格颜色
- gridType: 'dash', //X轴网格线型 'solid'为实线、'dash'为虚线`
- dashLength: 8, //X轴网格为虚线时,单段虚线长度
- },
- yAxis: { //y轴配置
- gridType: 'dash',
- gridColor: '#CCCCCC',
- dashLength: 8,
- },
- width: _self11.cWidth, //canvas宽度,单位为px
- height: _self11.cHeight, //canvas高度,单位为px
- extra: { //扩展配置
- line: {
- type: 'curve' //曲线 curve曲线,straight直线
- }
- }
- });
- },
- moveLineA11(e) {
- canvaLineA11.showToolTip(e, { //详情框
- format: function(item, category) {
- return category + ' ' + item.name + ':' + item.data + '%'
- }
- });
- },
- async getWD_1(e) {
- let vm = this;
- let url = uni.$api.deviceParam.detail;
- let data = {
- id: "206",
- };
- let res = await uni.$http.get(url, data);
- console.log('form发生了submit事件')
- this.gaugeOption.value = res.data.data.deviceParam.value;
- },
- async getSD_1(e) {
- let vm = this;
- let url = uni.$api.deviceParam.detail;
- let data = {
- id: "284",
- };
- let res = await uni.$http.get(url, data);
- console.log('form发生了submit事件')
- this.gaugeOption2.value = res.data.data.deviceParam.value;
- },
- }
- }
- </script>
- <style>
- .anniu {
- width: 116rpx;
- height: 116rpx;
- float: right;
- margin-top: 20rpx;
- }
- .charts {
- margin-top: 60rpx;
- width: 702rpx;
- height: 500rpx;
- background-color: #FFFFFF;
- }
- .title1 {
- display: flex;
- flex-direction: column;
- align-items: center;
- }
- .tiao {
- width: 60px;
- height: 3px;
- margin-top: 20rpx;
- background: #007AFF;
- }
- .param {
- font-size: 38rpx;
- font-weight: 550;
- margin-top: 40rpx;
- }
- .white {
- width: 702rpx;
- height: 720rpx;
- margin-left: 24rpx;
- background-color: white;
- margin-top: 28rpx;
- border-radius: 10rpx;
- }
- .white1 {
- width: 702rpx;
- height: 720rpx;
- margin-left: 24rpx;
- background-color: white;
- margin-top: 28rpx;
- border-radius: 10rpx;
- }
- .chart {
- font-size: 26rpx;
- height: 300px;
- /* background:white; */
- background: rgb(30, 130, 250);
- display: flex;
- flex-direction: row;
- align-items: center;
- justify-content: center;
- }
- .charts-box {
- margin-left: 8rpx;
- margin-right: 8rpx;
- }
- </style>
|