Commit d7aadb22 by 王志慧

Merge branch 'dev_v1.0.0' of http://192.168.3.233:8090/gh/data-view into dev_v1.0.0

2 parents ee4ca92c 30135bb4
<template> <template>
<div class="line-box"> <div class="line-box">
<p v-if="title" class="title">{{ title }}</p> <div id="echarts-line" class="echarts-line"></div>
<div id="line-chart" class="line-chart"></div>
<div class="rank-box"> <div class="rank-box">
<div> <div>
<p :class="[ 'rank-title', rankFlag == 'first' ? 'rank-active' : '' ]" @click="handleRankChange('first')">前5{{ storeOrBrandTxt }}</p> <p :class="[ 'rank-title', rankFlag == 'first' ? 'rank-active' : '' ]" @click="handleRankChange('first')">前5{{ storeOrBrandTxt }}</p>
...@@ -13,9 +12,9 @@ ...@@ -13,9 +12,9 @@
<script> <script>
import * as echarts from 'echarts' import * as echarts from 'echarts'
import options from './lineOptions' import getLineOptions from './lineOptions'
export default { export default {
name: 'LineChart', name: 'EchartLine',
props: { props: {
// height: { // height: {
...@@ -26,10 +25,6 @@ export default { ...@@ -26,10 +25,6 @@ export default {
type: String, type: String,
default: '' default: ''
}, },
title: {
type: String,
default: ''
},
storeOrBrandTxt: { storeOrBrandTxt: {
type: String, type: String,
default: '门店' default: '门店'
...@@ -38,15 +33,25 @@ export default { ...@@ -38,15 +33,25 @@ export default {
data() { data() {
return { return {
// first,last
rankFlag: 'first', rankFlag: 'first',
lineOptions: JSON.parse(JSON.stringify(options)) lineOptions: [],
xAxisLabel: {
monthList: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月']
},
echartsLine: '',
dataList: [1, 2, 3, 10, 5, 2, 7, 8, 9, 10, 11, 12],
moveAttr: {
speed: 900,
seriesIndex: 0,
dataIndex: -1
},
timer: null
// chartHeight: this.height // chartHeight: this.height
} }
}, },
created() { created() {
this.lineOptions = getLineOptions({ axisLabelColor: this.axisLabelColor })
}, },
mounted() { mounted() {
...@@ -54,10 +59,50 @@ export default { ...@@ -54,10 +59,50 @@ export default {
}, },
methods: { methods: {
dealxAxisLabel() {
this.lineOptions.xAxis.data = this.xAxisLabel.monthList
},
autoMove() {
clearTimeout(this.timer)
this.timer = setTimeout(() => {
this.moveAttr.dataIndex = this.moveAttr.dataIndex + 1
if (this.moveAttr.dataIndex === this.dataList.length) {
this.moveAttr.dataIndex = 0
}
this.moveAction()
this.autoMove()
}, this.moveAttr.speed)
},
chartBindEvent() {
this.echartsLine.on('click', () => {
// clearTimeout(this.timer)
console.log('???????')
})
},
moveAction(type) {
this.echartsLine.dispatchAction({
type: type || 'showTip',
seriesIndex: this.moveAttr.seriesIndex,
dataIndex: this.moveAttr.dataIndex
})
},
drawLine() { drawLine() {
var lineDom = document.getElementById('line-chart') // var lineDom = document.getElementById('echarts-line')
var lineChart = echarts.init(lineDom) // this.echartsLine = echarts.init(lineDom)
lineChart.setOption(this.lineOptions) this.echartsLine = echarts.init(document.getElementById('echarts-line'))
this.dealxAxisLabel()
this.lineOptions.series[0].data = this.dataList
this.echartsLine.setOption(this.lineOptions)
console.log(this.echartsLine)
this.chartBindEvent()
// this.autoMove()
}, },
handleRankChange(value) { handleRankChange(value) {
...@@ -73,25 +118,25 @@ p { ...@@ -73,25 +118,25 @@ p {
} }
.line-box { .line-box {
color: #ffffff; color: #ffffff;
padding: 4px 8px; // padding: 4px 8px;
font-size: 0.75em; font-size: 0.75em;
.title { .echarts-line {
height: 17px; width: 100%;
color: #e8e8e8; height: calc(100% - 3.1vh - 4.6vh);
}
.line-chart {
height: calc(100% - 25px - 30px);
} }
.rank-box { .rank-box {
box-sizing: border-box;
display: flex; display: flex;
height: 30px; height: 4.6vh;
padding: 0.48vh 0.87vh;
border-top: 1px solid #373739;
.rank-title { .rank-title {
box-sizing: border-box; box-sizing: border-box;
font-size: 0.6em; font-size: 0.6em;
background: #353535; background: #353535;
padding: 1px 5px; padding: 1px 5px;
height: 15px; height: 1.83vh;
line-height: 15px; line-height: 1.83vh;
opacity: 0.7; opacity: 0.7;
cursor: pointer; cursor: pointer;
} }
......
var lineOptions = { function getLineOptions(obj) {
visualMap: [ // const { axisLabelColor } = obj
{ console.log(obj)
show: false, var lineOptions = {
type: 'continuous', tooltip: {
seriesIndex: 0, trigger: 'axis',
min: 0, formatter: ''
max: 400
}, },
{ grid: {
show: false, left: '3%',
type: 'continuous', right: '4%',
seriesIndex: 1, top: '10%',
dimension: 0, bottom: '10%',
min: 0, containLabel: true
max: 0
}
],
title: [
{
left: 'center',
text: 'Gradient along the y axis'
}, },
{ xAxis: {
top: '55%', type: 'category',
left: 'center', axisLabel: {
text: 'Gradient along the x axis' color: '#606266',
} // color: axisLabelColor ? (value, index) => axisLabelColor(value, index) : '#606266',
], fontSize: '0.8em'
tooltip: {
trigger: 'axis'
}, },
xAxis: [
{
data: [] data: []
}, },
{ yAxis: {
data: [], type: 'value',
gridIndex: 1 splitLine: {
lineStyle: {
color: '#606266'
} }
],
yAxis: [
{},
{
gridIndex: 1
} }
],
grid: [
{
bottom: '60%'
}, },
{
top: '60%'
}
],
series: [ series: [
{ {
type: 'line', type: 'line',
showSymbol: false, itemStyle: {
data: [] color: '#F5AA01'
},
// 节点,平滑曲线
symbol: 'none',
smooth: true,
// 折线背景色
areaStyle: {
color: {
type: 'linear',
x: 0,
y: 0,
x2: 0,
y2: 1,
colorStops: [
{
offset: 0,
color: 'rgba(254, 84, 0, 0.6)'
}, },
{ {
type: 'line', offset: 1,
showSymbol: false, color: 'rgba(254, 84, 0, 0.05)'
data: [],
xAxisIndex: 1,
yAxisIndex: 1
} }
] ]
}
},
data: []
}
]
}
return lineOptions
} }
export default lineOptions export default getLineOptions
...@@ -8,11 +8,18 @@ ...@@ -8,11 +8,18 @@
<template> <template>
<div> <div>
<div class="title">售后档案客户</div> <div class="title">售后档案客户</div>
<echart-line :height="height"></echart-line>
</div> </div>
</template> </template>
<script> <script>
export default { export default {
name: 'File' name: 'File',
props: {
height: {
type: String,
default: '19.8vh'
}
}
} }
</script> </script>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!