Commit 1a8aed13 by 胡悦

提交图例

1 parent 75e5fcb7
<!--
* @Description:
* @Description: 柱状图
* @Author: huyue
* @Date: 2023-07-07 14:01:42
* @LastEditors: huyue
* @LastEditTime: 2023-07-07 14:24:23
* @LastEditTime: 2023-07-07 14:59:28
-->
<template>
<div>
......@@ -67,6 +67,7 @@ export default {
mounted() {
this.barLineDom = document.getElementById(this.domId)
this[this.domId] = echarts.init(this.barLineDom)
this.chartBindEvent()
},
methods: {
tooltipFormatter(obj) {
......@@ -86,6 +87,12 @@ export default {
this.barLineOptions.series[0].data = this.dataList.map(item => item.data1)
this.barLineOptions.series[1].data = this.dataList.map(item => item.data2)
this[this.domId].setOption(this.barLineOptions)
},
chartBindEvent() {
// resize
window.addEventListener('resize', () => {
this[this.domId].resize()
})
}
}
}
......
......@@ -2,7 +2,7 @@
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2022-10-25 10:12:26
* @LastEditors: huyue
* @LastEditTime: 2023-07-07 14:04:18
* @LastEditTime: 2023-07-07 16:22:32
* @FilePath: \dj-data-view\src\components\ViewTitle.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
......@@ -68,18 +68,20 @@ export default {
mounted() {
this.barLineDom = document.getElementById(this.domId)
this[this.domId] = echarts.init(this.barLineDom)
this.chartBindEvent()
},
methods: {
tooltipFormatter(obj) {
var _currentItem = this.dataList[obj[0].dataIndex]
var _html = ''
var _txt = ''
this.tooltipFormatterObj.forEach(item => {
if (_txt) {
_txt = _txt + '<br>'
}
_txt = _txt + item.label + ':' + _currentItem[item.attrName] + (item.addSymbol || '')
_txt += `<div style="display:flex;"><div style="color: #c9c9c9">${item.label}:</div><div style="color: #fff;">${_currentItem[item.attrName]}${item.addSymbol || ''}</div></div>`
})
return _txt
_html += `<div style="backdrop-filter: blur(4px);background-color: #051526;border: 2px solid;border-image: linear-gradient(90deg, #074989, #30DCFF, #074989) 1;padding: 10px;">
${_txt}
</div>`
return _html
},
drawBarLine() {
console.log(this.dataList)
......@@ -88,6 +90,12 @@ export default {
this.barLineOptions.series[1].data = this.dataList.map(item => item.data2)
this.barLineOptions.series[2].data = this.dataList.map(item => item.data3)
this[this.domId].setOption(this.barLineOptions)
},
chartBindEvent() {
// resize
window.addEventListener('resize', () => {
this[this.domId].resize()
})
}
}
}
......
......@@ -5,13 +5,26 @@ function getBarLineOptions(obj) {
tooltip: {
trigger: 'axis',
borderWidth: 0,
backgroundColor: 'rgba(68,68,68,0.80)',
textStyle: {
color: 'rgba(255,255,255,0.6)',
fontSize: '1.5px'
},
formatter: tooltipFormatter || '',
confine: true
padding: 0,
// borderColor: function(p) {
// return new echarts.graphic.LinearGradient(
// 0, 0, 0, 1, [{ // 代表渐变色从正上方开始
// offset: 0, // offset范围是0~1,用于表示位置,0是指0%处的颜色
// color: '#074989'
// }, // 柱图渐变色
// {
// offset: 1, // 指100%处的颜色
// color: '#30DCFF'
// }]
// )
// },
backgroundColor: '#051526',
// textStyle: {
// color: '#c9c9c9',
// fontSize: '1.5px'
// },
formatter: tooltipFormatter || ''
// confine: true
},
xAxis: {
data: []
......@@ -41,7 +54,7 @@ function getBarLineOptions(obj) {
],
grid: {
left: '3%',
right: '4%',
right: '2%',
top: '20%',
bottom: '6%',
containLabel: true
......
......@@ -3,20 +3,16 @@
* @Author: huyue
* @Date: 2023-07-07 14:04:52
* @LastEditors: huyue
* @LastEditTime: 2023-07-07 14:35:44
* @LastEditTime: 2023-07-07 16:23:54
*/
import * as echarts from 'echarts'
function getBarLineOptions(obj) {
const { tooltipFormatter } = obj
var barLineOption = {
tooltip: {
show: false,
trigger: 'axis',
borderWidth: 0,
backgroundColor: 'rgba(68,68,68,0.80)',
textStyle: {
color: 'rgba(255,255,255,0.6)',
fontSize: '1.5px'
},
formatter: tooltipFormatter || '',
confine: true
},
......@@ -37,7 +33,7 @@ function getBarLineOptions(obj) {
grid: {
left: '3%',
right: '4%',
top: '10%',
top: '20%',
bottom: '6%',
containLabel: true
},
......
......@@ -3,11 +3,19 @@
* @Author: huyue
* @Date: 2023-07-06 16:19:15
* @LastEditors: huyue
* @LastEditTime: 2023-07-07 14:35:36
* @LastEditTime: 2023-07-07 16:30:49
-->
<template>
<div class="merchant-box">
<box-title title="商户开通及使用趋势"></box-title>
<div class="legend">
<div class="legend-item">
<span class="open"></span>开通商户
</div>
<div class="legend-item">
<span class="procure"></span>采购商户
</div>
</div>
<BarChart ref="merchantTrendsRef" height="28.67vh" domId="merchantTrends" :dataList.sync="dataList" :tooltipFormatterObj="tooltipFormatterObj"></BarChart>
</div>
</template>
......@@ -55,8 +63,37 @@ export default {
</script>
<style scoped lang='scss'>
.merchant-box {
position: relative;
// margin: 1.78vh 0;
background-color: #061422;
box-shadow: inset 0 0 20px 0 #3d57ff69;
.legend {
position: absolute;
display: flex;
align-items: center;
top: 3.97vh;
left: 50%;
transform: translateX(-50%);
&-item {
display: flex;
align-items: center;
color: #fff;
margin-right: 1.67vw;
&:last-child {
margin-right: 0;
}
.open,
.procure {
width: 0.56vw;
height: 0.89vh;
}
.open {
background-image: linear-gradient(180deg, #22D8FF 0%, #223FA9 100%);
}
.procure {
background-image: linear-gradient(180deg, #38FBB0 1%, #00A89E 100%);
}
}
}
}
</style>
......@@ -3,12 +3,27 @@
* @Author: huyue
* @Date: 2023-07-06 16:19:15
* @LastEditors: huyue
* @LastEditTime: 2023-07-07 14:46:37
* @LastEditTime: 2023-07-07 15:34:39
-->
<template>
<div class="purchase-box">
<box-title title="采购额排名"></box-title>
<BarLineChart ref="purchaseRef" height="28.48vh" domId="purchase" :dataList.sync="dataList" :tooltipFormatterObj="tooltipFormatterObj"></BarLineChart>
<div class="legend">
<div class="legend-item shop">
<span class="legend-even">双</span>
<span class="legend-odd">单</span>
<span>商城</span>
</div>
<div class="legend-item self">
<span class="legend-even">双</span>
<span class="legend-odd">单</span>
自采
</div>
<div class="legend-item">
<img class="icon-line" src="@/assets/images/icon-line.png" alt="">商城采购占比
</div>
</div>
</div>
</template>
......@@ -61,8 +76,58 @@ export default {
</script>
<style scoped lang='scss'>
.purchase-box {
position: relative;
margin: 1.78vh 0;
background-color: #061422;
box-shadow: inset 0 0 20px 0 #3d57ff69;
.legend {
display: flex;
position: absolute;
right: 1.39vw;
top: 2.22vh;
&-item {
display: flex;
align-items: center;
color: #fff;
margin-right: 1.67vw;
&:last-child {
margin-right: 0;
}
img {
width: 1.32vw;
height: 1vh;
margin-right: 0.28vw;
}
.icon-line {
width: 0.98vw;
height: 0.56vh;
}
.legend-even,
.legend-odd {
display: inline-block;
width: 0.83vw;
height: 1.33vh;
margin-right: 0.28vw;
font-size: 8px;
text-align: center;
}
}
}
}
.shop {
.legend-even {
background-image: linear-gradient(180deg, #2AD190 1%, #00B7DF 100%);
}
.legend-odd {
background-image: linear-gradient(180deg, #22D8FF 0%, #5C56FF 100%);
}
}
.self {
.legend-even {
background-image: linear-gradient(180deg, #145F4E 1%, #035972 100%);
}
.legend-odd {
background-image: linear-gradient(180deg, #11627A 0%, #282F7A 100%);
}
}
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!