<div id="charweeks_mineTest" style="width: 100%; height: 306px"></div>
drawCharbrokenline(range) {
console.log(range)
let legendData, defaultDate
if (range === 'month') {
defaultDate = moment().month()
legendData = ['今年', '去年']
} else if (range === 'week') {
defaultDate = 6
legendData = ['近七周']
} else if (range === 'day') {
defaultDate = moment().weekday() - 1
legendData = ['本周', '上周']
}
const myChart = this.$echarts.init(document.getElementById('charweeks_mineTest'), null, { renderer: 'svg' })
if (this.tabletype === '1') {
myChart.resize({ width: this.echartsWidth2 })
}
const option = {
color: ['#FD864A', '#96B1D8'],
tooltip: {
trigger: 'axis'
},
axisPointer: {
lineStyle: {
color: 'rgba(253,134,74)',
opacity: 0.25,
width: 5,
type: 'solid'
}
},
legend: {
left: 'right',
data: legendData,
selectedMode: false,
icon: 'rectangle',
padding: [16, 32, 0, 0],
itemHeight: 1,
itemWidth: 9,
textStyle: {
color: '#666'
},
itemGap: 20
},
grid: {
left: '4%',
right: '8%',
bottom: '4%',
top: '2%',
containLabel: true
},
xAxis: {
type: 'category',
boundaryGap: false,
data: this.chartgroupdata.past ? this.chartgroupdata.past.xaxis : this.chartgroupdata.recent.xaxis,
axisTick: {
show: false
},
axisLine: {
lineStyle: {
color: '#ddd',
width: 1
}
},
axisLabel: {
inside: false,
textStyle: {
color: '#888888',
fontSize: '10',
itemSize: ''
},
interval: 0
}
},
yAxis: {
show: false,
type: 'value',
splitLine: {
show: false
},
axisLabel: {
formatter: function() {
return ''
}
}
},
series: [
{
name: legendData[0],
type: 'line',
smooth: true,
data: this.chartgroupdata.recent.series,
itemStyle: {
normal: {
color: '#FD864A',
lineStyle: {
width: 1
}
}
}
},
{
name: this.chartgroupdata.past ? legendData[1] : '',
type: 'line',
smooth: true,
data: this.chartgroupdata.past ? this.chartgroupdata.past.series : [],
itemStyle: {
normal: {
color: '#96B1D8',
lineStyle: {
width: 1
}
}
}
}
]
}
myChart.setOption(option, true)
myChart.dispatchAction({
type: 'showTip',
seriesIndex: 0,
dataIndex: defaultDate
})
window.addEventListener('resize', () => {
myChart.resize()
})
},