Files

2149 lines
62 KiB
Vue
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<!-- 移动端 -->
<view v-if="fIsPhone==1">
<view class="status_bar"></view>
<view class="body">
<!-- 头部 -->
<view class="kb_header" v-show="FHasMainTitle">
<view v-if="FShowSubTitle" class="subtitle">{{FSubTitle}}</view>
<view class="title">{{FMainTitle}}</view>
<!-- <view v-if="FShowSubTitle" class="datetime">{{datetime}}</view> -->
</view>
<!-- 主体 -->
<view class="kb_body">
<!-- <view style="display: flex;flex-direction: column; text-align: center;"> -->
<view v-for="(itemStyle,i) in verticalItemStyleList" :key="i"
:class="{'chart_small':itemStyle.issmall ,'chart_mian': !itemStyle.issmall && !isLandScape,'chart_lanscape': !itemStyle.issmall && isLandScape,'chart_landscape_small': itemStyle.issmall && isLandScape }" >
<!-- 混合图 -->
<div v-if="itemStyle.FIsMixedChart == true" style='height:100%' >
<view class="chart_item">
<view class="qiun-title-dot-light" v-show="itemStyle.hasTitle">
<view class="icon"></view>
{{itemStyle.fTitle}}
</view>
<view class="chart_bottom">
<canvas :canvas-id="itemStyle.fEntryID" id="canvasMix" class="kb_column" focus="false" style="width:100%; height:82vh"></canvas>
</view>
</view>
</div>
<!-- 柱状图 -->
<div v-if="itemStyle.fMappintType[0]==1 && itemStyle.FIsMixedChart == false">
<view class="chart_item">
<view class="qiun-title-dot-light" v-show="itemStyle.hasTitle">
<view class="icon"></view>
{{itemStyle.fTitle}}
</view>
<view class="chart_bottom">
<canvas :canvas-id="itemStyle.fEntryID" id="canvasMix" class="kb_column" focus="false" style="width: 100%;height:82vh;"></canvas>
</view>
</view>
</div>
<div v-if="itemStyle.fKBType==1 && itemStyle.fMappintType[0]==20 && itemStyle.FIsMixedChart == false">
<view class="chart_item">
<view class="qiun-title-dot-light" v-show="itemStyle.hasTitle">
<view class="icon"></view>
{{itemStyle.fTitle}}
</view>
<view class="chart_bottom">
<canvas :canvas-id="itemStyle.fEntryID" id="canvasColumn" style="width:100%; height:82vh;" @touchstart="touchColumn"></canvas>
</view>
</view>
</div>
<!-- 区域图 -->
<div v-if="itemStyle.fKBType==1 && itemStyle.fMappintType[0]==4 && itemStyle.FIsMixedChart == false">
<view class="chart_item">
<view class="qiun-title-dot-light" v-show="itemStyle.hasTitle">
<view class="icon"></view>{{itemStyle.fTitle}}
</view>
<view class="chart_bottom">
<canvas :canvas-id="itemStyle.fEntryID" id="canvasArea" style="width:100%; height:82vh;" @touchstart="touchArea"></canvas>
</view>
</view>
</div>
<!-- 点图 -->
<div v-if="itemStyle.fKBType==1 && itemStyle.fMappintType[0]==7 && itemStyle.FIsMixedChart == false">
<view class="chart_item">
<view class="qiun-title-dot-light" v-show="itemStyle.hasTitle">
<view class="icon"></view>{{itemStyle.fTitle}}
</view>
<view class="chart_bottom">
<canvas :canvas-id="itemStyle.fEntryID" id="canvasPoint" style="width:100%; height:82vh;"></canvas>
</view>
</view>
</div>
<!-- 折线图 -->
<div v-if="itemStyle.fMappintType[0]==3 && itemStyle.FIsMixedChart == false">
<view class="chart_item">
<view class="qiun-title-dot-light" v-show="itemStyle.hasTitle">
<view class="icon"></view>{{itemStyle.fTitle}}
</view>
<view class="chart_bottom">
<canvas :canvas-id="itemStyle.fEntryID" id="canvasLineA" style="width:100%; height:82vh;" @touchstart="touchLineA"></canvas>
</view>
</view>
</div>
<!-- 曲线图 -->
<div v-if="itemStyle.fMappintType[0]==2 && itemStyle.FIsMixedChart == false">
<view class="chart_item">
<view class="qiun-title-dot-light" v-show="itemStyle.hasTitle">
<view class="icon"></view>{{itemStyle.fTitle}}
</view>
<view class="chart_bottom">
<canvas :canvas-id="itemStyle.fEntryID" id="canvasLineA" style="width:100%; height:82vh;" @touchstart="touchLineA"></canvas>
</view>
</view>
</div>
<!-- 推叠图 -->
<div v-if="itemStyle.fMappintType[0]==6 && itemStyle.FIsMixedChart == false">
<view class="chart_item">
<view class="qiun-title-dot-light" v-show="itemStyle.hasTitle">
<view class="icon"></view>{{itemStyle.fTitle}}
</view>
<view class="chart_bottom">
<canvas :canvas-id="itemStyle.fEntryID" id="canvasLineA" style="width:100%; height:82vh;" @touchstart="touchLineA"></canvas>
</view>
</view>
</div>
<!-- 仪表盘 -->
<div v-if="itemStyle.fKBType==4">
<view class="chart_item">
<view class="qiun-title-dot-light" v-show="itemStyle.hasTitle">
<view class="icon"></view>{{itemStyle.fTitle}}
</view>
<view class="chart_bottom">
<canvas :canvas-id="itemStyle.fEntryID" id="canvasGauge" style="width: 100%;height: 82vh;" ></canvas>
</view>
</view>
</div>
<!-- 圆弧进度 -->
<div v-if="itemStyle.fKBType==6">
<view class="chart_item">
<view class="qiun-title-dot-light" v-show="itemStyle.hasTitle">
<view class="icon"></view>{{itemStyle.fTitle}}
</view>
<view class="chart_bottom">
<canvas :canvas-id="itemStyle.fEntryID" id="canvasArcbar1" style="width:100%; height:82vh"></canvas>
</view>
</view>
</div>
<!-- label -->
<div v-if="itemStyle.fKBType==5">
<view class="chart_item">
<view class="qiun-title-dot-light" v-show="itemStyle.hasTitle">
<view class="icon"></view>{{itemStyle.fTitle}}
</view>
<view class="chart_bottom">
<view class="kb_label" v-if="show" >
<view class="label_item" v-for="(itemSource,j) in itemStyle.dataSource" :key="j" style="height: 100%;font-size: 12px;color: #c4f9ff; ">
<label class="label_title">{{itemSource.CAPTION}}</label>
<view focus="false" class="label_count" v-if="itemSource.VALUE">
<label v-for="(count,i) in ((itemSource.VALUE && itemSource.VALUE).toString())" :key="i" :style="{color:itemSource.COLOR,backgroundColor:itemSource.BACKGROUND}" :class="{percent:count=='%' || count=='.'}" focus="false" >{{count}}</label>
</view>
<view focus="false" class="label_count" v-else-if="itemSource.VALUE == 0">
<label :style="{color:itemSource.COLOR,backgroundColor:itemSource.BACKGROUND}" focus="false" >{{itemSource.VALUE}}</label>
</view>
</view>
</view>
</view>
</view>
</div>
<!-- 圆环 -->
<div v-if="itemStyle.fMappintType[0]==8 && itemStyle.FIsMixedChart == false">
<view class="chart_item">
<view class="qiun-title-dot-light" v-show="itemStyle.hasTitle">
<view class="icon"></view>{{itemStyle.fTitle}}
</view>
<view class="chart_bottom">
<canvas :canvas-id="itemStyle.fEntryID" id="canvasRing" style="width:100%; height:82vh"></canvas>
</view>
</view>
</div>
<!-- 饼图 -->
<div v-if="itemStyle.fMappintType[0]==9 && itemStyle.FIsMixedChart == false">
<view class="chart_item">
<view class="qiun-title-dot-light" v-show="itemStyle.hasTitle">
<view class="icon"></view>{{itemStyle.fTitle}}
</view>
<view class="chart_bottom">
<canvas :canvas-id="itemStyle.fEntryID" id="canvasPie" style="width:100%; height:82vh"></canvas>
</view>
</view>
</div>
<!-- 列表 -->
<div v-if="itemStyle.fKBType==2">
<view class="chart_list">
<view class="qiun-title-dot-light" v-show="itemStyle.hasTitle">
<view class="icon"></view>{{itemStyle.fTitle}}
</view>
<view class="chart_bottom table_content">
<z-table :tableData='itemStyle.ListShowData' :columns='itemStyle.baseColumns' :hasheader='itemStyle.hasHeader' :tableHeight="470"></z-table>
</view>
</view>
</div>
<!-- 进度条 -->
<div v-if="itemStyle.fKBType==3">
<view class="chart_item">
<view class="qiun-title-dot-light" v-show="itemStyle.hasTitle">
<view class="icon"></view>{{itemStyle.fTitle}}
</view>
<view class="kb_process">
<view class="process_title">
<text>{{JSON.parse(itemStyle.dataSource)[0].VALUE*100}}%</text>
</view>
<cmd-progress :percent="JSON.parse(itemStyle.dataSource)[0].VALUE*100"
stroke-shape="round"
:stroke-width="15"
stroke-color="#369cff"
:show-info="false"
></cmd-progress>
</view>
</view>
</div>
<!-- 自定义html -->
<div class="diy_box" v-if="itemStyle.fKBType == 9 ">
<view class="diy">........</view>
</div>
</view>
<!-- </view> -->
</view>
</view>
<!-- 回到顶部 -->
<!-- <view class="backtop"> -->
<backTop :scrollTop="scrollTop"></backTop>
<!-- </view> -->
</view>
</template>
<script>
import uCharts from '@/js_sdk/u-charts/u-charts/u-charts.js';
import zTable from '@/components/z-table-kanban/z-table.vue';
import cmdProgress from "@/components/cmd-progress/cmd-progress.vue"
import wybTable from '@/components/wyb-table/wyb-table.vue'
import backTop from '@/components/back-top/back-top.vue'
var _self;
var canvaColumn = null;
var canvaLineA = null;
var canvaPie = null;
var canvaRing = null;
var canvaArcbar1;
var canvaGauge = null;
var canvaArea = null; // 面积图
var canvaPoint = null;
var canvaMix = null
var Billtimer = null; // 单据计数器 BY LYY
var Listtimer = null; // 列表计数器 BY LYY
export default {
data() {
return {
datetime:'', // 系统时间
FSubTitle:'', // 副标题
dateTimer:null,
datasource:[],
show:false, // 数据判断
timeId:null,
ctwidth:'',
ctheight:'',
tempstyle: '',
fIsPhone: 0,
fIsLandScape: 0,
fFPeriod: 0, //刷新频率 BY LYY
FMainTitle: '',
billNO: '',
arcbarWidth: '', //圆弧进度图,进度条宽度,此设置可使各端宽度一致
gaugeWidth: 10,
baseTableData: [],
baseColumns: [],
pixelRatio: 1,
serverData: '',
screenWidth: 0,
screenHeight: 0,
columncounts: 0,
gridStyle: {
display: 'grid',
// 'grid-gap': '5px',
'grid-template-columns': 'repeat(3, 1fr)',
'grid-template-rows': 'repeat(3,150upx)'
},
canvasid: 'canvasColumn',
tabviewStyle: {},
tabmainStyle: {},
items: [],
titleList: [], //['字段一', '字段二', '字段三'],
listRowCounts: 0,
listSourceData: [],
verticalItemStyleList: [],
Listtimer:null,
FShowSubTitle:true,
FHasMainTitle:true,
scrollTop : 0,
isLandScape: false,
}
},
onLoad: function(option) {
this.billNO = option.pageNumber;
// #ifdef APP-PLUS
plus.screen.lockOrientation('default');
// #endif
},
components: {cmdProgress,wybTable,backTop,zTable},
mounted() {
this.initdata(this) // 初始化数据 BY LYY
this.baseTableData = []
this.baseColumns = []
this.verticalItemStyleList = []
},
// 监听页面卷曲高度
onPageScroll(options){
this.scrollTop = options.scrollTop
},
// 监听尺寸变化
onResize(){
let _this = this
uni.getSystemInfo({
success: function(res) {
if (res.windowWidth > res.windowHeight) {
_this.screenWidth = res.windowWidth
console.log('横屏',_this.screenWidth);
_this.GetListData()
_this.ReloadData()
_this.$forceUpdate()
_this.isLandScape = true
} else {
_this.screenWidth = res.windowWidth
console.log('竖屏',_this.screenWidth);
_this.ReloadData()
_this.GetListData()
_this.$forceUpdate()
_this.isLandScape = false
}
}
})
},
onUnload() {
// #ifdef APP-PLUS
plus.screen.lockOrientation('portrait-primary');
// #endif
clearInterval(Billtimer); //BY LYY
if(this.Listtimer){
clearInterval(this.Listtimer);
this.Listtimer = null
}
if(this.timeId){
clearInterval(this.timeId)
this.timeId = null
}
if(this.dateTimer){
clearInterval(this.dateTimer)
this.dateTimer = null
}
},
methods: {
// 获取当前系统时间
// getDate(){
// this.datetime = moment(Date.now()).format('YYYY年MM月DD日 HH:mm')
// },
// 点击返回上一页
goIndex(){
uni.redirectTo({
url:'../../tabbar/home/home'
})
},
// 初始化定时器
async initdata(_this) {
uni.showLoading({
mask:true,
title:"正在加载数据",
});
await this.init(_this)
// setTimeout(function () {
// uni.hideLoading();
// }, 2000);
this.$nextTick(function(){
uni.hideLoading()
})
// 系统时间定时器
clearInterval(this.dateTimer)
// this.dateTimer = setInterval(()=>{this.getDate()},1000)
// 页面数据定时器
// if (this.fIsPhone ==0) {
// if(this.fFPeriod > 0) {
// this.getVerticalServerData(this.verticalItemStyleList)
// clearInterval(this.timeId)
// this.datasource=[];
// this.timeId = setInterval(()=>{this.getVerticalServerData(this.verticalItemStyleList)},this.fFPeriod)
// }
// }
// 设置单据计时器
if (this.fFPeriod > 0) {
Billtimer = setInterval(this.ReloadData, this.fFPeriod);
}
},
ReloadData() {
//重新获取后端数据,覆盖当前记录
this.init(this);
},
// 初始化的数据
async init(_this) {
_self = this;
// 获取硬件屏幕宽高
await uni.getSystemInfo({
success(res) {
// console.log(res.brand) // 手机牌子
// console.log(res.model) // 手机型号
// console.log('屏幕',res.screenWidth) // 屏幕宽度
// console.log(res.screenHeight) // 屏幕高度
if(res.screenWidth > res.screenHeight){
_this.isLandScape = true
}else {
_this.isLandScape = false
}
_this.screenWidth = res.screenWidth;
_this.screenHeight = res.screenHeight;
}
});
//let UserID = this.$store.state.userInfo.UserID;
//let DBAias = this.$store.state.userInfo.dbAlise;
//获取后台布局样式
// uni.showLoading({
// mask:true,
// title:"正在加载数据",
// });
let FBillNO = this.billNO;
await this.$request.get('/KanBan/getLayout?FBillNO='+FBillNO).then(res => {
// uni.hideLoading();
let resData = JSON.parse(res);
console.log(resData)
this.verticalItemStyleList=[]
this.gridStyle['display'] = resData.gridStyleInfo.display;
// this.gridStyle['grid-gap'] = resData.gridStyleInfo.gridgap;
this.gridStyle['grid-template-columns'] = resData.gridStyleInfo.gridtemplatecolumns;
this.gridStyle['grid-template-rows'] = resData.gridStyleInfo.gridtemplaterows;
this.fIsPhone = resData.gridStyleInfo.fisphone;
this.FMainTitle = resData.gridStyleInfo.FMainTitle;
this.FHasMainTitle = resData.gridStyleInfo.FHasMainTitle;
this.FShowSubTitle = resData.gridStyleInfo.FShowSubTitle
this.FSubTitle = resData.gridStyleInfo.FSubTitle
this.fFPeriod = resData.gridStyleInfo.FPeriod * 1000; //by lyy
for (let i = 0; i < resData.itemList.length; i++) {
resData.itemList[i]["dataSource"] = JSON.stringify(_self.jsonKeysToCase(resData.itemList[i]["dataSource"], 1));
// console.log('style',this.itemStyleList) // 没有数据的itemstyle
// 移动端
let verticalContentWidth = 0
let verticalContentHeight = 0
if(!this.isLandScape){
verticalContentWidth = this.screenWidth - 40;
if(resData.itemList[i].FHasTitle == true){
verticalContentHeight = (this.screenHeight / 2 - 140);
}else {
verticalContentHeight = (this.screenHeight / 2 - 110);
}
}else{
verticalContentWidth = this.screenWidth - 40;
if(resData.itemList[i].FHasTitle == true){
verticalContentHeight = (this.screenHeight - 100);
}else {
verticalContentHeight = (this.screenHeight - 80);
}
}
let issmall = false
if(resData.itemList[i]["fKBType"]==3 || resData.itemList[i]["fKBType"]==5 || resData.itemList[i]["fKBType"]==9){
issmall = true
}
this.verticalItemStyleList.push({
'width': verticalContentWidth + 'px',
'height': verticalContentHeight + 'px',
'fMappintType': resData.itemList[i]["fMappintType"],
'fKBType': resData.itemList[i]["fKBType"],
'dataSource': resData.itemList[i]["dataSource"],
'entry3Source': resData.itemList[i]["entry3Source"],
'fEntryID': resData.itemList[i]["fEntryID"],
'fTitle': resData.itemList[i]["fTitle"],
'contentwidth': verticalContentWidth,
'contentheight': verticalContentHeight,
'baseTableData': [],
'ListShowData': [], //列表显示数据 ADD BY LYY
'PageRows': 1, //没每页显示行数
'Currtpage': 0, //当前显示页
'totalPage': 1, //显示总页数
'baseColumns': [],
'contentStyle': 'height:' + verticalContentHeight + 'px;background-color: #FFFFFF;position: relative;font-size:20;',
'hasHeader': resData.itemList[i].FHasHeader,
'hasTitle': resData.itemList[i].FHasTitle,
'FIsMixedChart': resData.itemList[i].FIsMixedChart,
'subtitle': resData.itemList[i].FSubTitle,
'issmall':issmall
});
}
if (this.fIsPhone == 1) {
//plus.screen.lockOrientation('landscape');
}
}).catch(err => {
uni.showModal({
title: '提示',
content: err,
success: function (res) {
uni.reLaunch({
url: '/pages/tabbar/home/home'
})
},
showCancel:false
});
});
_self = this;
this.arcbarWidth = uni.upx2px(20);
if (this.fIsPhone == 1) {
this.getVerticalServerData(this.verticalItemStyleList);
//列表计时器 BY LYY
this.GetListData()
// clearInterval(this.Listtimer);
// this.Listtimer = setInterval(this.GetListData, 3000);
}
this.show = true
},
// 获取列表定时器的数据
GetListData() {
if (!this.fIsPhone && this.itemStyleList.length > 0) {
// console.log('TV')
} else {
for (let n = 0; n < this.verticalItemStyleList.length; n++) {
if (this.verticalItemStyleList[n]["fKBType"] == 2) {
let baseTableData = this.verticalItemStyleList[n].baseTableData;
// let pageHeight = this.verticalItemStyleList[n].baseColumns[0].height;
let contentheight = this.verticalItemStyleList[n].contentheight;
let PageRows = this.verticalItemStyleList[n].PageRows;
let Currtpage = this.verticalItemStyleList[n].Currtpage;
let TotalPage = this.verticalItemStyleList[n].totalPage;
let ListShowData;
this.verticalItemStyleList[n]['ListShowData'] = baseTableData
// if (TotalPage != Currtpage + 1) {
// this.verticalItemStyleList[n]['ListShowData'] = baseTableData.slice(PageRows * Currtpage, PageRows * (Currtpage +
// 1));
// this.verticalItemStyleList[n]["Currtpage"] = Currtpage + 1;
// } else {
// this.verticalItemStyleList[n]['ListShowData'] = baseTableData.slice(PageRows * Currtpage, baseTableData.length);
// this.verticalItemStyleList[n]["Currtpage"] = 0;
// }
}
}
}
},
// 移动端数据
getVerticalServerData(itemList) {
let _self = this;
for (let n = 0; n < itemList.length; n++) {
//柱状图
if (itemList[n]["fMappintType"] == 1 || (itemList[n]["fKBType"] == 1 && itemList[n]["fMappintType"] == 20)) {
let Column = {
categories: [],
series: []
};
let cateArray = [];
let qtyArray = [];
let datasource = itemList[n]["dataSource"];
if(typeof(datasource) === 'string'){
datasource = JSON.parse(datasource);
}
let entry3source = itemList[n]["entry3Source"];
if(typeof(entry3source) === 'string'){
entry3source = JSON.parse(entry3source);
}
let coltypeList = [];
for (let i = 0; i < datasource.length; i++) {
cateArray.push(datasource[i][entry3source[0]["FXCategory"].trim().toUpperCase()]);
}
let ser = [];
let max = 0;
let min = 0;
for (let i = 0; i < entry3source.length; i++) {
for (let j = 0; j < datasource.length; j++) {
qtyArray.push(datasource[j][entry3source[i]["FYValue"].toUpperCase()]);
}
max = Math.max.apply(Math, qtyArray) > max ? Math.max.apply(Math, qtyArray) : max;
min = Math.min.apply(Math, qtyArray) < min ? Math.min.apply(Math, qtyArray) : min;
if (min < 0) {
min = 0;
}
let seritem = {
textColor:'#666',
textSize:8,
name: entry3source[i]["FCaption"],
data: qtyArray,
type: 'column'
};
ser.push(seritem);
qtyArray = [];
}
Column.categories = cateArray;
Column.series = ser;
_self.showColumn(itemList[n]["fEntryID"], Column, itemList[n]["contentwidth"], itemList[n]["contentheight"], max,
min);
cateArray = [];
}
// 混合图
if (itemList[n]["FIsMixedChart"] == true) {
let datasource = itemList[n]["dataSource"];
if(typeof(datasource) === 'string'){
datasource = JSON.parse(datasource);
}
let cateArray = [];
let qtyArray = [];
let entry3source = itemList[n]["entry3Source"];
if(typeof(entry3source) === 'string'){
entry3source = JSON.parse(entry3source);
}
for (let i = 0; i < datasource.length; i++) {
cateArray.push(datasource[i][entry3source[0]["FXCategory"].trim().toUpperCase()]);
}
let ser = [];
for (let i = 0; i < entry3source.length; i++) {
for (let j = 0; j < datasource.length; j++) {
qtyArray.push(datasource[j][entry3source[i]["FYValue"].toUpperCase()]);
}
let seritem = {
name: entry3source[i]["FCaption"],
data: qtyArray,
type: entry3source[i]["type"],
style: entry3source[i]["style"]
};
ser.push(seritem);
qtyArray = [];
}
let LineA = {
categories: [],
series: []
};
//这里我后台返回的是数组,所以用等于,如果您后台返回的是单条数据,需要push进去
LineA.categories = cateArray;
LineA.series = ser
let max = Math.max.apply(Math, qtyArray) > max ? Math.max.apply(Math, qtyArray) : max;
let min = Math.min.apply(Math, qtyArray) < min ? Math.min.apply(Math, qtyArray) : min;
if (min < 0) {
min = 0;
}
_self.showMix(itemList[n]["fEntryID"], LineA, itemList[n]["contentwidth"], itemList[n]["contentheight"],max,min);
}
//推叠柱状图
if (itemList[n]["fMappintType"] == 6) {
let Column = {
categories: [],
series: []
};
let cateArray = [];
let qtyArray = [];
let datasource = itemList[n]["dataSource"];
if(typeof(datasource) === 'string'){
datasource = JSON.parse(datasource);
}
let entry3source = itemList[n]["entry3Source"];
entry3source = JSON.parse(entry3source);
let coltypeList = [];
for (let i = 0; i < datasource.length; i++) {
cateArray.push(datasource[i][entry3source[0]["FXCategory"].trim().toUpperCase()]);
}
let ser = [];
let max = 0;
let min = 0;
for (let i = 0; i < entry3source.length; i++) {
for (let j = 0; j < datasource.length; j++) {
qtyArray.push(datasource[j][entry3source[i]["FYValue"].toUpperCase()]);
}
max = Math.max.apply(Math, qtyArray) > max ? Math.max.apply(Math, qtyArray) : max;
min = Math.min.apply(Math, qtyArray) < min ? Math.min.apply(Math, qtyArray) : min;
let seritem = {
textColor:'#666',
textSize:8,
name: entry3source[i]["FCaption"],
data: qtyArray
};
ser.push(seritem);
qtyArray = [];
}
if (min < 0) {
min = 0;
}
Column.categories = cateArray;
Column.series = ser;
_self.showColumnStack(itemList[n]["fEntryID"], Column, itemList[n]["contentwidth"], itemList[n]["contentheight"], max,
min);
cateArray = [];
}
//区域图
if (itemList[n]["fKBType"] == 1 && itemList[n]["fMappintType"] == 4) {
let Area = {
categories: [],
series: []
};
let datasource = itemList[n]["dataSource"];
datasource = JSON.parse(datasource);
let entry3source = itemList[n]["entry3Source"];
entry3source = JSON.parse(entry3source);
let cateArray = [];
let qtyArray = [];
let ser = [];
for (let i = 0; i < datasource.length; i++) {
cateArray.push(datasource[i][entry3source[0]["FXCategory"].trim().toUpperCase()]);
}
for (let i = 0; i < entry3source.length; i++) {
for (let j = 0; j < datasource.length; j++) {
qtyArray.push(datasource[j][entry3source[i]["FYValue"].toUpperCase()]);
}
let seritem = {
name: entry3source[i]["FCaption"],
data: qtyArray
};
ser.push(seritem);
qtyArray = [];
}
Area.categories = cateArray;
Area.series = ser;
_self.showArea(itemList[n]["fEntryID"], Area, itemList[n]["contentwidth"], itemList[n]["contentheight"]);
}
//点图
if (itemList[n]["fKBType"] == 1 && itemList[n]["fMappintType"] == 7) {
let Area = {
categories: [],
series: []
};
let datasource = itemList[n]["dataSource"];
if(typeof(datasource) === 'string'){
datasource = JSON.parse(datasource);
}
let entry3source = itemList[n]["entry3Source"];
entry3source = JSON.parse(entry3source);
let cateArray = [];
let qtyArray = [];
let ser = [];
for (let i = 0; i < datasource.length; i++) {
cateArray.push(datasource[i][entry3source[0]["FXCategory"].trim().toUpperCase()]);
}
for (let i = 0; i < entry3source.length; i++) {
for (let j = 0; j < datasource.length; j++) {
qtyArray.push(datasource[j][entry3source[i]["FYValue"].toUpperCase()]);
}
let seritem = {
name: entry3source[i]["FCaption"],
data: qtyArray,
type: 'point'
};
ser.push(seritem);
qtyArray = [];
}
Area.categories = cateArray;
Area.series = ser;
_self.showPoint(itemList[n]["fEntryID"], Area, itemList[n]["contentwidth"], itemList[n]["contentheight"]);
}
// 曲线图
if (itemList[n]["fMappintType"] == 2) {
let datasource = itemList[n]["dataSource"];
if(typeof(datasource) === 'string'){
datasource = JSON.parse(datasource);
}
let cateArray = [];
let qtyArray = [];
let entry3source = itemList[n]["entry3Source"];
entry3source = JSON.parse(entry3source);
for (let i = 0; i < datasource.length; i++) {
cateArray.push(datasource[i][entry3source[0]["FXCategory"].trim().toUpperCase()]);
}
let ser = [];
for (let i = 0; i < entry3source.length; i++) {
for (let j = 0; j < datasource.length; j++) {
qtyArray.push(datasource[j][entry3source[i]["FYValue"].toUpperCase()]);
}
let seritem = {
name: entry3source[i]["FCaption"],
data: qtyArray
};
ser.push(seritem);
qtyArray = [];
}
let LineA = {
categories: [],
series: []
};
//这里我后台返回的是数组,所以用等于,如果您后台返回的是单条数据,需要push进去
LineA.categories = cateArray;
LineA.series = ser
let max = Math.max.apply(Math, qtyArray) > max ? Math.max.apply(Math, qtyArray) : max;
let min = Math.min.apply(Math, qtyArray) < min ? Math.min.apply(Math, qtyArray) : min;
if (min < 0) {
min = 0;
}
_self.showLineA(itemList[n]["fEntryID"], LineA, itemList[n]["contentwidth"], itemList[n]["contentheight"],'curve',max,min);
}
// 折线图
if (itemList[n]["fMappintType"] == 3) {
let datasource = itemList[n]["dataSource"];
if(typeof(datasource) === 'string'){
datasource = JSON.parse(datasource);
}
let cateArray = [];
let qtyArray = [];
let entry3source = itemList[n]["entry3Source"];
entry3source = JSON.parse(entry3source);
for (let i = 0; i < datasource.length; i++) {
cateArray.push(datasource[i][entry3source[0]["FXCategory"].trim().toUpperCase()]);
}
let ser = [];
for (let i = 0; i < entry3source.length; i++) {
for (let j = 0; j < datasource.length; j++) {
qtyArray.push(datasource[j][entry3source[i]["FYValue"].toUpperCase()]);
}
let seritem = {
name: entry3source[i]["FCaption"],
data: qtyArray
};
ser.push(seritem);
qtyArray = [];
}
let LineA = {
categories: [],
series: []
};
//这里我后台返回的是数组,所以用等于,如果您后台返回的是单条数据,需要push进去
LineA.categories = cateArray;
LineA.series = ser
let max = Math.max.apply(Math, qtyArray) > max ? Math.max.apply(Math, qtyArray) : max;
let min = Math.min.apply(Math, qtyArray) < min ? Math.min.apply(Math, qtyArray) : min;
if (min < 0) {
min = 0;
}
_self.showLineA(itemList[n]["fEntryID"], LineA, itemList[n]["contentwidth"], itemList[n]["contentheight"],'straight',max,min);
}
//环行图
if (itemList[n]["fMappintType"] == 8) {
let Ring = {
series: []
};
let datasource = itemList[n]["dataSource"];
if(typeof(datasource) === 'string'){
datasource = JSON.parse(datasource);
}
let entry3source = itemList[n]["entry3Source"];
entry3source = JSON.parse(entry3source);
let ringsourceArray = [];
for (let i = 0; i < datasource.length; i++) {
ringsourceArray.push({
name: datasource[i][entry3source[0]["FXCategory"].trim().toUpperCase()],
data: datasource[i][entry3source[0]["FYValue"].toUpperCase()]
})
}
//这里我后台返回的是数组,所以用等于,如果您后台返回的是单条数据,需要push进去
Ring.series = ringsourceArray;
_self.showRing(itemList[n]["fEntryID"], Ring, itemList[n]["contentwidth"], itemList[n]["contentheight"]);
}
//饼图
if (itemList[n]["fMappintType"] == 9) {
let pieDataSource = itemList[n]["dataSource"];
if(typeof(pieDataSource) === 'string'){
pieDataSource = JSON.parse(pieDataSource);
}
let pieentry3source = itemList[n]["entry3Source"];
pieentry3source = JSON.parse(pieentry3source);
let piesourceArray = [];
for (let i = 0; i < pieDataSource.length; i++) {
piesourceArray.push({
textColor:'#666',
textSize:8,
name: pieDataSource[i][pieentry3source[0]["FXCategory"].toUpperCase()],
data: pieDataSource[i][pieentry3source[0]["FYValue"].toUpperCase()],
})
}
let Pie = {
series: [{
"name": "一班",
"data": 50
}]
};
//这里我后台返回的是数组,所以用等于,如果您后台返回的是单条数据,需要push进去
Pie.series = piesourceArray;
_self.showPie(itemList[n]["fEntryID"], Pie, itemList[n]["contentwidth"], itemList[n]["contentheight"]);
}
// 列表数据
if (itemList[n]["fKBType"] == 2) {
let listDataSource = itemList[n]["dataSource"];
if(typeof(listDataSource) === 'string'){
listDataSource = JSON.parse(listDataSource);
}
// console.log('listDataSource',listDataSource) // 表体
let listentry3source = itemList[n]["entry3Source"];
if(typeof(listentry3source) === 'string'){
listentry3source = JSON.parse(listentry3source);
}
// console.log('listentry3source',listentry3source) // 表头
let temptitleList = [];
for (let i = 0; i < listentry3source.length; i++) {
temptitleList.push(listentry3source[i]["FCaption"]);
}
let tempbaseColumns = [];
for (let i = 0; i < listentry3source.length; i++) {
let tempwid = 0
// 列表表格宽度
if(listentry3source.length<=3){
if(!this.isLandScape){
tempwid = 660 * listentry3source[i].FPerWidth;
}else{
tempwid = (_self.screenWidth / _self.screenHeight* 690 ) * listentry3source[i].FPerWidth;
}
}else if(listentry3source.length<=5){
if(!this.isLandScape){
tempwid = 660 * 1.5 * listentry3source[i].FPerWidth;
}else{
tempwid = (_self.screenWidth / _self.screenHeight* 690 ) * listentry3source[i].FPerWidth;
}
}else{
if(!this.isLandScape){
tempwid = 660 * 2 * listentry3source[i].FPerWidth;
}else{
tempwid = (_self.screenWidth / _self.screenHeight* 690 ) * listentry3source[i].FPerWidth;
}
}
var tempentry3data = {
title: listentry3source[i]["FCaption"],
key: listentry3source[i]["FXCategory"].toUpperCase(),
width: tempwid,
};
tempbaseColumns.push(tempentry3data);
}
// console.log(tempbaseColumns)
this.titleList = temptitleList;
this.listRowCounts = listDataSource.length;
this.listSourceData = listDataSource;
// BY LYY 需要修改
let rowheight = 23; //itemList[n]["contentheight"];
// console.log("FHeight:" + tempbaseColumns[0]["FHeight"]); // undefined
itemList[n]["PageRows"] = Math.floor((itemList[n]["contentheight"] - 50 - rowheight) / rowheight);
itemList[n]["totalPage"] = Math.ceil(listDataSource.length / itemList[n]["PageRows"]);
itemList[n]["baseTableData"] = listDataSource;
itemList[n]["baseColumns"] = tempbaseColumns;
this.baseTableData = listDataSource;
this.baseColumns = tempbaseColumns;
// console.log('baseColumns',tempbaseColumns)
}
if (itemList[n]["fKBType"] == 6) {
let Arcbar1 = {
series: []
};
let datasource = itemList[n]["dataSource"];
if(typeof(datasource) === 'string'){
datasource = JSON.parse(datasource);
}
let datavalue = datasource[0]["Value".toUpperCase()] / 100;
let series = [{
name: '',
data: datavalue,
color: '#2680e4'
}];
Arcbar1.series = series;
_self.showArcbar(itemList[n]["fEntryID"], Arcbar1, itemList[n]["contentwidth"], itemList[n]["contentheight"]);
}
// label
if (itemList[n]["fKBType"] == 5) {
let sourceData = itemList[n]["dataSource"];
if(typeof(sourceData) === 'string'){
_self.datasource = JSON.parse(sourceData);
}else{
_self.datasource = sourceData
}
itemList[n]["dataSource"]=_self.datasource;
itemList[n]["FCaption"] = _self.datasource[0]["Caption".toUpperCase()];
itemList[n]["FValue"] = _self.datasource[0]["Value".toUpperCase()];
}
//仪表盘
if (itemList[n]["fKBType"] == 4) {
let datasource = itemList[n]["dataSource"];
if(typeof(datasource) === 'string'){
datasource = JSON.parse(datasource);
}
let minimum = 0
let maximum = 10
// 增加 0 判断
if(datasource[0]['Value'.toUpperCase()] == 0){
minimum = 0
maximum = 10
}else{
minimum = datasource[0]["Minimum".toUpperCase()] || 0;
maximum = datasource[0]["Maximum".toUpperCase()] || ( datasource[0]['Value'.toUpperCase()] * 2);
}
let completerate = 0
let name = ''
let title = ''
let categories = []
if(datasource[0].GAUGETYPE){
completerate = datasource[0]["Value".toUpperCase()] / (datasource[0]["Maximum".toUpperCase()]);
title = Math.round(completerate * 100) + '%'
categories = [{
value: 0.2,
color: '#f65961'
},
{
value: 0.8,
color: '#fcd32f'
}, {
value: 1,
color: '#3945a0'
},
];
}else{
categories = [ {
value: 1,
color: '#0448b1'
}
]
if(datasource[0]['Value'.toUpperCase()] == 0){
completerate = 0
name = '0'
}else{
completerate = 0.5
name = datasource[0]["Value".toUpperCase()]
}
}
//let fname=maximum=datasource[0]["FName"];
let Gauge = {
categories: [],
series: []
};
let series = [{
name: name,
data: completerate
}];
//这里我后台返回的是数组,所以用等于,如果您后台返回的是单条数据,需要push进去
Gauge.categories = categories;
Gauge.series = series;
_self.showGauge(itemList[n]["fEntryID"], Gauge, itemList[n]["contentwidth"], itemList[n]["contentheight"],title,
minimum, maximum);
}
}
this.verticalItemStyleList = itemList;
console.log('verticalItemStyleList',this.verticalItemStyleList)
itemList = []
},
// color16() { // 十六进制颜色随机
// // let colorlist = ['#262e79',#6ba1d2',#9292e3','#8d5ae3','#5651bf','#260295','#7628ff','#1fcce0','#6ba1d2','#4e7cde','#3c00dd','#3402c6','#2c00a3','#1c0066']
// var r = Math.floor(Math.random() * 256);
// var g = Math.floor(Math.random() * 256);
// var b = Math.floor(Math.random() * 256);
// var color = '#' + r.toString(16) + g.toString(16) + b.toString(16);
// return color;
// },
/**
* @param {Object} json
* @param {Object} type: 默认不传 ==>全部小写;传1 ==>全部大写;传2 ==>首字母大写
* 将json的key值进行大小写转换
*/
jsonKeysToCase(json, type) {
if (typeof(json) === "string") {
var tempJson = JSON.parse(json);
_self.toCase(tempJson, type);
return tempJson;
} else {
return json;
}
},
toCase(json, type) {
if (typeof(json) === 'object') {
if (Array.isArray(json)) {
json.forEach((item) => {
_self.toCase(item, type);
})
} else {
for (var key in json) {
var item = json[key];
if (typeof item == 'object') {
_self.toCase(item, type);
}
delete(json[key]);
switch (type) {
case 1:
//key值全部大写
json[key.toLocaleUpperCase()] = item;
break;
case 2:
//key值首字母大写,其余小写
json[key.substring(0, 1).toLocaleUpperCase() + key.substring(1).toLocaleLowerCase()] = item;
break;
default:
//默认key值全部小写
json[key.toLocaleLowerCase()] = item;
break;
}
}
}
}
},
// 配置项
// 混合图
showMix(canvasId, chartData, ctwidth, ctheight, max, min){
let qtyArray = [];
for (let i = 0; i < chartData.series.length; i++) {
// console.log(chartData.series[i].data)
chartData.series[i].format = (val) => {
// console.log(val)
if(val >= 10000){
return (val.toFixed(0) / 10000).toFixed(1) + '万'
}else if(val >= 1000){
return (val.toFixed(0) / 1000).toFixed(1) + '千'
}else{
return val
}
}
}
if(chartData.series&&chartData.series.length>0){
chartData.series.forEach(
function(el){
let arr = {
data : el.data,
name : el.name,
type : el.type,
}
qtyArray.push(arr);
}
);
}
console.log(qtyArray);
let maxTypeA = 0;
let maxTypeB = 0;
let minTypeA = 0;
let minTypeB = 0;
maxTypeA = Math.max(...qtyArray[0].data);
minTypeA = Math.min(...qtyArray[0].data);
maxTypeB = Math.max(...qtyArray[1].data);
minTypeB = Math.min(...qtyArray[1].data);
let contentheight = ctheight;
canvaMix = new uCharts({
$this:_self,
canvasId: canvasId,
type: 'mix',
enableScroll: false,
colors:['#15affb','#00cd9a','#9292e3','#ffcc1f','#e0c79a','#bfe048'],
padding:[30,15,0,15],
legend: {
fontColor:'#666',
margin:5,
show: true
},
fontSize: 8,
background: '#fff',
pixelRatio: _self.pixelRatio,
animation: true,
categories: chartData.categories,
series: chartData.series,
xAxis: {
rotateLabel:true,
disableGrid: true,
},
yAxis: {
disableGrid:true,
splitNumber:3,
data:[{
calibration:true,
position:'left',
title:qtyArray[0].type,
titleFontSize:12,
max:maxTypeA,
min:minTypeA,
format:(val)=>{return val.toFixed(0)}
},{
calibration:true,
position:'right',
title:qtyArray[1].type,
titleFontSize:12,
max:maxTypeB,
min:minTypeB,
format:(val)=>{return val.toFixed(0)}
},],
},
dataLabel: true,
width: ctwidth, //_self.cWidth*_self.pixelRatio,
height: contentheight, //_self.cHeight*_self.pixelRatio,
extra: {
column: {
meter:{
border:5
},
type: 'group',
width: 25 //_self.cWidth*_self.pixelRatio*0.45/chartData.categories.length
}
}
});
},
showColumn(canvasId, chartData, ctwidth, ctheight, max, min) {
for (let i = 0; i < chartData.series.length; i++) {
// console.log(chartData.series[i].data)
chartData.series[i].format = (val) => {
// console.log(val)
if(val >= 10000){
return (val.toFixed(0) / 10000).toFixed(1) + '万'
}else if(val >= 1000){
return (val.toFixed(0) / 1000).toFixed(1) + '千'
}else{
return val
}
}
}
// console.log('图表宽度',ctwidth)
// let contentwidth = 500;
let contentheight = ctheight;
canvaColumn = new uCharts({
$this: _self,
canvasId: canvasId,
type: 'column',
enableScroll: false,
colors:['#15affb','#00cd9a','#9292e3','#ffcc1f','#e0c79a','#bfe048'],
padding:[30,15,0,15],
legend: {
fontColor:'#666',
margin:5,
show: true
},
fontSize: 8,
background: '#fff',
pixelRatio: _self.pixelRatio,
animation: true,
categories: chartData.categories,
series: chartData.series,
xAxis: {
rotateLabel:true,
disableGrid: true,
},
yAxis: {
disableGrid:true,
splitNumber:3,
//disabled:true
min: min,
max: max,
format: (val) => {
return val.toFixed(0)
}
},
dataLabel: true,
width: ctwidth, //_self.cWidth*_self.pixelRatio,
height: contentheight, //_self.cHeight*_self.pixelRatio,
extra: {
column: {
meter:{
border:5
},
type: 'group',
width: 15 //_self.cWidth*_self.pixelRatio*0.45/chartData.categories.length
}
}
});
},
touchColumn(e) {
canvaColumn.showToolTip(e, {
format: function(item, category) {
if (typeof item.data === 'object') {
return category + ' ' + item.name + ':' + item.data.value
} else {
return category + ' ' + item.name + ':' + item.data
}
}
});
},
showLineA(canvasId, chartData, ctwidth, ctheight,type,max,min) {
let contentwidth = ctwidth - 20;
let contentheight = ctheight;
canvaLineA = new uCharts({
$this: _self,
padding:[20,10,0,15],
canvasId: canvasId,
type: 'line',
colors:['#15affb','#9292e3','#00cd9a','#ffcc1f','#e0c79a','#bfe048'],
fontSize: 8,
dataPointShape:false,
legend: {
show:true,
fontColor:'#666',
},
dataLabel: true,
dataPointShape: true,
background: '#FFFFFF',
pixelRatio: _self.pixelRatio,
categories: chartData.categories,
series: chartData.series,
animation: true,
xAxis: {
rotateLabel:true,
disableGrid:true,
type: 'grid',
gridColor: '#CCCCCC',
gridType: 'dash',
dashLength: 8
},
yAxis: {
disableGrid:true,
gridType: 'dash',
gridColor: '#CCCCCC',
dashLength: 8,
splitNumber: 3,
min: min,
max: max,
format: (val) => {
return val.toFixed(0)
}
},
width: contentwidth,
height: contentheight,
extra: {
line: {
type: type
}
}
});
},
touchLineA(e) {
canvaLineA.showToolTip(e, {
format: function(item, category) {
return category + ' ' + item.name + ':' + item.data
}
});
},
showRing(canvasId, chartData, ctwidth, ctheight) {
let contentwidth = ctwidth - 20;
let contentheight = ctheight;
canvaRing = new uCharts({
$this: _self,
padding:[10,0,5,10],
canvasId: canvasId,
type: 'ring',
fontSize: 11,
legend: {
padding:0,
fontSize:8,
itemGap:0,
margin:5,
show:true,
fontColor:'#666'
},
colors: ['#b5b0e3','#8d5ae3','#3745bf','#c27fbc','#2a9cff','#6de0c3','#87c1d2','#9e7bc1','#b6dd99','#b9c68c','#a34f94','#1c0066'],
title: {
name: '',
color: '#7cb5ec',
fontSize: 10 * _self.pixelRatio,
offsetY: -20 * _self.pixelRatio,
},
subtitle: {
name: '',
color: '#666666',
fontSize: 15 * _self.pixelRatio,
offsetY: 30 * _self.pixelRatio,
},
extra: {
pie: {
offsetAngle: -25,
ringWidth: 10 * _self.pixelRatio,
labelWidth: 2,
ringWidth:20,
}
},
background: '#fff',
pixelRatio: _self.pixelRatio,
series: chartData.series,
animation: true,
width: contentwidth,
height: contentheight,
disablePieStroke: true,
dataLabel: true,
});
},
touchRing(e) {
canvaRing.showToolTip(e, {
format: function(item) {
return item.name + ':' + item.data
}
});
},
showPie(canvasId, chartData, ctwidth, ctheight) {
let contentwidth = ctwidth - 20;
let contentheight = ctheight;
canvaPie = new uCharts({
$this: _self,
padding:[30,15,0,15],
canvasId: canvasId,
type: 'pie',
fontSize: 11,
legend: {
show: true,
fontColor:'#666',
fontSize:8,
},
colors: ['#b5b0e3','#8d5ae3','#3745bf','#c27fbc','#2a9cff','#6de0c3','#87c1d2','#9e7bc1','#b6dd99','#b9c68c','#a34f94','#1c0066'],
background: '#FFFFFF',
pixelRatio: _self.pixelRatio,
series: chartData.series,
animation: true,
width: contentwidth,
height: contentheight,
dataLabel: true,
extra: {
pie: {
labelWidth: 2,
}
}
});
},
touchPie(e) {
canvaPie.showToolTip(e, {
format: function(item) {
return item.name + ':' + item.data
}
});
},
showArcbar(canvasId, chartData, ctwidth, ctheight) {
let contentwidth = ctwidth ;
let contentheight = ctheight;
canvaArcbar1 = new uCharts({
padding:[10,0,5,10],
$this: _self,
canvasId: canvasId,
type: 'arcbar',
fontSize: 8,
legend: {
show: false,
fontColor:'#666',
},
background: '#FFFFFF',
pixelRatio: _self.pixelRatio,
series: chartData.series,
animation: true,
width: contentwidth,
height: contentheight,
dataLabel: true,
title: {
name: Math.round(chartData.series[0].data * 100) + '%', //这里我自动计算了,您可以直接给任意字符串
color: '#3390fb',
fontSize: 30 * _self.pixelRatio
},
subtitle: {
name: chartData.series[0].name, //这里您可以直接给任意字符串
color: '#666666',
fontSize: 15 * _self.pixelRatio
},
extra: {
arcbar: {
radius: contentheight / 3,
type: 'circle',
backgroundColor:'#dde8fe',
width: _self.arcbarWidth * _self.pixelRatio, //圆弧的宽度
}
}
});
},
showGauge(canvasId, chartData, ctwidth, ctheight,title, minimum, maximum) {
let contentwidth = ctwidth;
let contentheight = ctheight;
canvaGauge = new uCharts({
padding:[20,15,0,15],
$this: _self,
canvasId: canvasId,
type: 'gauge',
fontSize: 12,
legend: false,
title: {
name: title,
color: '#666',
fontSize: 24 * _self.pixelRatio,
offsetY: 45 * _self.pixelRatio, //新增参数,自定义调整Y轴文案距离
},
subtitle: {
name: chartData.series[0].name,
color: '#666',
fontSize: 24 * _self.pixelRatio,
offsetY: 45 * _self.pixelRatio, //新增参数,自定义调整Y轴文案距离
},
extra: {
gauge: {
labelColor:'#666',
type: 'default',
width: _self.gaugeWidth * _self.pixelRatio, //仪表盘背景的宽度
startAngle: 0.75,
endAngle: 0.25,
startNumber: minimum,
endNumber: maximum,
splitLine: {
fixRadius: -5,
splitNumber: 10,
width: _self.gaugeWidth * _self.pixelRatio, //仪表盘背景的宽度
color: '#fff',
childNumber: 5,
childWidth: _self.gaugeWidth * 0.3 * _self.pixelRatio, //仪表盘背景的宽度
},
pointer: {
width: _self.gaugeWidth * 0.8 * _self.pixelRatio, //指针宽度
length:'-50%',
color: 'auto'
},
labelFormat: (val) => {
return val.toFixed(0)
}
}
},
background: '#FFFFFF',
pixelRatio: _self.pixelRatio,
categories: chartData.categories,
series: chartData.series,
animation: true,
width: contentwidth,
height: contentheight,
dataLabel: true,
});
},
showArea(canvasId, chartData, ctwidth, ctheight) {
let contentwidth = ctwidth;
let contentheight = ctheight;
canvaArea = new uCharts({
$this: _self,
padding:[30,15,0,15],
canvasId: canvasId,
type: 'area',
fontSize: 8,
legend: {
show:true,
fontColor:'#666',
},
dataLabel: true,
dataPointShape: true,
background: '#FFFFFF',
pixelRatio: _self.pixelRatio,
categories: chartData.categories,
series: chartData.series,
animation: true,
xAxis: {
rotateLabel:true,
disableGrid:true
},
yAxis: {
splitNumber: 3,
disableGrid:true,
format: (val) => {
return val.toFixed(0)
}
},
width: contentwidth,
height: contentheight,
extra: {
area: {
type: 'straight',
opacity: 0.2,
addLine: true,
width: 2
}
}
});
},
touchArea(e) {
canvaArea.showToolTip(e, {
format: function(item, category) {
return category + ' ' + item.name + ':' + item.data
}
});
},
// 温度
showColumnMeter(canvasId,chartData, ctwidth, ctheight){
let contentwidth = ctwidth;
let contentheight = 100;
canvaColumn=new uCharts({
padding:[10,15,0,0],
$this:_self,
canvasId: canvasId,
type: 'column',
legend:{show:false},
fontSize:8,
background:'#FFFFFF',
pixelRatio:_self.pixelRatio,
animation: true,
rotate:true,
categories: chartData.categories,
series: chartData.series,
xAxis: {
rotateLabel:true,
disableGrid:true,
disabled:true
},
yAxis: {
disableGrid:true,
disabled:true
},
dataLabel: true,
width: contentwidth,
height: contentheight,
extra: {
column: {
type:'meter',
width: _self.cWidth*_self.pixelRatio*0.45/chartData.categories.length,
meter:{
//这个是外层边框的宽度
border:4,
//这个是内部填充颜色
fillColor:'#E5FDC3'
}
}
}
});
},
// 推叠柱状图
showColumnStack(canvasId,chartData, ctwidth, ctheight){
let contentwidth = ctwidth;
let contentheight = ctheight;
canvaColumn=new uCharts({
$this:_self,
padding:[15,15,0,15],
colors:['#15affb','#00cd9a','#9292e3','#ffcc1f','#e0c79a','#bfe048'],
canvasId: canvasId,
type: 'column',
legend: {
fontColor:'#666',
margin:0,
show: true
},
fontSize:11,
background:'#FFFFFF',
pixelRatio:_self.pixelRatio,
animation: true,
// rotate:true,
categories: chartData.categories,
series: chartData.series,
xAxis: {
disableGrid:true,
// disabled:true
},
yAxis: {
disableGrid:true,
// disabled:true
splitNumber:3,
format: (val) => {
return val.toFixed(0)
}
},
dataLabel: true,
width: contentwidth,
height: contentheight,
extra: {
column: {
type:'stack',
width: _self.cWidth*_self.pixelRatio*0.5/chartData.categories.length
}
}
});
},
showPoint(canvasId, chartData, ctwidth, ctheight) {
let contentwidth = ctwidth;
let contentheight = ctheight;
canvaPoint = new uCharts({
$this: _self,
padding:[30,15,0,15],
canvasId: canvasId,
type: 'mix',
fontSize: 8,
legend: {
show: true,
fontColor:'#666',
},
background: '#FFFFFF',
pixelRatio: _self.pixelRatio,
categories: chartData.categories,
series: chartData.series,
animation: true,
enableScroll: false, //开启图表拖拽功能
xAxis: {
rotateLabel:true,
disableGrid: true,
type: 'grid',
gridType: 'dash',
scrollShow: false,
scrollAlign: 'left',
},
yAxis: {
disableGrid: true,
gridType: 'dash',
splitNumber: 3,
// min: 10,
// max: 180,
format: (val) => {
return val.toFixed(0)
}
},
width: contentwidth,
height: contentheight,
dataLabel: true,
dataPointShape: true,
extra: {
tooltip: {
bgColor: '#000000',
bgOpacity: 0.7,
gridType: 'dash',
dashLength: 8,
gridColor: '#1890ff',
fontColor: '#FFFFFF',
horizentalLine: true,
xAxisLabel: true,
yAxisLabel: true,
labelBgColor: '#DFE8FF',
labelBgOpacity: 0.95,
labelAlign: 'left',
labelFontColor: '#666666'
}
},
});
}
}
}
</script>
<style lang='less' scoped>
uni-page-body{
box-sizing: border-box;
background: #f7f8fa;
}
.status_bar {
position: fixed;
top: 0;
z-index: 9999;
height: var(--status-bar-height);
width: 100%;
background: linear-gradient(to right,#4b8fdf,#7c86d0);
}
.body{
margin-top: var(--status-bar-height);
}
.kb_header{
position: relative;
width: 100%;
height: 30px;
box-sizing: border-box;
background: linear-gradient(to right,#4b8fdf,#7c86d0);
overflow: hidden;
.title{
color: #fff;
font-size: 20px;
font-weight: 700;
display: flex;
align-items: center;
justify-content: center;
height: 100%;
}
/* .datetime{
font-size: 14rpx;
text-align: right;
position: absolute;
top: 8%;
right: 14%;
} */
.subtitle{
color: #fff;
font-size: 14px;
text-align: center;
position: absolute;
top: 20%;
left: 4%;
}
}
.kb_body{
background-color: #f7f8fa;
padding: 0.4rem 0.9rem;
box-sizing: border-box;
.chart_mian{
border-radius: 5px;
overflow: hidden;
box-sizing: border-box;
width: 100%;
height: 36vh;
margin-bottom: 30rpx;
background-color: #fff;
box-shadow: 0 6px 10px #d9d9d9;
div{
width: 100%;
height: 100%;
}
}
.chart_lanscape{
border-radius: 5px;
overflow: hidden;
box-sizing: border-box;
width: 100%;
height: 82vh;
margin-bottom: 30rpx;
background-color: #fff;
box-shadow: 0 6px 10px #d9d9d9;
div{
width: 100%;
height: 100%;
}
}
.chart_small{
border-radius: 5px;
overflow: hidden;
box-sizing: border-box;
width: 100%;
height: 24vh;
margin-bottom: 22rpx;
background-color: #fff;
box-shadow: 0 6px 10px #d9d9d9;
div{
width: 100%;
height: 100%;
}
}
.chart_landscape_small{
border-radius: 5px;
overflow: hidden;
box-sizing: border-box;
width: 100%;
height: 44vh;
margin-bottom: 22rpx;
background-color: #fff;
box-shadow: 0 6px 10px #d9d9d9;
div{
width: 100%;
height: 100%;
}
}
}
.chart_item {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
}
.chart_list {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
}
/* 标题文字 */
.qiun-title-dot-light {
height: 36px;
line-height: 36px;
display: flex;
flex-direction: row;
padding-left: 10upx;
font-size: 15px;
text-align: left;
color: #fff;
/* font-weight: 600px; */
background:linear-gradient(to right,#4b8fdf,#7c86d0);
.icon{
height: 100%;
box-sizing: border-box;
margin-right:5px ;
width: 18px;
background:url(../../../static/img/titleicon.png) center no-repeat;
background-size: 50%;
}
}
.chart_bottom{
height: 40px;
box-sizing: border-box;
flex: 1;
}
.diy_box{
display: flex;
align-items: center;
justify-content: center;
}
.diy{
color: #0d68ff;
font-size: 40px;
}
/* label样式 */
.kb_label{
width: 100%;
height: 100%;
display: flex;
flex-direction:row;
justify-content: center;
align-items: center;
flex-wrap: no-wrap;
box-sizing: border-box;
.label_item {
/* display: flex;
flex-direction: column;
justify-content: center;
align-items: center; */
padding: 30rpx;
margin-right: 20rpx;
box-sizing: border-box;
text-align: center;
}
.label_item:nth-last-child{
margin-right: 0rpx;
box-sizing: border-box;
}
}
/* label数量 */
.label_count{
font-size: 1.8rem;
/* display: flex;
flex-direction: row;
justify-content: space-around;
align-items: center; */
color: #fff;
font-weight: 800;
line-height: 1.5;
box-sizing: border-box;
margin: 40rpx 0;
.uni-label-pointer{
padding: 25rpx 12rpx;
box-sizing: border-box;
background-color: #369cff;
margin-right: 10rpx;
text-align: center;
}
/* 已完成 */
.label_done{
background-color: #1fe0ca;
}
/* 百分比 */
.percent{
padding:25rpx 7rpx ;
box-sizing: border-box;
background-color: #369cff;
text-align: center;
}
}
/* label标题 */
.label_title{
display: inline-block;
text-align: center;
height: 40rpx;
width: 100%;
font-size: 16px;
color: #666;
padding-right: 25rpx;
box-sizing: border-box;
}
/* 进度条 */
.kb_process{
height: 100%;
display: flex;
align-items: center;
padding: 0 20rpx;
box-sizing: border-box;
/* 上标题 */
.process_title{
width: 20%;
margin-right: 5rpx;
font-size: 32rpx;
color: #666;
text-align: center;
}
}
/* 列表 */
/* .table_content{
padding: 10rpx 10rpx 0 10rpx;
box-sizing: border-box;
} */
.tab-tr:nth-child(odd) {
background-color: #FFFFFF;
color: #555555;
}
/* 柱状图 */
.kb_column{
width: 100%;
height:100%;
}
</style>