xy 2 years ago
parent bf3dfcd8b7
commit 8739edce0b

@ -406,8 +406,9 @@
// 使用刚指定的配置项和数据显示图表。
pieChart.setOption(option);
}
var barChart
function initBarChart () {
var barChart = echarts.init(document.querySelector("#bar-chart"));
barChart = echarts.init(document.querySelector("#bar-chart"));
var option = {
title: {
text: '销售额趋势'
@ -434,9 +435,65 @@
}
barChart.setOption(option)
}
function setBarChartOption (type) {
var option
if (type == 1) {
option = {
title: {
text: '销售额趋势'
},
tooltip: {},
legend: {
data: ['销量']
},
xAxis: {
data: saleList.map(function (item) {
return item.month
})
},
yAxis: {},
series: [
{
name: '销量',
type: 'bar',
data: saleList.map(function (item) {
return item.total
})
}
]
}
barChart.setOption(option)
} else {
option = {
title: {
text: '订单量趋势'
},
tooltip: {},
legend: {
data: ['订单']
},
xAxis: {
data: orderList.map(function (item) {
return item.month
})
},
yAxis: {},
series: [
{
name: '订单',
type: 'bar',
data: saleList.map(function (item) {
return item.total
})
}
]
}
barChart.setOption(option)
}
}
function typeSwitchListener () {
$("[name=type-switch]").change(function () {
console.log($(this).val())
setBarChartOption($(this).val())
})
}
(function () {

Loading…
Cancel
Save