activityRankBar(type) {
let xAxis = [];
let yData = [];
let current = [];
let name = "";
let myChart = "";
if (type == "partyActivity") {
current = this.PartyActivityRank;
name = "黨組織黨建活動排名";
myChart = echarts.init(_document.getElementById("partyActivityRank"));
} else {
current = this.VolunteerActivityRank;
name = "黨組織志願活動排名";
myChart = echarts.init(
_document.getElementById("volunteerActivityRank")
);
}
for (let i = 0; i < current.length; i++) {
xAxis.push(current[i].text);
yData.push(current[i].count);
}
let option = {
tooltip: {
trigger: "axis",
axisPointer: {
type: "shadow"
}
},
grid: {
left: "3%",
right: "4%",
bottom: "2%",
top: "3%",
containLabel: true
},
xAxis: {
axisLine: {
show: false
},
axisTick: {
show: false
},
splitLine: {
show: false //不顯示分割線
},
minInterval: 1,
show: false
},
yAxis: {
type: "category",
data: xAxis,
inverse: true,//倒敘
splitLine: {
show: false
},
axisLine: {
show: false
},
axisTick: {
show: false
},
axisLabel: {
interval: 0
},
offset: 10,
nameTextStyle: {
fontSize: 12
}
},
series: [
{
name: "數量",
type: "bar",
data: yData,
barWidth: 14,
barGap: 10,
smooth: true,
label: {
normal: {
show: true,
position: "right",
offset: [5, -2],
textStyle: {
color: "black",
fontSize: 12
}
}
},
itemStyle: {
normal: {
color: function(params) {
var colorList = ["#9b0b11", "#777777"];
var index = 0;
if (params.dataIndex > 2) {
index = 1;
}
return colorList[index];//前三列與之后列顏色區分
}
}
}
}
]
};
myChart.setOption(option);
}
如圖: