Commit 8ebcdcd3 by 匡雅琴

Merge branch 'v1.3.0' of http://192.168.3.233:8090/h5/glsk-data-view-pd into v1.3.0

2 parents 8f6e82f0 2c75bba5
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* @Author: huyue * @Author: huyue
* @Date: 2023-07-07 14:01:42 * @Date: 2023-07-07 14:01:42
* @LastEditors: huyue * @LastEditors: huyue
* @LastEditTime: 2023-07-26 14:38:43 * @LastEditTime: 2023-08-02 17:06:11
--> -->
<template> <template>
<div> <div>
...@@ -53,13 +53,7 @@ export default { ...@@ -53,13 +53,7 @@ export default {
}, },
data() { data() {
return { return {
barLineOptions: [], barLineOptions: []
moveAttr: {
// speed: 900,
seriesIndex: 0,
dataIndex: 0
},
timer: null
} }
}, },
created() { created() {
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* @Author: huyue * @Author: huyue
* @Date: 2023-07-04 13:55:35 * @Date: 2023-07-04 13:55:35
* @LastEditors: huyue * @LastEditors: huyue
* @LastEditTime: 2023-08-02 15:41:04 * @LastEditTime: 2023-08-02 17:21:46
--> -->
<template> <template>
<div class="left"> <div class="left">
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
<div class="ratio-left">周同比<span class="positive">12%</span></div> <div class="ratio-left">周同比<span class="positive">12%</span></div>
<div class="ratio-right">日环比<span class="negative">-7%</span></div> <div class="ratio-right">日环比<span class="negative">-7%</span></div>
</div> </div>
<BarChart ref="amountChartRef" domId="amountChart" :dataList.sync="amountDataList" :tooltipFormatterObj="amountTooltip"></BarChart>
</div> </div>
</div> </div>
<div class="left-box"> <div class="left-box">
...@@ -31,13 +32,25 @@ ...@@ -31,13 +32,25 @@
</template> </template>
<script> <script>
import BarChart from './compoments/BarChart.vue'
export default { export default {
name: 'CrowdfundLeft', name: 'CrowdfundLeft',
components: {
BarChart
},
data() { data() {
return { return {
amountDataList: [1000, 1000, 5000, 10000, 20000],
amountTooltip: [
{
label: '部署门店',
attrName: 'data1'
}
]
} }
}, },
mounted() { mounted() {
this.$refs.amountChartRef.drawBar()
} }
} }
</script> </script>
......
<!--
* @Description: 柱状图
* @Author: huyue
* @Date: 2023-07-07 14:01:42
* @LastEditors: huyue
* @LastEditTime: 2023-08-02 17:21:01
-->
<template>
<div>
<div :id="domId" style="width: 100%;height: 15vh"></div>
</div>
</template>
<script type="text/ecmascript-6">
import * as echarts from 'echarts'
import BarOptions from './BarOptions'
import utils from '../../../utils/util'
export default {
name: 'BarChart',
props: {
domId: {
type: String,
default: ''
},
dataList: {
type: Array,
default: () => []
},
tooltipFormatterObj: {
type: Array,
default: () => {
return [
{
label: '数量',
attrName: 'num'
}
]
}
}
},
data() {
return {
barLineOptions: []
}
},
created() {
this.barOptions = BarOptions({ tooltipFormatter: this.tooltipFormatter })
},
mounted() {
this.barDom = document.getElementById(this.domId)
this[this.domId] = echarts.init(this.barDom)
this.chartBindEvent()
},
methods: {
tooltipFormatter(obj) {
var _currentItem = this.dataList[obj[0].dataIndex]
var _html = ''
var _txt = ''
this.tooltipFormatterObj.forEach(item => {
_txt += `<div style="display:flex;"><div style="color: #c9c9c9">${item.label}:</div><div style="color: #fff;">${utils.numAddSymbol(_currentItem[item.attrName])}${item.addSymbol || ''}</div></div>`
})
_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
},
drawBar() {
this.barOptions.xAxis.data = ['1月', '2月', '3月', '4月', '5月']
this.barLineOptions.series[0].data = this.dataList
},
chartBindEvent() {
// resize
window.addEventListener('resize', () => {
this[this.domId].resize()
})
}
}
}
</script>
/*
* @Description: 柱状图配置
* @Author: huyue
* @Date: 2023-07-07 14:04:52
* @LastEditors: huyue
* @LastEditTime: 2023-08-02 17:12:26
*/
import * as echarts from 'echarts'
function getBarLineOptions(obj) {
const { tooltipFormatter } = obj
var barLineOption = {
tooltip: {
trigger: 'axis',
borderWidth: 0,
padding: 0,
formatter: tooltipFormatter || '',
confine: true
},
xAxis: {
data: []
},
yAxis: {
name: '',
type: 'value',
// min: 0,
// max: 100,
splitLine: {
lineStyle: {
color: '#1d2a38'
}
}
},
grid: {
left: '3%',
right: '4%',
top: '20%',
bottom: '6%',
containLabel: true
},
series: [
{
name: 'bar',
type: 'bar',
data: [],
label: {
show: false
},
itemStyle: {
barBorderRadius: [2, 2, 0, 0], // 柱体圆角
color: function(params) {
return new echarts.graphic.LinearGradient(
0, 0, 0, 1, [{ // 代表渐变色从正上方开始
offset: 0, // offset范围是0~1,用于表示位置,0是指0%处的颜色
color: '#22D8FF'
}, // 柱图渐变色
{
offset: 1, // 指100%处的颜色
color: '#061422'
}]
)
}
}
}
]
}
return barLineOption
}
export default getBarLineOptions
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!