|
|
@@ -0,0 +1,278 @@
|
|
|
+<template>
|
|
|
+ <div class="chart-wrap">
|
|
|
+ <v-chart autoresize :option="option"/>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import * as echarts from 'echarts'
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: 'Jryl',
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ option: {}
|
|
|
+ }
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ this.getOption()
|
|
|
+ },
|
|
|
+
|
|
|
+ methods: {
|
|
|
+ getOption() {
|
|
|
+ var xData2 = ['变电', '电力']
|
|
|
+ var data = [
|
|
|
+ [50, 50, 50],
|
|
|
+ [100, 100, 100],
|
|
|
+ [80, 80, 80]
|
|
|
+ ]
|
|
|
+ const sealingData = []
|
|
|
+ const gapPerSize = 5
|
|
|
+ const gapData = data.map(() => [gapPerSize, gapPerSize, gapPerSize])
|
|
|
+
|
|
|
+ data.forEach((item, index) => {
|
|
|
+ let sealingBeforeItem = item
|
|
|
+ let sealingStart = [0, 0, 0]
|
|
|
+ let sealingEnd = sealingBeforeItem
|
|
|
+ if (index > 0) {
|
|
|
+ sealingBeforeItem = sealingData[index - 1][1]
|
|
|
+ sealingStart = sealingBeforeItem.map((d) => {
|
|
|
+ return d + gapPerSize
|
|
|
+ })
|
|
|
+ sealingEnd = sealingBeforeItem.map((d, dIndex) => {
|
|
|
+ return d + gapPerSize + item[dIndex]
|
|
|
+ })
|
|
|
+ }
|
|
|
+ sealingData[index] = [sealingStart, sealingEnd]
|
|
|
+ // const gapItem = item.map(n => {
|
|
|
+ // return n + gapPerSize
|
|
|
+ // })
|
|
|
+ // gapData.push(gapItem)
|
|
|
+ })
|
|
|
+ window['sealingData'] = sealingData
|
|
|
+ var barWidth = 30
|
|
|
+ this.option = {
|
|
|
+ backgroundColor: '#021132',
|
|
|
+ tooltip: {
|
|
|
+ trigger: 'item'
|
|
|
+ },
|
|
|
+ grid: {
|
|
|
+ left: 100,
|
|
|
+ bottom: 100
|
|
|
+ },
|
|
|
+ xAxis: {
|
|
|
+
|
|
|
+ type: 'value'
|
|
|
+
|
|
|
+ },
|
|
|
+ yAxis: {
|
|
|
+ data: xData2,
|
|
|
+ type: 'category',
|
|
|
+ splitLine: {
|
|
|
+ show: false
|
|
|
+ },
|
|
|
+ axisTick: {
|
|
|
+ show: false
|
|
|
+ },
|
|
|
+ axisLine: {
|
|
|
+ show: false
|
|
|
+ }
|
|
|
+
|
|
|
+ },
|
|
|
+ series: [
|
|
|
+ { // bar1
|
|
|
+ name: 'bar1',
|
|
|
+ type: 'bar',
|
|
|
+ stack: 'total',
|
|
|
+ barWidth: barWidth,
|
|
|
+ itemStyle: { // lenged文本
|
|
|
+ opacity: 1,
|
|
|
+ color: function(params) {
|
|
|
+ return new echarts.graphic.LinearGradient(0, 0, 1, 0, [{
|
|
|
+ offset: 0,
|
|
|
+ color: 'rgba(135, 49, 17,.4)' // 0% 处的颜色
|
|
|
+ }, {
|
|
|
+ offset: 1,
|
|
|
+ color: 'rgb(135, 49, 17)' // 100% 处的颜色
|
|
|
+ }], false)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ data: data[1]
|
|
|
+ },
|
|
|
+ { // gapBar
|
|
|
+ name: 'gapBar',
|
|
|
+ type: 'bar',
|
|
|
+ barWidth: barWidth,
|
|
|
+ stack: 'total',
|
|
|
+ z: 0,
|
|
|
+ itemStyle: {
|
|
|
+ color: 'rgba(255,0,0,1)',
|
|
|
+ opacity: 0.7
|
|
|
+ },
|
|
|
+ data: gapData[0]
|
|
|
+ },
|
|
|
+ { // bar2
|
|
|
+ name: 'bar2',
|
|
|
+ type: 'bar',
|
|
|
+ stack: 'total',
|
|
|
+ barWidth: barWidth,
|
|
|
+ itemStyle: { // lenged文本
|
|
|
+ opacity: 0.7,
|
|
|
+ color: function(params) {
|
|
|
+ return new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
|
|
|
+ offset: 0,
|
|
|
+ color: 'rgba(138, 138, 36,.4)' // 0% 处的颜色
|
|
|
+ }, {
|
|
|
+ offset: 1,
|
|
|
+ color: 'rgb(138, 138, 36)' // 100% 处的颜色
|
|
|
+ }], false)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ data: data[1]
|
|
|
+ },
|
|
|
+ { // gapBar
|
|
|
+ name: 'gapBar',
|
|
|
+ type: 'bar',
|
|
|
+ barWidth: barWidth,
|
|
|
+ stack: 'total',
|
|
|
+ z: 0,
|
|
|
+ itemStyle: {
|
|
|
+ color: 'rgba(255,0,0,1)',
|
|
|
+ opacity: 0.7
|
|
|
+ },
|
|
|
+ data: gapData[1]
|
|
|
+ },
|
|
|
+ { // bar2
|
|
|
+ name: 'bar3',
|
|
|
+ type: 'bar',
|
|
|
+ stack: 'total',
|
|
|
+ barWidth: barWidth,
|
|
|
+ itemStyle: { // lenged文本
|
|
|
+ opacity: 0.7,
|
|
|
+ color: function(params) {
|
|
|
+ return new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
|
|
|
+ offset: 0,
|
|
|
+ color: 'rgba(60, 151, 171,.4)' // 0% 处的颜色
|
|
|
+ }, {
|
|
|
+ offset: 1,
|
|
|
+ color: 'rgb(60, 151, 171)' // 100% 处的颜色
|
|
|
+ }], false)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ data: data[2]
|
|
|
+ },
|
|
|
+ // { // 替代柱状图 默认不显示颜色,是最下方柱图(邮件营销)的value值 - 20
|
|
|
+ // type: 'bar',
|
|
|
+ // barWidth: barWidth,
|
|
|
+ // barGap: '-100%',
|
|
|
+ // stack: '广告',
|
|
|
+ // itemStyle: {
|
|
|
+ // color: 'transparent'
|
|
|
+ // },
|
|
|
+ // data: data1
|
|
|
+ // },
|
|
|
+ { // 上半截柱子顶部圆片
|
|
|
+ 'name': '',
|
|
|
+ 'type': 'pictorialBar',
|
|
|
+ 'symbolSize': [15, barWidth],
|
|
|
+ 'symbolOffset': [5, 0],
|
|
|
+ 'symbolRotate': 180,
|
|
|
+ 'z': 12,
|
|
|
+ 'symbolPosition': 'end',
|
|
|
+ itemStyle: {
|
|
|
+ color: '#163F7A',
|
|
|
+ opacity: 1
|
|
|
+ },
|
|
|
+ label: {
|
|
|
+ show: true,
|
|
|
+ position: 'top',
|
|
|
+ fontSize: 16,
|
|
|
+ color: '#fff'
|
|
|
+ },
|
|
|
+ 'data': data[0]
|
|
|
+ },
|
|
|
+ { // 下半截柱子顶部圆片
|
|
|
+ 'name': '',
|
|
|
+ 'type': 'pictorialBar',
|
|
|
+ 'symbol': 'circle',
|
|
|
+ 'symbolRotate': 180,
|
|
|
+ 'symbolSize': [15, barWidth],
|
|
|
+ 'symbolOffset': [10, 0],
|
|
|
+ 'z': 12,
|
|
|
+ itemStyle: {
|
|
|
+ opacity: 1,
|
|
|
+ color: function(params) {
|
|
|
+ return new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
|
|
|
+ offset: 0,
|
|
|
+ color: '#FF9A22' // 0% 处的颜色
|
|
|
+ }, {
|
|
|
+ offset: 1,
|
|
|
+ color: '#FFD56E' // 100% 处的颜色
|
|
|
+ }], false)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ label: {
|
|
|
+ show: true,
|
|
|
+ position: 'top',
|
|
|
+ fontSize: 16,
|
|
|
+ color: '#fff'
|
|
|
+ // formatter:(item)=>{
|
|
|
+ // console.log(item)
|
|
|
+ // return 'ssss'
|
|
|
+ // }
|
|
|
+ },
|
|
|
+ 'symbolPosition': 'end',
|
|
|
+ 'data': data[1]
|
|
|
+ },
|
|
|
+ { // 下半截柱子底部圆片
|
|
|
+ 'name': '',
|
|
|
+ 'type': 'pictorialBar',
|
|
|
+ 'symbolSize': [15, barWidth],
|
|
|
+ 'symbolRotate': 180,
|
|
|
+ 'symbolOffset': [-5, 0],
|
|
|
+ 'z': 12,
|
|
|
+ itemStyle: {
|
|
|
+ opacity: 1,
|
|
|
+ color: function(params) {
|
|
|
+ return new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
|
|
|
+ offset: 0,
|
|
|
+ color: '#FF9A22' // 0% 处的颜色
|
|
|
+ }, {
|
|
|
+ offset: 1,
|
|
|
+ color: '#FFD56E' // 100% 处的颜色
|
|
|
+ }], false)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ 'data': [1, 1, 1, 1, 1]
|
|
|
+ }
|
|
|
+
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped lang="scss">
|
|
|
+
|
|
|
+$xHeight: 120px;
|
|
|
+.chart-wrap {
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+
|
|
|
+ .left-bar {
|
|
|
+ width: 35px;
|
|
|
+ display: inline-block;
|
|
|
+ }
|
|
|
+
|
|
|
+ .right-conent {
|
|
|
+ width: calc(100% - 35px);
|
|
|
+ height: 100%;
|
|
|
+ display: grid;
|
|
|
+ grid-template-columns: 1fr 1fr 1fr 1fr;
|
|
|
+ grid-template-rows: auto $xHeight;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+</style>
|