| | |
| | | <ChartTitle name="车间正品率"></ChartTitle> |
| | | <div class="bar-contents"> |
| | | <div class="bar-total"> |
| | | <div class="bar-item"> |
| | | 当日合计生产:{{ chartData.total }} |
| | | </div> |
| | | <div class="bar-item"> |
| | | 正品率:{{ chartData.rate }} |
| | | </div> |
| | | <div class="bar-item">当日合计生产:{{ chartData.total }}</div> |
| | | <div class="bar-item">正品率:{{ chartData.rate }}</div> |
| | | </div> |
| | | <div class="chart" ref="chart"></div> |
| | | </div> |
| | |
| | | <script> |
| | | import ChartTitle from "@/views/cockpitPage/components/ChartTitle.vue"; |
| | | //引入echart |
| | | import * as echarts from 'echarts' |
| | | import * as echarts from "echarts"; |
| | | export default { |
| | | components: { |
| | | ChartTitle, |
| | |
| | | props: {}, |
| | | data() { |
| | | return { |
| | | chartData:{ |
| | | total:1000, |
| | | rate:'99%', |
| | | datax:['第一车间', '第二车间', '第三车间', '第四车间','第五车间','第六车间',], |
| | | datay:[120, 200, 150, 180, 170, 150, 130,180, 140], |
| | | datay2:[20, 30, 50, 40, 70, 50, 30,80,40], |
| | | } |
| | | chartData: { |
| | | total: 1000, |
| | | rate: "99%", |
| | | datax: [ |
| | | "第一车间", |
| | | "第二车间", |
| | | "第三车间", |
| | | "第四车间", |
| | | "第五车间", |
| | | "第六车间", |
| | | "第七车间", |
| | | "第八车间", |
| | | "第九车间", |
| | | ], |
| | | datay: [120, 200, 150, 180, 170, 150, 130, 180, 140], |
| | | datay2: [20, 30, 50, 40, 70, 50, 30, 80, 40], |
| | | }, |
| | | }; |
| | | }, |
| | | mounted() { |
| | | this.pieChart('chart',this.chartData) |
| | | this.pieChart("chart", this.chartData); |
| | | }, |
| | | watch: {}, |
| | | methods: { |
| | | //在职 |
| | | pieChart(chartName,data){ |
| | | let chartDom = this.$refs[chartName] |
| | | let myChart = echarts.init(chartDom); |
| | | let option; |
| | | let lineColor='#35ddc74d' |
| | | if(data){ |
| | | option = { |
| | | color:['#dcb018','#00FFFF'], |
| | | tooltip: { |
| | | trigger: 'axis', |
| | | axisPointer: { |
| | | type: 'none' |
| | | }, |
| | | textStyle:{ |
| | | color:'#00FFFF', |
| | | }, |
| | | borderColor:'#00FFFF', |
| | | backgroundColor:'#238d8d6b', |
| | | formatter:function(a){ |
| | | let list=[] |
| | | let listItem='' |
| | | let firstString='<span style=width:70px;display:inline-block">'+ |
| | | '生产总数'+ |
| | | '</span> '+ |
| | | data.total |
| | | list.push(firstString) |
| | | for(let i in a){ |
| | | let str='<span style=width:70px;display:inline-block">'+ |
| | | a[i].seriesName+ |
| | | '</span> '+ |
| | | a[i].value |
| | | |
| | | list.push(str) |
| | | } |
| | | let lastString='<span style=width:70px;display:inline-block">'+ |
| | | '正品率'+ |
| | | '</span> '+ |
| | | data.rate |
| | | list.push(lastString) |
| | | listItem=list.join('<br>') |
| | | return '<div class="showBox">'+listItem+'</div>' |
| | | } |
| | | }, |
| | | grid: { |
| | | right: "10px", |
| | | bottom:'60px', |
| | | left:'10px', |
| | | top:'10px', |
| | | }, |
| | | dataZoom: [ |
| | | { |
| | | type: 'inside', |
| | | // show: true, //显示滚动条 |
| | | start:0, |
| | | end: 100, |
| | | xAxisIndex: 0, |
| | | minSpan:20, |
| | | maxSpan:100, |
| | | // handleSize: 8 |
| | | }, |
| | | { |
| | | // type: 'slider', //两个一个是slider,一个是inside,slider是增加滚动条以及鼠标拖动滚动条功能,inside则是鼠标滚轮滚动滚动条。 |
| | | type: 'inside', |
| | | // show: true, |
| | | // realtime : true, |
| | | xAxisIndex: 0, |
| | | minSpan:20, |
| | | maxSpan:100, |
| | | start: 0, |
| | | end: 100 |
| | | }, |
| | | ], |
| | | legend: { |
| | | itemWidth: 8, |
| | | itemHeight: 8, |
| | | itemGap: 35,//间距 |
| | | bottom:'5px', |
| | | left:'center', |
| | | data:[ |
| | | { |
| | | name:'正品数量', |
| | | icon:'circle', |
| | | textStyle:{ |
| | | color:'#dcb018' |
| | | } |
| | | }, |
| | | { |
| | | name:'次品数量', |
| | | icon:'circle', |
| | | textStyle:{ |
| | | color:'#00FFFF' |
| | | } |
| | | }, |
| | | ], |
| | | }, |
| | | xAxis: [ |
| | | { |
| | | type: 'category', |
| | | axisTick: { |
| | | show: false |
| | | }, |
| | | axisLine: { |
| | | show: true, |
| | | lineStyle: { |
| | | color:lineColor, |
| | | } |
| | | }, |
| | | axisLabel:{ |
| | | // rotate:45, |
| | | margin: 10, |
| | | show: true, |
| | | textStyle: { |
| | | color: '#00FFFF' |
| | | }, |
| | | }, |
| | | data: data.datax?data.datax:[], |
| | | } |
| | | ], |
| | | yAxis: [ |
| | | { |
| | | type: '', |
| | | name: '', |
| | | // min: data.yAxis[0].min?data.yAxis.min:0, |
| | | minInterval: 1,//坐标轴是整数 |
| | | max:Math.ceil(eval(`Math.max(${data.datay})`)/5)*5,//数据最大值加3 |
| | | interval: Math.ceil(eval( `Math.max(${data.datay})`)/5)*5 / 5, |
| | | position: 'left', |
| | | axisLine: { |
| | | show: true, |
| | | lineStyle: { |
| | | color:lineColor, |
| | | } |
| | | }, |
| | | nameTextStyle:{ |
| | | color:"#00FFFF", |
| | | }, |
| | | splitLine: { |
| | | show: true, |
| | | lineStyle: { |
| | | // 使用深浅的间隔色 |
| | | color: lineColor, |
| | | } |
| | | }, |
| | | axisTick: { |
| | | show: false |
| | | }, |
| | | axisLabel: { |
| | | textStyle: { |
| | | color: '#9B9B9B' |
| | | }, |
| | | formatter: '' |
| | | } |
| | | }, |
| | | { |
| | | type: '', |
| | | name: '', |
| | | // min: data.yAxis[0].min?data.yAxis.min:0, |
| | | minInterval: 1,//坐标轴是整数 |
| | | max:Math.ceil(eval(`Math.max(${data.datay2})`)/5)*5,//数据最大值加3 |
| | | interval: Math.ceil(eval( `Math.max(${data.datay2})`)/5)*5 / 5, |
| | | position: 'right', |
| | | axisLine: { |
| | | show: true, |
| | | lineStyle: { |
| | | color:lineColor, |
| | | } |
| | | }, |
| | | nameTextStyle:{ |
| | | color:"#00FFFF", |
| | | }, |
| | | splitLine: { |
| | | show: true, |
| | | lineStyle: { |
| | | // 使用深浅的间隔色 |
| | | color:lineColor, |
| | | } |
| | | }, |
| | | axisTick: { |
| | | show: false |
| | | }, |
| | | axisLabel: { |
| | | textStyle: { |
| | | color: '#9B9B9B' |
| | | }, |
| | | formatter: '' |
| | | } |
| | | } |
| | | ], |
| | | series:[ |
| | | { |
| | | type: 'bar', |
| | | name: '正品数量', |
| | | barWidth: '15', |
| | | itemStyle: { |
| | | normal: { |
| | | //柱形图圆角,初始化效果 |
| | | barBorderRadius:[4, 4, 0, 0], |
| | | } |
| | | }, |
| | | data: data.datay, |
| | | }, |
| | | { |
| | | type: 'bar', |
| | | name: '次品数量', |
| | | barWidth: '15', |
| | | itemStyle: { |
| | | normal: { |
| | | //柱形图圆角,初始化效果 |
| | | barBorderRadius:[4, 4, 0, 0], |
| | | } |
| | | }, |
| | | data: data.datay2, |
| | | } |
| | | ] |
| | | }; |
| | | pieChart(chartName, data) { |
| | | let that = this; |
| | | let chartDom = this.$refs[chartName]; |
| | | let myChart = echarts.init(chartDom); |
| | | let option; |
| | | let lineColor = "#35ddc74d"; |
| | | if (data) { |
| | | option = { |
| | | color: ["#dcb018", "#00FFFF"], |
| | | tooltip: { |
| | | trigger: "axis", |
| | | axisPointer: { |
| | | type: "none", |
| | | }, |
| | | textStyle: { |
| | | color: "#00FFFF", |
| | | }, |
| | | borderColor: "#00FFFF", |
| | | backgroundColor: "#238d8d6b", |
| | | formatter: function (a) { |
| | | let list = []; |
| | | let listItem = ""; |
| | | let firstString = |
| | | '<span style=width:70px;display:inline-block">' + |
| | | "生产总数" + |
| | | "</span> " + |
| | | data.total; |
| | | list.push(firstString); |
| | | for (let i in a) { |
| | | let str = |
| | | '<span style=width:70px;display:inline-block">' + |
| | | a[i].seriesName + |
| | | "</span> " + |
| | | a[i].value; |
| | | |
| | | option && myChart.setOption(option); |
| | | }else{ |
| | | option={}; |
| | | myChart.setOption(option,true); |
| | | list.push(str); |
| | | } |
| | | let lastString = |
| | | '<span style=width:70px;display:inline-block">' + |
| | | "正品率" + |
| | | "</span> " + |
| | | data.rate; |
| | | list.push(lastString); |
| | | listItem = list.join("<br>"); |
| | | return '<div class="showBox">' + listItem + "</div>"; |
| | | }, |
| | | }, |
| | | grid: { |
| | | right: "10px", |
| | | bottom: "60px", |
| | | left: "10px", |
| | | top: "10px", |
| | | }, |
| | | dataZoom: [ |
| | | { |
| | | type: "inside", |
| | | xAxisIndex: 0, |
| | | show: false, |
| | | startValue: 0, // 从头开始 |
| | | endValue: 5, // 一次性展示几个 |
| | | }, |
| | | ], |
| | | legend: { |
| | | itemWidth: 8, |
| | | itemHeight: 8, |
| | | itemGap: 35, //间距 |
| | | bottom: "5px", |
| | | left: "center", |
| | | data: [ |
| | | { |
| | | name: "正品数量", |
| | | icon: "circle", |
| | | textStyle: { |
| | | color: "#dcb018", |
| | | }, |
| | | }, |
| | | { |
| | | name: "次品数量", |
| | | icon: "circle", |
| | | textStyle: { |
| | | color: "#00FFFF", |
| | | }, |
| | | }, |
| | | ], |
| | | }, |
| | | xAxis: [ |
| | | { |
| | | type: "category", |
| | | axisTick: { |
| | | show: false, |
| | | }, |
| | | axisLine: { |
| | | show: true, |
| | | lineStyle: { |
| | | color: lineColor, |
| | | }, |
| | | }, |
| | | axisLabel: { |
| | | // rotate:45, |
| | | margin: 10, |
| | | show: true, |
| | | textStyle: { |
| | | color: "#00FFFF", |
| | | }, |
| | | }, |
| | | data: data.datax ? data.datax : [], |
| | | }, |
| | | ], |
| | | yAxis: [ |
| | | { |
| | | type: "value", |
| | | name: "", |
| | | // min: data.yAxis[0].min?data.yAxis.min:0, |
| | | minInterval: 1, //坐标轴是整数 |
| | | max: Math.ceil(eval(`Math.max(${data.datay})`) / 5) * 5, //数据最大值加3 |
| | | interval: |
| | | (Math.ceil(eval(`Math.max(${data.datay})`) / 5) * 5) / 5, |
| | | position: "left", |
| | | axisLine: { |
| | | show: true, |
| | | lineStyle: { |
| | | color: lineColor, |
| | | }, |
| | | }, |
| | | nameTextStyle: { |
| | | color: "#00FFFF", |
| | | }, |
| | | splitLine: { |
| | | show: true, |
| | | lineStyle: { |
| | | // 使用深浅的间隔色 |
| | | color: lineColor, |
| | | }, |
| | | }, |
| | | axisTick: { |
| | | show: false, |
| | | }, |
| | | axisLabel: { |
| | | textStyle: { |
| | | color: "#9B9B9B", |
| | | }, |
| | | formatter: "", |
| | | }, |
| | | }, |
| | | { |
| | | type: "value", |
| | | name: "", |
| | | // min: data.yAxis[0].min?data.yAxis.min:0, |
| | | minInterval: 1, //坐标轴是整数 |
| | | max: Math.ceil(eval(`Math.max(${data.datay2})`) / 5) * 5, //数据最大值加3 |
| | | interval: |
| | | (Math.ceil(eval(`Math.max(${data.datay2})`) / 5) * 5) / 5, |
| | | position: "right", |
| | | axisLine: { |
| | | show: true, |
| | | lineStyle: { |
| | | color: lineColor, |
| | | }, |
| | | }, |
| | | nameTextStyle: { |
| | | color: "#00FFFF", |
| | | }, |
| | | splitLine: { |
| | | show: true, |
| | | lineStyle: { |
| | | // 使用深浅的间隔色 |
| | | color: lineColor, |
| | | }, |
| | | }, |
| | | axisTick: { |
| | | show: false, |
| | | }, |
| | | axisLabel: { |
| | | textStyle: { |
| | | color: "#9B9B9B", |
| | | }, |
| | | formatter: "", |
| | | }, |
| | | }, |
| | | ], |
| | | series: [ |
| | | { |
| | | type: "bar", |
| | | name: "正品数量", |
| | | barWidth: "15", |
| | | itemStyle: { |
| | | normal: { |
| | | //柱形图圆角,初始化效果 |
| | | barBorderRadius: [4, 4, 0, 0], |
| | | }, |
| | | }, |
| | | data: data.datay, |
| | | }, |
| | | { |
| | | type: "bar", |
| | | name: "次品数量", |
| | | barWidth: "15", |
| | | itemStyle: { |
| | | normal: { |
| | | //柱形图圆角,初始化效果 |
| | | barBorderRadius: [4, 4, 0, 0], |
| | | }, |
| | | }, |
| | | data: data.datay2, |
| | | }, |
| | | ], |
| | | }; |
| | | setInterval(function () { |
| | | // 每次向左滑动一个,最后一个从头开始。 |
| | | if (option.dataZoom[0].endValue == that.chartData.datay.length) { |
| | | option.dataZoom[0].startValue = 0; |
| | | option.dataZoom[0].endValue = 5; |
| | | } else { |
| | | option.dataZoom[0].endValue = option.dataZoom[0].endValue + 1; |
| | | option.dataZoom[0].startValue = option.dataZoom[0].startValue + 1; |
| | | } |
| | | }, |
| | | myChart.setOption(option); |
| | | }, 3000); |
| | | |
| | | option && myChart.setOption(option); |
| | | window.addEventListener("resize", function () { |
| | | myChart.resize(); |
| | | }); |
| | | } else { |
| | | option = {}; |
| | | myChart.setOption(option, true); |
| | | } |
| | | }, |
| | | }, |
| | | }; |
| | | </script> |
| | | |
| | | <style scoped lang="scss"> |
| | | .bar-chart{ |
| | | width:100%; |
| | | height:calc(100% - 20px); |
| | | padding:20px 0 0; |
| | | .bar-contents{ |
| | | width:100%; |
| | | height:calc(100% - 60px); |
| | | border:1px solid #00FFFF; |
| | | .bar-chart { |
| | | width: 100%; |
| | | height: calc(100% - 20px); |
| | | padding: 20px 0 0; |
| | | .bar-contents { |
| | | width: 100%; |
| | | height: calc(100% - 60px); |
| | | border: 1px solid #00ffff; |
| | | box-sizing: border-box; |
| | | .bar-total{ |
| | | width:100%; |
| | | height:30px; |
| | | line-height:30px; |
| | | color:#dcb018; |
| | | font-size:14px; |
| | | margin-top:10px; |
| | | .bar-item{ |
| | | width:50%; |
| | | text-align:center; |
| | | float:left; |
| | | .bar-total { |
| | | width: 100%; |
| | | height: 30px; |
| | | line-height: 30px; |
| | | color: #dcb018; |
| | | font-size: 14px; |
| | | margin-top: 10px; |
| | | .bar-item { |
| | | width: 50%; |
| | | text-align: center; |
| | | float: left; |
| | | } |
| | | } |
| | | .chart{ |
| | | width: 100%; |
| | | height:calc(100% - 40px); |
| | | } |
| | | .chart { |
| | | width: 100%; |
| | | height: calc(100% - 40px); |
| | | } |
| | | } |
| | | } |
| | | </style> |
| | |
| | | |
| | | <script> |
| | | //引入echart |
| | | import * as echarts from 'echarts' |
| | | import * as echarts from "echarts"; |
| | | export default { |
| | | components: { |
| | | }, |
| | | components: {}, |
| | | props: {}, |
| | | data() { |
| | | return { |
| | | chartData: { |
| | | datax: ['设备1', '设备2', '设备3', '设备4', '设备5', '设备6'], |
| | | datay: [10, 20, 15, 38, 47, 50, 20], |
| | | } |
| | | datax: [ |
| | | "设备1", |
| | | "设备2", |
| | | "设备3", |
| | | "设备4", |
| | | "设备5", |
| | | "设备6", |
| | | "设备7", |
| | | "设备8", |
| | | "设备9", |
| | | ], |
| | | datay: [10, 20, 15, 38, 47, 50, 20, 33, 25, 48], |
| | | }, |
| | | }; |
| | | }, |
| | | mounted() { |
| | | this.pieChart('chart', this.chartData) |
| | | this.pieChart("chart", this.chartData); |
| | | }, |
| | | watch: {}, |
| | | methods: { |
| | | //在职 |
| | | pieChart(chartName, data) { |
| | | let chartDom = this.$refs[chartName] |
| | | let that = this; |
| | | let chartDom = this.$refs[chartName]; |
| | | let myChart = echarts.init(chartDom); |
| | | let option; |
| | | let lineColor = '#35ddc74d' |
| | | let lineColor = "#35ddc74d"; |
| | | if (data) { |
| | | option = { |
| | | color: ['#00FFFF', '#dcb018'], |
| | | color: ["#00FFFF", "#dcb018"], |
| | | tooltip: { |
| | | trigger: 'axis', |
| | | trigger: "axis", |
| | | axisPointer: { |
| | | type: 'none' |
| | | type: "none", |
| | | }, |
| | | }, |
| | | grid: { |
| | | right: "80px", |
| | | bottom: '60px', |
| | | left: '60px', |
| | | top: '30px', |
| | | bottom: "60px", |
| | | left: "60px", |
| | | top: "30px", |
| | | }, |
| | | dataZoom: [ |
| | | { |
| | | type: 'inside', |
| | | // show: true, //显示滚动条 |
| | | start: 0, |
| | | end: 100, |
| | | type: "inside", |
| | | yAxisIndex: 0, |
| | | minSpan: 20, |
| | | maxSpan: 100, |
| | | // handleSize: 8 |
| | | }, |
| | | { |
| | | // type: 'slider', //两个一个是slider,一个是inside,slider是增加滚动条以及鼠标拖动滚动条功能,inside则是鼠标滚轮滚动滚动条。 |
| | | type: 'inside', |
| | | // show: true, |
| | | // realtime : true, |
| | | yAxisIndex: 0, |
| | | minSpan: 20, |
| | | maxSpan: 100, |
| | | start: 0, |
| | | end: 100 |
| | | show: false, |
| | | startValue: 0, // 从头开始 |
| | | endValue: 5, // 一次性展示几个 |
| | | }, |
| | | ], |
| | | legend: { |
| | | itemWidth: 8, |
| | | itemHeight: 8, |
| | | itemGap: 35,//间距 |
| | | bottom: '5px', |
| | | left: 'center', |
| | | itemGap: 35, //间距 |
| | | bottom: "5px", |
| | | left: "center", |
| | | }, |
| | | yAxis: [ |
| | | { |
| | | type: 'category', |
| | | type: "category", |
| | | axisTick: { |
| | | show: false |
| | | show: false, |
| | | }, |
| | | axisLine: { |
| | | show: true, |
| | | lineStyle: { |
| | | color: lineColor, |
| | | } |
| | | }, |
| | | }, |
| | | axisLabel: { |
| | | // rotate:45, |
| | |
| | | show: true, |
| | | textStyle: { |
| | | color: function (params, index) { |
| | | let colorList = ['#dcb018', '#00FFFF'] |
| | | let colorList = ["#dcb018", "#00FFFF"]; |
| | | if (index % 2 == 0) { |
| | | return colorList[0] |
| | | return colorList[0]; |
| | | } else { |
| | | return colorList[1] |
| | | return colorList[1]; |
| | | } |
| | | } |
| | | }, |
| | | }, |
| | | }, |
| | | data: data.datax ? data.datax : [], |
| | | } |
| | | }, |
| | | ], |
| | | xAxis: [ |
| | | { |
| | | type: '', |
| | | name: '', |
| | | type: "value", |
| | | name: "", |
| | | // min: data.yAxis[0].min?data.yAxis.min:0, |
| | | minInterval: 1,//坐标轴是整数 |
| | | max: Math.ceil(eval(`Math.max(${data.datay})`) / 5) * 5,//数据最大值加3 |
| | | interval: Math.ceil(eval(`Math.max(${data.datay})`) / 6) * 6 / 6, |
| | | position: 'left', |
| | | minInterval: 1, //坐标轴是整数 |
| | | max: Math.ceil(eval(`Math.max(${data.datay})`) / 5) * 5, //数据最大值加3 |
| | | interval: |
| | | (Math.ceil(eval(`Math.max(${data.datay})`) / 6) * 6) / 6, |
| | | position: "left", |
| | | axisLine: { |
| | | show: true, |
| | | lineStyle: { |
| | | color: '#0a112B', |
| | | } |
| | | color: "#0a112B", |
| | | }, |
| | | }, |
| | | nameTextStyle: { |
| | | color: "#00FFFF", |
| | |
| | | lineStyle: { |
| | | // 使用深浅的间隔色 |
| | | color: lineColor, |
| | | } |
| | | }, |
| | | }, |
| | | axisTick: { |
| | | show: false |
| | | show: false, |
| | | }, |
| | | |
| | | axisLabel: { |
| | | textStyle: { |
| | | color: '#00FFFF' |
| | | color: "#00FFFF", |
| | | }, |
| | | formatter: '{value}%' |
| | | } |
| | | formatter: "{value}%", |
| | | }, |
| | | }, |
| | | ], |
| | | series: [ |
| | | { |
| | | type: 'bar', |
| | | name: '', |
| | | barWidth: '15', |
| | | label:{ |
| | | show:true, |
| | | position:'right', |
| | | color: '#00FFFF' |
| | | type: "bar", |
| | | name: "", |
| | | barWidth: "15", |
| | | label: { |
| | | show: true, |
| | | position: "right", |
| | | color: "#00FFFF", |
| | | }, |
| | | itemStyle: { |
| | | normal: { |
| | | //柱形图圆角,初始化效果 |
| | | barBorderRadius: [4, 4, 0, 0], |
| | | color: function (params) { |
| | | let colorList = ['#dcb018', '#00FFFF'] |
| | | let colorList = ["#dcb018", "#00FFFF"]; |
| | | if (params.dataIndex % 2 == 0) { |
| | | return colorList[0] |
| | | return colorList[0]; |
| | | } else { |
| | | return colorList[1] |
| | | return colorList[1]; |
| | | } |
| | | } |
| | | }, |
| | | }, |
| | | }, |
| | | data: data.datay, |
| | | }, |
| | | ] |
| | | ], |
| | | }; |
| | | |
| | | setInterval(function () { |
| | | // 每次向左滑动一个,最后一个从头开始。 |
| | | if (option.dataZoom[0].endValue == that.chartData.datay.length) { |
| | | option.dataZoom[0].startValue = 0; |
| | | option.dataZoom[0].endValue = 5; |
| | | } else { |
| | | option.dataZoom[0].endValue = option.dataZoom[0].endValue + 1; |
| | | option.dataZoom[0].startValue = option.dataZoom[0].startValue + 1; |
| | | } |
| | | myChart.setOption(option); |
| | | }, 4000); |
| | | |
| | | option && myChart.setOption(option); |
| | | window.addEventListener("resize", function () { |
| | | myChart.resize(); |
| | | }); |
| | | } else { |
| | | option = {}; |
| | | myChart.setOption(option, true); |
| | |
| | | width: 100%; |
| | | height: calc(100% - 0px); |
| | | padding: 0px 0 0; |
| | | border: 1px solid #00FFFF; |
| | | border: 1px solid #00ffff; |
| | | box-sizing: border-box; |
| | | position: relative; |
| | | .top-view { |
| | | height:38px; |
| | | margin-top: -1px; |
| | | margin-left: -1px; |
| | | position: relative; |
| | | left:0; |
| | | top:0; |
| | | .top-title { |
| | | width: calc(100% - 10px); |
| | | margin: auto; |
| | | height:38px; |
| | | line-height:38px; |
| | | position:absolute; |
| | | top:0; |
| | | left:10px; |
| | | color: #01f7fd; |
| | | font-size: 14px; |
| | | font-family: "Arial Negreta", "Arial Normal", "Arial"; |
| | | font-weight: 700; |
| | | } |
| | | height: 38px; |
| | | margin-top: -1px; |
| | | margin-left: -1px; |
| | | position: relative; |
| | | left: 0; |
| | | top: 0; |
| | | .top-title { |
| | | width: calc(100% - 10px); |
| | | margin: auto; |
| | | height: 38px; |
| | | line-height: 38px; |
| | | position: absolute; |
| | | top: 0; |
| | | left: 10px; |
| | | color: #01f7fd; |
| | | font-size: 14px; |
| | | font-family: "Arial Negreta", "Arial Normal", "Arial"; |
| | | font-weight: 700; |
| | | } |
| | | } |
| | | .bar-contents { |
| | | width: 100%; |
| | | height: calc(100% - 40px); |
| | |
| | | <script> |
| | | import ChartTitle from "@/views/cockpitPage/components/ChartTitle.vue"; |
| | | //引入echart |
| | | import * as echarts from 'echarts' |
| | | import * as echarts from "echarts"; |
| | | export default { |
| | | components: { |
| | | ChartTitle, |
| | |
| | | props: {}, |
| | | data() { |
| | | return { |
| | | chartData:{ |
| | | datax:['产品1', '产品2', '产品3', '产品4','产品5', '产品6'], |
| | | datay:[120, 200, 150, 380, 470, 150, 230], |
| | | } |
| | | chartData: { |
| | | datax: [ |
| | | "产品1", |
| | | "产品2", |
| | | "产品3", |
| | | "产品4", |
| | | "产品5", |
| | | "产品6", |
| | | "产品7", |
| | | "产品8", |
| | | "产品9", |
| | | "产品10", |
| | | ], |
| | | datay: [120, 200, 150, 380, 470, 150, 230, 130, 210, 145, 330], |
| | | }, |
| | | }; |
| | | }, |
| | | mounted() { |
| | | this.pieChart('chart',this.chartData) |
| | | this.pieChart("chart", this.chartData); |
| | | }, |
| | | watch: {}, |
| | | methods: { |
| | | //在职 |
| | | pieChart(chartName,data){ |
| | | let chartDom = this.$refs[chartName] |
| | | let myChart = echarts.init(chartDom); |
| | | let option; |
| | | let lineColor='#35ddc74d' |
| | | if(data){ |
| | | option = { |
| | | color:['#00FFFF','#dcb018'], |
| | | tooltip: { |
| | | trigger: 'axis', |
| | | axisPointer: { |
| | | type: 'none' |
| | | pieChart(chartName, data) { |
| | | let that = this; |
| | | let chartDom = this.$refs[chartName]; |
| | | let myChart = echarts.init(chartDom); |
| | | let option; |
| | | let lineColor = "#35ddc74d"; |
| | | if (data) { |
| | | option = { |
| | | color: ["#00FFFF", "#dcb018"], |
| | | tooltip: { |
| | | trigger: "axis", |
| | | axisPointer: { |
| | | type: "none", |
| | | }, |
| | | }, |
| | | grid: { |
| | | right: "80px", |
| | | bottom: "60px", |
| | | left: "60px", |
| | | top: "30px", |
| | | }, |
| | | dataZoom: [ |
| | | { |
| | | type: "inside", |
| | | yAxisIndex: 0, |
| | | show: false, |
| | | startValue: 0, // 从头开始 |
| | | endValue: 5, // 一次性展示几个 |
| | | }, |
| | | ], |
| | | legend: { |
| | | itemWidth: 8, |
| | | itemHeight: 8, |
| | | itemGap: 35, //间距 |
| | | bottom: "5px", |
| | | left: "center", |
| | | }, |
| | | yAxis: [ |
| | | { |
| | | type: "category", |
| | | axisTick: { |
| | | show: false, |
| | | }, |
| | | axisLine: { |
| | | show: true, |
| | | lineStyle: { |
| | | color: lineColor, |
| | | }, |
| | | }, |
| | | grid: { |
| | | right: "80px", |
| | | bottom:'60px', |
| | | left:'60px', |
| | | top:'30px', |
| | | axisLabel: { |
| | | // rotate:45, |
| | | margin: 10, |
| | | show: true, |
| | | textStyle: { |
| | | color: function (params, index) { |
| | | let colorList = ["#dcb018", "#00FFFF"]; |
| | | if (index % 2 == 0) { |
| | | return colorList[0]; |
| | | } else { |
| | | return colorList[1]; |
| | | } |
| | | }, |
| | | }, |
| | | }, |
| | | dataZoom: [ |
| | | { |
| | | type: 'inside', |
| | | // show: true, //显示滚动条 |
| | | start:0, |
| | | end: 100, |
| | | yAxisIndex: 0, |
| | | minSpan:20, |
| | | maxSpan:100, |
| | | // handleSize: 8 |
| | | data: data.datax ? data.datax : [], |
| | | }, |
| | | ], |
| | | xAxis: [ |
| | | { |
| | | type: "value", |
| | | name: "单位:件", |
| | | // min: data.yAxis[0].min?data.yAxis.min:0, |
| | | minInterval: 1, //坐标轴是整数 |
| | | max: Math.ceil(eval(`Math.max(${data.datay})`) / 5) * 5, //数据最大值加3 |
| | | interval: |
| | | (Math.ceil(eval(`Math.max(${data.datay})`) / 7) * 7) / 7, |
| | | position: "left", |
| | | axisLine: { |
| | | show: true, |
| | | lineStyle: { |
| | | color: "#0a112B", |
| | | }, |
| | | { |
| | | // type: 'slider', //两个一个是slider,一个是inside,slider是增加滚动条以及鼠标拖动滚动条功能,inside则是鼠标滚轮滚动滚动条。 |
| | | type: 'inside', |
| | | // show: true, |
| | | // realtime : true, |
| | | yAxisIndex: 0, |
| | | minSpan:20, |
| | | maxSpan:100, |
| | | start: 0, |
| | | end: 100 |
| | | }, |
| | | ], |
| | | legend: { |
| | | itemWidth: 8, |
| | | itemHeight: 8, |
| | | itemGap: 35,//间距 |
| | | bottom:'5px', |
| | | left:'center', |
| | | }, |
| | | yAxis: [ |
| | | { |
| | | type: 'category', |
| | | axisTick: { |
| | | show: false |
| | | }, |
| | | axisLine: { |
| | | show: true, |
| | | lineStyle: { |
| | | color:lineColor, |
| | | } |
| | | }, |
| | | axisLabel:{ |
| | | // rotate:45, |
| | | margin: 10, |
| | | show: true, |
| | | textStyle: { |
| | | color:function(params,index){ |
| | | let colorList=['#dcb018','#00FFFF'] |
| | | if(index % 2 == 0){ |
| | | return colorList[0] |
| | | }else{ |
| | | return colorList[1] |
| | | } |
| | | } |
| | | }, |
| | | }, |
| | | data: data.datax?data.datax:[], |
| | | } |
| | | ], |
| | | xAxis: [ |
| | | { |
| | | type: '', |
| | | name: '单位:件', |
| | | // min: data.yAxis[0].min?data.yAxis.min:0, |
| | | minInterval: 1,//坐标轴是整数 |
| | | max:Math.ceil(eval(`Math.max(${data.datay})`)/5)*5,//数据最大值加3 |
| | | interval: Math.ceil(eval( `Math.max(${data.datay})`)/7)*7 / 7, |
| | | position: 'left', |
| | | axisLine: { |
| | | show: true, |
| | | lineStyle: { |
| | | color:'#0a112B', |
| | | } |
| | | }, |
| | | nameTextStyle:{ |
| | | color:"#00FFFF", |
| | | }, |
| | | splitLine: { |
| | | show: true, |
| | | lineStyle: { |
| | | // 使用深浅的间隔色 |
| | | color: lineColor, |
| | | } |
| | | }, |
| | | axisTick: { |
| | | show: false |
| | | }, |
| | | |
| | | axisLabel: { |
| | | textStyle: { |
| | | color: '#00FFFF' |
| | | }, |
| | | |
| | | } |
| | | nameTextStyle: { |
| | | color: "#00FFFF", |
| | | }, |
| | | splitLine: { |
| | | show: true, |
| | | lineStyle: { |
| | | // 使用深浅的间隔色 |
| | | color: lineColor, |
| | | }, |
| | | ], |
| | | series:[ |
| | | { |
| | | type: 'bar', |
| | | name: '', |
| | | barWidth: '15', |
| | | itemStyle: { |
| | | normal: { |
| | | //柱形图圆角,初始化效果 |
| | | barBorderRadius:[4, 4, 0, 0], |
| | | color:function(params){ |
| | | let colorList=['#dcb018','#00FFFF'] |
| | | if(params.dataIndex % 2 == 0){ |
| | | return colorList[0] |
| | | }else{ |
| | | return colorList[1] |
| | | } |
| | | } |
| | | }, |
| | | }, |
| | | data: data.datay, |
| | | }, |
| | | ] |
| | | }; |
| | | }, |
| | | axisTick: { |
| | | show: false, |
| | | }, |
| | | |
| | | option && myChart.setOption(option); |
| | | }else{ |
| | | option={}; |
| | | myChart.setOption(option,true); |
| | | axisLabel: { |
| | | textStyle: { |
| | | color: "#00FFFF", |
| | | }, |
| | | }, |
| | | }, |
| | | ], |
| | | series: [ |
| | | { |
| | | type: "bar", |
| | | name: "", |
| | | barWidth: "15", |
| | | itemStyle: { |
| | | normal: { |
| | | //柱形图圆角,初始化效果 |
| | | barBorderRadius: [4, 4, 0, 0], |
| | | color: function (params) { |
| | | let colorList = ["#dcb018", "#00FFFF"]; |
| | | if (params.dataIndex % 2 == 0) { |
| | | return colorList[0]; |
| | | } else { |
| | | return colorList[1]; |
| | | } |
| | | }, |
| | | }, |
| | | }, |
| | | data: data.datay, |
| | | }, |
| | | ], |
| | | }; |
| | | setInterval(function () { |
| | | // 每次向左滑动一个,最后一个从头开始。 |
| | | if (option.dataZoom[0].endValue == that.chartData.datay.length) { |
| | | option.dataZoom[0].startValue = 0; |
| | | option.dataZoom[0].endValue = 5; |
| | | } else { |
| | | option.dataZoom[0].endValue = option.dataZoom[0].endValue + 1; |
| | | option.dataZoom[0].startValue = option.dataZoom[0].startValue + 1; |
| | | } |
| | | }, |
| | | myChart.setOption(option); |
| | | }, 4000); |
| | | |
| | | option && myChart.setOption(option); |
| | | window.addEventListener("resize", function () { |
| | | myChart.resize(); |
| | | }); |
| | | } else { |
| | | option = {}; |
| | | myChart.setOption(option, true); |
| | | } |
| | | }, |
| | | }, |
| | | }; |
| | | </script> |
| | | |
| | | <style scoped lang="scss"> |
| | | .bar-chart{ |
| | | width:100%; |
| | | height:calc(100% - 20px); |
| | | padding:20px 0 0; |
| | | .bar-contents{ |
| | | width:100%; |
| | | height:calc(100% - 60px); |
| | | border:1px solid #00FFFF; |
| | | .bar-chart { |
| | | width: 100%; |
| | | height: calc(100% - 20px); |
| | | padding: 20px 0 0; |
| | | .bar-contents { |
| | | width: 100%; |
| | | height: calc(100% - 60px); |
| | | border: 1px solid #00ffff; |
| | | box-sizing: border-box; |
| | | .chart{ |
| | | width: 100%; |
| | | height:100%; |
| | | } |
| | | .chart { |
| | | width: 100%; |
| | | height: 100%; |
| | | } |
| | | } |
| | | } |
| | | </style> |
| | |
| | | data() { |
| | | return { |
| | | chartData: { |
| | | datax: ["人员1", "人员2", "人员3", "人员4", "人员5", "人员6"], |
| | | datay: [120, 200, 150, 380, 470, 150, 230], |
| | | datax: [ |
| | | "人员1", |
| | | "人员2", |
| | | "人员3", |
| | | "人员4", |
| | | "人员5", |
| | | "人员6", |
| | | "人员7", |
| | | "人员8", |
| | | "人员9", |
| | | ], |
| | | datay: [120, 200, 150, 380, 470, 150, 230, 330, 190, 440], |
| | | }, |
| | | }; |
| | | }, |
| | |
| | | methods: { |
| | | //在职 |
| | | pieChart(chartName, data) { |
| | | let that = this; |
| | | let chartDom = this.$refs[chartName]; |
| | | let myChart = echarts.init(chartDom); |
| | | let option; |
| | |
| | | dataZoom: [ |
| | | { |
| | | type: "inside", |
| | | // show: true, //显示滚动条 |
| | | start: 0, |
| | | end: 100, |
| | | yAxisIndex: 0, |
| | | minSpan: 20, |
| | | maxSpan: 100, |
| | | // handleSize: 8 |
| | | }, |
| | | { |
| | | // type: 'slider', //两个一个是slider,一个是inside,slider是增加滚动条以及鼠标拖动滚动条功能,inside则是鼠标滚轮滚动滚动条。 |
| | | type: "inside", |
| | | // show: true, |
| | | // realtime : true, |
| | | yAxisIndex: 0, |
| | | minSpan: 20, |
| | | maxSpan: 100, |
| | | start: 0, |
| | | end: 100, |
| | | show: false, |
| | | startValue: 0, // 从头开始 |
| | | endValue: 5, // 一次性展示几个 |
| | | }, |
| | | ], |
| | | legend: { |
| | |
| | | ], |
| | | xAxis: [ |
| | | { |
| | | type: "", |
| | | type: "value", |
| | | name: "单位:件", |
| | | // min: data.yAxis[0].min?data.yAxis.min:0, |
| | | minInterval: 1, //坐标轴是整数 |
| | |
| | | ], |
| | | }; |
| | | |
| | | setInterval(function () { |
| | | // 每次向左滑动一个,最后一个从头开始。 |
| | | if (option.dataZoom[0].endValue == that.chartData.datay.length) { |
| | | option.dataZoom[0].startValue = 0; |
| | | option.dataZoom[0].endValue = 5; |
| | | } else { |
| | | option.dataZoom[0].endValue = option.dataZoom[0].endValue + 1; |
| | | option.dataZoom[0].startValue = option.dataZoom[0].startValue + 1; |
| | | } |
| | | myChart.setOption(option); |
| | | }, 4000); |
| | | |
| | | option && myChart.setOption(option); |
| | | window.addEventListener("resize", function () { |
| | | myChart.resize(); |
| | | }); |
| | | } else { |
| | | option = {}; |
| | | myChart.setOption(option, true); |
| | |
| | | this.getDashboard(); |
| | | setInterval(() => { |
| | | this.getDashboard(); |
| | | }, 10000); |
| | | }, 300000); |
| | | }, |
| | | watch: {}, |
| | | methods: { |