Commit b177e247 by 匡雅琴

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

2 parents 5195e009 526d2b54
<!--
* @Description:
* @Author: huyue
* @Date: 2023-07-07 14:01:42
* @LastEditors: huyue
* @LastEditTime: 2023-07-07 14:04:45
-->
<template>
<div>
<div :id="domId" style="width: 100%;" :style="{ height }"></div>
</div>
</template>
<script type="text/ecmascript-6">
import * as echarts from 'echarts'
import getBarLineOptions from './BarLineOptions'
export default {
name: 'BarChart',
props: {
height: {
type: String
},
domId: {
type: String,
default: 'bar-line'
},
dataList: {
type: Array,
default: () => []
},
tooltipFormatterObj: {
type: Array,
default: () => {
return [
{
label: '数量',
attrName: 'num'
},
{
label: '环比',
attrName: 'hrate',
addSymbol: '%'
},
{
label: '同比',
attrName: 'trate',
addSymbol: '%'
}
]
}
}
},
data() {
return {
barLineOptions: [],
moveAttr: {
// speed: 900,
seriesIndex: 0,
dataIndex: 0
},
timer: null
}
},
created() {
this.barLineOptions = getBarLineOptions({ tooltipFormatter: this.tooltipFormatter })
},
mounted() {
this.barLineDom = document.getElementById(this.domId)
this[this.domId] = echarts.init(this.barLineDom)
},
methods: {
tooltipFormatter(obj) {
var _currentItem = this.dataList[obj[0].dataIndex]
var _txt = ''
this.tooltipFormatterObj.forEach(item => {
if (_txt) {
_txt = _txt + '<br>'
}
_txt = _txt + item.label + ':' + _currentItem[item.attrName] + (item.addSymbol || '')
})
return _txt
},
drawBarLine() {
console.log(this.dataList)
this.barLineOptions.xAxis.data = this.dataList.map(item => item.month)
this.barLineOptions.series[0].data = this.dataList.map(item => item.data1)
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)
}
}
}
</script>
<style scoped lang="scss">
</style>
<!--
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2022-10-25 10:12:26
* @LastEditors: huyue
* @LastEditTime: 2023-07-07 14:04:18
* @FilePath: \dj-data-view\src\components\ViewTitle.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
<div>
<div :id="domId" style="width: 100%;" :style="{ height }"></div>
</div>
</template>
<script type="text/ecmascript-6">
import * as echarts from 'echarts'
import getBarLineOptions from './BarLineOptions'
export default {
name: 'BarLineChart',
props: {
height: {
type: String
},
domId: {
type: String,
default: 'bar-line'
},
dataList: {
type: Array,
default: () => []
},
tooltipFormatterObj: {
type: Array,
default: () => {
return [
{
label: '数量',
attrName: 'num'
},
{
label: '环比',
attrName: 'hrate',
addSymbol: '%'
},
{
label: '同比',
attrName: 'trate',
addSymbol: '%'
}
]
}
}
},
data() {
return {
barLineOptions: [],
moveAttr: {
// speed: 900,
seriesIndex: 0,
dataIndex: 0
},
timer: null
}
},
created() {
this.barLineOptions = getBarLineOptions({ tooltipFormatter: this.tooltipFormatter })
},
mounted() {
this.barLineDom = document.getElementById(this.domId)
this[this.domId] = echarts.init(this.barLineDom)
},
methods: {
tooltipFormatter(obj) {
var _currentItem = this.dataList[obj[0].dataIndex]
var _txt = ''
this.tooltipFormatterObj.forEach(item => {
if (_txt) {
_txt = _txt + '<br>'
}
_txt = _txt + item.label + ':' + _currentItem[item.attrName] + (item.addSymbol || '')
})
return _txt
},
drawBarLine() {
console.log(this.dataList)
this.barLineOptions.xAxis.data = this.dataList.map(item => item.month)
this.barLineOptions.series[0].data = this.dataList.map(item => item.data1)
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)
}
}
}
</script>
<style scoped lang="scss">
</style>
import * as echarts from 'echarts'
function getBarLineOptions(obj) {
const { tooltipFormatter } = obj
var barLineOption = {
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
},
xAxis: {
data: []
},
yAxis: [
{
name: '¥',
type: 'value',
min: 0,
max: 8000,
axisLabel: {
formatter: '{value}'
},
splitLine: {
show: false
}
},
{
name: '',
type: 'value',
min: 0,
max: 100,
interval: 20,
axisLabel: {
formatter: '{value}%'
},
splitLine: {
lineStyle: {
color: '#1d2a38'
}
}
}
],
grid: {
left: '3%',
right: '4%',
top: '10%',
bottom: '6%',
containLabel: true
},
series: [
{
name: 'bar',
type: 'bar',
stack: 'one',
data: [],
label: {
show: true
},
itemStyle: {
barBorderRadius: [2, 2, 0, 0], // 柱体圆角
color: function(params) {
const colorList = [
['#22D8FF', '#5C56FF'],
['#2AD190', '#00B7DF'],
['#22D8FF', '#5C56FF'],
['#2AD190', '#00B7DF'],
['#22D8FF', '#5C56FF'],
['#2AD190', '#00B7DF'],
['#22D8FF', '#5C56FF'],
['#2AD190', '#00B7DF'],
['#22D8FF', '#5C56FF'],
['#2AD190', '#00B7DF'],
['#22D8FF', '#5C56FF'],
['#2AD190', '#00B7DF']
]
var colorItem = colorList[params.dataIndex]
return new echarts.graphic.LinearGradient(
0, 0, 0, 1, [{ // 代表渐变色从正上方开始
offset: 0, // offset范围是0~1,用于表示位置,0是指0%处的颜色
color: colorItem[0]
}, // 柱图渐变色
{
offset: 1, // 指100%处的颜色
color: colorItem[1]
}]
)
}
}
},
{
name: 'bar2',
type: 'bar',
stack: 'one',
label: {
show: true
},
data: [],
itemStyle: {
barBorderRadius: [2, 2, 0, 0], // 柱体圆角
color: function(params) {
const colorList = [
['#11627A', '#282F7A'],
['#145F4E', '#035972'],
['#11627A', '#282F7A'],
['#145F4E', '#035972'],
['#11627A', '#282F7A'],
['#145F4E', '#035972'],
['#11627A', '#282F7A'],
['#145F4E', '#035972'],
['#11627A', '#282F7A'],
['#145F4E', '#035972'],
['#11627A', '#282F7A'],
['#145F4E', '#035972']
]
var colorItem = colorList[params.dataIndex]
return new echarts.graphic.LinearGradient(
0, 0, 0, 1, [{ // 代表渐变色从正上方开始
offset: 0, // offset范围是0~1,用于表示位置,0是指0%处的颜色
color: colorItem[0]
}, // 柱图渐变色
{
offset: 1, // 指100%处的颜色
color: colorItem[1]
}]
)
}
}
},
{
name: 'Dynamic Line',
type: 'line',
yAxisIndex: 1,
data: []
}
]
}
return barLineOption
}
export default getBarLineOptions
import * as echarts from 'echarts'
function getBarLineOptions(obj) {
// const { tooltipFormatter } = obj
var barLineOption = {
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
},
xAxis: {
data: []
},
yAxis: {
name: '',
type: 'value',
min: 0,
max: 10000,
splitLine: {
lineStyle: {
color: '#1d2a38'
}
}
},
grid: {
left: '3%',
right: '4%',
top: '10%',
bottom: '6%',
containLabel: true
},
series: [
{
name: 'bar',
type: 'bar',
stack: 'one',
data: [],
label: {
show: true
},
itemStyle: {
barBorderRadius: [2, 2, 0, 0], // 柱体圆角
color: function(params) {
const colorList = [
['#22D8FF', '#5C56FF'],
['#2AD190', '#00B7DF'],
['#22D8FF', '#5C56FF'],
['#2AD190', '#00B7DF'],
['#22D8FF', '#5C56FF'],
['#2AD190', '#00B7DF'],
['#22D8FF', '#5C56FF'],
['#2AD190', '#00B7DF'],
['#22D8FF', '#5C56FF'],
['#2AD190', '#00B7DF'],
['#22D8FF', '#5C56FF'],
['#2AD190', '#00B7DF']
]
var colorItem = colorList[params.dataIndex]
return new echarts.graphic.LinearGradient(
0, 0, 0, 1, [{ // 代表渐变色从正上方开始
offset: 0, // offset范围是0~1,用于表示位置,0是指0%处的颜色
color: colorItem[0]
}, // 柱图渐变色
{
offset: 1, // 指100%处的颜色
color: colorItem[1]
}]
)
}
}
},
{
name: 'bar2',
type: 'bar',
stack: 'one',
label: {
show: true
},
data: [],
itemStyle: {
barBorderRadius: [2, 2, 0, 0], // 柱体圆角
color: function(params) {
const colorList = [
['#11627A', '#282F7A'],
['#145F4E', '#035972'],
['#11627A', '#282F7A'],
['#145F4E', '#035972'],
['#11627A', '#282F7A'],
['#145F4E', '#035972'],
['#11627A', '#282F7A'],
['#145F4E', '#035972'],
['#11627A', '#282F7A'],
['#145F4E', '#035972'],
['#11627A', '#282F7A'],
['#145F4E', '#035972']
]
var colorItem = colorList[params.dataIndex]
return new echarts.graphic.LinearGradient(
0, 0, 0, 1, [{ // 代表渐变色从正上方开始
offset: 0, // offset范围是0~1,用于表示位置,0是指0%处的颜色
color: colorItem[0]
}, // 柱图渐变色
{
offset: 1, // 指100%处的颜色
color: colorItem[1]
}]
)
}
}
}
]
}
return barLineOption
}
export default getBarLineOptions
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<template> <template>
<div> <div>
<div>测试图</div> <div>测试图</div>
<div id="demo" style="width: 100vh;height: 100%;"></div> <div id="demo" style="width: 100vw;height: 50vh"></div>
</div> </div>
</template> </template>
......
<template>
<div class="statistics">
<div class="statistics-item" v-for="(item, index) in list" :key="index" :style="{'width': 100 / list.length + '%'}">
<div class="statistics-top">
<div class="statistics-name">{{item.name}}</div>
<div class="statistics-price">¥<span class="statistics-price-number">{{item.value}}</span></div>
</div>
<div class="statistics-bottom">
<template v-if="bottomType == 'money'">
<span> {{item.moneyName}}</span>
<span>¥{{item.moneyValue}}</span>
</template>
<template v-else-if="bottomType == 'default'">
<span>{{item.moneyName}}</span>
<span>{{item.moneyValue}}</span>
</template>
</div>
</div>
</div>
</template>
<script>
export default {
name: 'StatisticsBox',
props: {
list: {
type: Array
},
bottomType: {
type: String,
default: 'default'
}
},
data() {
return {
}
},
mounted() {},
methods: {}
}
</script>
<style lang="scss" scoped>
.statistics {
display: flex;
color: #fff;
&-item {
padding: 0.89vh 0.53vw;
margin-right: 1.11vw;
background: #061422;
box-shadow: inset 0 0 20px 0 #3d57ff69;
&:last-child {
margin-right: 0;
}
}
&-top {
padding-bottom: 0.89vh;
padding-left: 0.3vw;
}
&-name {
font-weight: 500;
font-size: 14px;
margin-bottom: 0.89vh;
}
&-price {
display: flex;
align-items: center;
color: #25D6FF;
font-weight: 600;
font-size: 14px;
&-number {
padding-left: 0.56vw;
font-size: 20px;
color: #5894FF;
background-image:-webkit-linear-gradient(left,#24D8FF,#7787FF);
-webkit-background-clip:text;
-webkit-text-fill-color:transparent;
}
}
&-bottom {
display: flex;
justify-content: space-between;
font-size: 12px;
color: #95ACD9;
border-top: 1px solid #2A3D72;
padding: 0.89vh 0.3vw 0;
}
}
</style>
export default {
watch: {
watchReportParams: {
immediate: true,
handler(newval) {
this && this.init && this.init(newval)
}
}
},
computed: {
watchReportParams() {
return this.$store.state.app.reportParams
}
}
}
/*
* @Description:
* @Author: huyue
* @Date: 2023-07-04 11:44:11
* @LastEditors: huyue
* @LastEditTime: 2023-07-07 11:22:53
*/
import changeMixin from './changeMixin'
export {
changeMixin
}
...@@ -3,14 +3,57 @@ ...@@ -3,14 +3,57 @@
* @Author: huyue * @Author: huyue
* @Date: 2023-07-05 10:35:43 * @Date: 2023-07-05 10:35:43
* @LastEditors: huyue * @LastEditors: huyue
* @LastEditTime: 2023-07-05 10:50:54 * @LastEditTime: 2023-07-06 17:41:10
--> -->
<template> <template>
<div class="left">左侧内容</div> <div class="left">
<StatisticsBox :list="solarList" bottomType="money"></StatisticsBox>
<PurchaseTrends></PurchaseTrends>
</div>
</template> </template>
<script type='text/ecmascript-6'> <script type='text/ecmascript-6'>
import PurchaseTrends from './PurchaseTrends.vue'
export default { export default {
name: 'ContentLeft' name: 'ContentLeft',
components: {
PurchaseTrends
},
data() {
return {
solarList: [
{
name: '总采购额',
value: '2,280,708',
moneyName: '本月采购额',
moneyValue: '2,280,708'
},
{
name: '总采购额',
value: '2,280,708',
moneyName: '本月采购额',
moneyValue: '2,280,708'
},
{
name: '总采购额',
value: '2,280,708',
moneyName: '本月采购额',
moneyValue: '2,280,708'
},
// {
// name: '总采购额',
// value: '2,280,708',
// moneyName: '本月采购额',
// moneyValue: '2,280,708'
// },
// {
// name: '总采购额',
// value: '2,280,708',
// moneyName: '本月采购额',
// moneyValue: '2,280,708'
// }
]
}
}
} }
</script> </script>
<style scoped lang='scss'> <style scoped lang='scss'>
...@@ -19,6 +62,6 @@ export default { ...@@ -19,6 +62,6 @@ export default {
flex-direction: column; flex-direction: column;
width: 64.17vw; width: 64.17vw;
overflow: hidden; overflow: hidden;
background: #091C40; // background: #091C40;
} }
</style> </style>
<!--
* @Description: 近一年采购额趋势图
* @Author: huyue
* @Date: 2023-07-06 16:19:15
* @LastEditors: huyue
* @LastEditTime: 2023-07-07 13:54:35
-->
<template>
<div class="purchase-box">
<box-title title="采购额排名"></box-title>
<BarLineChart ref="purchaseRef" height="25.37vh" domId="purchase" :dataList.sync="dataList" :tooltipFormatterObj="tooltipFormatterObj"></BarLineChart>
</div>
</template>
<script type="text/ecmascript-6">
import { changeMixin } from '@/mixins'
export default {
name: 'PurchaseTrends',
mixins: [changeMixin],
data() {
return {
tooltipFormatterObj: [
{
label: '商城',
attrName: 'data1'
},
{
label: '自采',
attrName: 'data2'
},
{
label: '占比',
attrName: 'data3',
addSymbol: '%'
}
],
dataList: []
}
},
mounted() {
},
methods: {
init() {
const p = new Promise((resolve) => {
for (let i = 0; i < 12; i++) {
this.dataList.push({
month: i + 1 + '月',
data1: +(Math.random() * 2000).toFixed(2),
data2: +(Math.random() * 5000).toFixed(2),
data3: +(Math.random() * 50).toFixed(2)
})
}
resolve()
})
p.then(() => {
this.$refs.purchaseRef.drawBarLine()
})
}
}
}
</script>
<style scoped lang='scss'>
.purchase-box {
margin: 1.78vh 0;
background-color: #061422;
box-shadow: inset 0 0 20px 0 #3d57ff69;
}
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!