Commit d1b555e2 by chenwq

折线图

1 parent fe6c0a41
<template>
<div class="line-box">
<p v-if="title" class="title">{{ title }}</p>
<div id="line-chart" class="line-chart"></div>
<div class="rank-box">
<div>
<p :class="[ 'rank-title', rankFlag == 'first' ? 'rank-active' : '' ]" @click="handleRankChange('first')">前5{{ storeOrBrandTxt }}</p>
<p :class="[ 'rank-title', rankFlag == 'last' ? 'rank-active' : '' ]" @click="handleRankChange('last')">后5{{ storeOrBrandTxt }}</p>
</div>
</div>
</div>
</template>
<script>
import * as echarts from 'echarts'
import options from './lineOptions'
export default {
name: 'LineChart',
props: {
// height: {
// type: String,
// default: '19.8vh'
// },
apiName: {
type: String,
default: ''
},
title: {
type: String,
default: ''
},
storeOrBrandTxt: {
type: String,
default: '门店'
}
},
data() {
return {
// first,last
rankFlag: 'first',
lineOptions: JSON.parse(JSON.stringify(options))
// chartHeight: this.height
}
},
created() {
},
mounted() {
this.drawLine()
},
methods: {
drawLine() {
var lineDom = document.getElementById('line-chart')
var lineChart = echarts.init(lineDom)
lineChart.setOption(this.lineOptions)
},
handleRankChange(value) {
this.rankFlag = value
}
}
}
</script>
<style lang="scss" scoped>
p {
margin: 0 0;
}
.line-box {
color: #ffffff;
padding: 4px 8px;
font-size: 0.75em;
.title {
height: 17px;
color: #e8e8e8;
}
.line-chart {
height: calc(100% - 25px - 30px);
}
.rank-box {
display: flex;
height: 30px;
.rank-title {
box-sizing: border-box;
font-size: 0.6em;
background: #353535;
padding: 1px 5px;
height: 15px;
line-height: 15px;
opacity: 0.7;
cursor: pointer;
}
.rank-active {
opacity: 1;
color: #ffffff;
background: #eb6001;
}
}
}
</style>
var lineOptions = {
visualMap: [
{
show: false,
type: 'continuous',
seriesIndex: 0,
min: 0,
max: 400
},
{
show: false,
type: 'continuous',
seriesIndex: 1,
dimension: 0,
min: 0,
max: 0
}
],
title: [
{
left: 'center',
text: 'Gradient along the y axis'
},
{
top: '55%',
left: 'center',
text: 'Gradient along the x axis'
}
],
tooltip: {
trigger: 'axis'
},
xAxis: [
{
data: []
},
{
data: [],
gridIndex: 1
}
],
yAxis: [
{},
{
gridIndex: 1
}
],
grid: [
{
bottom: '60%'
},
{
top: '60%'
}
],
series: [
{
type: 'line',
showSymbol: false,
data: []
},
{
type: 'line',
showSymbol: false,
data: [],
xAxisIndex: 1,
yAxisIndex: 1
}
]
}
export default lineOptions
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!