Commit 0e7d6b76 by 胡悦

提交概览

1 parent fbf2af39
import { http } from '@/main'
const timePeriodStatistics = params => {
params.method = 'scrm.api.shopmall.order.timePeriodStatistics'
return http({
url: 'rop-scrm-shopmall/router',
method: 'GET',
data: params,
sign: true
})
}
const couponStatistical = params => {
params.method = 'scrm.api.coupon.statistical.marketing.effect'
return http({
url: 'rop-scrm-coupon/router',
method: 'GET',
data: params,
sign: true
})
}
const equityStatistical = params => {
params.method = 'scrm.api.equity.statistical.marketing.effect'
return http({
url: 'rop-scrm-equity/router',
method: 'GET',
data: params,
sign: true
})
}
const merchantStatistical = params => {
params.method = 'scrm.api.shopmall.activity.get.merchant.statistics'
return http({
url: 'rop-scrm-shopmall/router',
method: 'GET',
data: params,
sign: true
})
}
export default { timePeriodStatistics, couponStatistical, equityStatistical, merchantStatistical }
<template>
<div id="bar" class="chart-bar"></div>
<div class="chart-box">
<div id="bar" class="chart-bar"></div>
</div>
</template>
<script>
import * as echarts from 'echarts'
export default {
name: 'BarChart',
props: ['list'],
data() {
return {}
},
methods: {
getChart() {
let chartDom = document.getElementById('bar')
let myChart = echarts.init(chartDom)
let option
const data = []
for (let i = 0; i < 5; ++i) {
data.push(Math.round(Math.random() * 200))
}
option = {
return {
myChart: {},
option: {
xAxis: {
max: 'dataMax'
},
yAxis: {
type: 'category',
data: ['A', 'B', 'C', 'D', 'E'],
data: [],
inverse: true,
animationDuration: 300,
animationDurationUpdate: 300,
max: 2 // only the largest 3 bars will be displayed
max: 4 // only the largest 3 bars will be displayed
},
grid: {
x: 120,
y: 0,
x2: 50,
y2: 0
},
series: [
{
realtimeSort: true,
name: 'X',
type: 'bar',
data: data,
data: [],
label: {
show: true,
position: 'right',
valueAnimation: true,
normal: [20, 0]
valueAnimation: true
},
itemStyle: {
normal: {
label: {
show: true,
textStyle: {
color: '#fff',
fontSize: 16
}
},
color: '#5850FF' // 修改柱状颜色
}
}
}
],
......@@ -52,19 +63,42 @@ export default {
animationEasing: 'linear',
animationEasingUpdate: 'linear'
}
option && myChart.setOption(option)
}
},
watch: {
list(val) {
const yData = val.map(i => i.packageName)
const data = val.map(i => i.totalSales)
this.option.yAxis.data = yData
this.option.series[0].data = data
console.log(this.option)
this.option && this.myChart.setOption(this.option)
}
},
methods: {
getChart() {
let option
const data = []
for (let i = 0; i < 5; ++i) {
data.push(Math.round(Math.random() * 200))
}
}
},
mounted() {
this.getChart()
// this.getChart()
let chartDom = document.getElementById('bar')
this.myChart = echarts.init(chartDom)
this.option && this.myChart.setOption(this.option)
}
}
</script>
<style lang="scss" scoped>
.chart-box {
width: 100%;
height: 207px;
}
.chart-bar {
width: 235px;
height: 207px;
}
</style>
<template>
<div id="line" class="chart-line"></div>
<div class="chart-box">
<div class="chart-line" id="line"></div>
</div>
</template>
<script>
import * as echarts from 'echarts'
export default {
name: 'LineChart',
props: ['list'],
data() {
return {}
},
methods: {
getChart() {
let chartDom = document.getElementById('line')
let myChart = echarts.init(chartDom)
let option
option = {
return {
option: {
tooltip: {
trigger: 'axis',
// formatter: `{b}\r \n成交金额:{c}\n \n 订单总数:{d}单`
formatter: function(params) {
var tips = ''
console.log(params)
if (params != null && params.length > 0) {
tips += params[0].name + '<br />'
for (var i = 0; i < params.length; i++) {
params[i].marker = '<span style="display:inline-block;margin-right:4px;border-radius:10px;width:10px;height:10px;background-color:#5850FF;"></span>'
tips += params[i].marker + '成交金额: ' + params[i].value + '元'
}
}
return tips
// var res = `<div>${params[0].name}</div>
// <div>成交金额:${params[0].data}元</div>
// <div>订单总数:${params[0].value}</div>`
// return res
}
},
xAxis: {
type: 'category',
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
data: []
},
yAxis: {
type: 'value'
},
// legend: {
// height: 260,
// width: 1184
// },
grid: {
x: 80,
y: 50,
x2: 50,
y2: 50
},
series: [
{
data: [150, 230, 224, 218, 135, 147, 260],
type: 'line'
data: [],
type: 'line',
itemStyle: {
normal: {
lineStyle: {
color: '#5850FF' // 改变折线颜色
}
}
}
}
]
}
option && myChart.setOption(option)
},
myChart: {}
}
},
watch: {
list(val) {
console.log(val)
const xData = val.map(i => i.dataDateStr)
const yData = val.map(i => i.amount)
this.option.xAxis.data = xData.reverse()
this.option.series[0].data = yData
this.option.series[0].count = val.map(i => i.count)
this.option && this.myChart.setOption(this.option)
}
},
methods: {},
mounted() {
this.getChart()
let chartDom = document.getElementById('line')
this.myChart = echarts.init(chartDom)
// this.option && this.myChart.setOption(this.option)
}
}
</script>
<style lang="scss" scoped>
.chart-box {
height: 260px;
width: 100%;
}
.chart-line {
height: 260px;
width: 880px;
}
</style>
<template>
<div id="pie" class="chart-pie"></div>
<div class="chart-box">
<div id="pie" class="chart-pie"></div>
</div>
</template>
<script>
import * as echarts from 'echarts'
const DISCOUNT_TYPE = {
1: '满减券',
2: '折扣券',
3: '代金券',
4: '兑换券',
5: '购车代金券',
6: '商品折扣券',
7: '会员服务'
}
export default {
name: 'PieChart',
props: ['list'],
data() {
return {}
},
methods: {
getChart() {
let chartDom = document.getElementById('pie')
let myChart = echarts.init(chartDom)
let option
option = {
// title: {
// text: 'Referer of a Website',
// subtext: 'Fake Data',
// left: 'center'
// },
return {
DISCOUNT_TYPE,
option: {
tooltip: {
trigger: 'item',
formatter: '{b}\n \n{c} 张'
},
// legend: {
// orient: 'vertical',
// left: 'left'
// },
series: [
{
name: '券类营销',
......@@ -40,15 +36,12 @@ export default {
itemStyle: {
normal: {
color: function(params) {
var colorList = ['#5850FF', '#FE9C1C']
var colorList = ['#5850FF', '#FE9C1C', '#FDB757', '#6495FA']
return colorList[params.dataIndex]
}
}
},
data: [
{ value: 1048, name: '折扣券' },
{ value: 75, name: '兑换券' }
],
data: [],
emphasis: {
itemStyle: {
shadowBlur: 10,
......@@ -58,20 +51,38 @@ export default {
}
}
]
}
option && myChart.setOption(option)
},
myChart: {}
}
},
watch: {
list(val) {
const arr = this.list.map(item => {
return {
name: this.DISCOUNT_TYPE[item.discountType],
value: item.totalIssue
}
})
this.option.series[0].data = arr
console.log(arr)
this.option && this.myChart.setOption(this.option)
}
},
methods: {},
mounted() {
this.getChart()
let chartDom = document.getElementById('pie')
this.myChart = echarts.init(chartDom)
this.option && this.myChart.setOption(this.option)
}
}
</script>
<style lang="scss" scoped>
.chart-box {
width: 100%;
height: 185px;
}
.chart-pie {
width: 330px;
height: 185px;
}
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!