vue 常用的 Echarts 示例
為啥要整理這一篇博文呢?其實最近做大屏做的惡心了,好多echarts圖表,樣式花里胡哨,調樣式太費勁了,然后把做過的拿下來備份一下,需要的話直接粘貼稍作修改就可以了,
echarts配置項官網:https://echarts.apache.org/zh/option.html#title
多條柱形圖

option = {
animation: false,
title: {
text: '本周主煤流系統啟動平均時長',
textAlign: 'left',
x: 'center',
y: 'top',
textStyle: {
color: 'rgba(255, 255, 255, 0.8)',
fontSize: 14
}
},
color: ['#0d81f7', '#0fb42c'],
tooltip: {},
legend: {
show: true,
top: 18,
right: 0,
data: ["主煤流系統手動啟動時長", "主煤流智能啟動時長"],
textStyle: {
color: 'rgba(255, 255, 255, 0.8)',
fontSize: 10
},
itemWidth: 10,
itemHeight: 10
},
xAxis: {
axisTick: {
show: false
},
axisLine: {
lineStyle: {
color: '#0092D5'
}
},
axisLabel: {
color: 'rgba(255, 255, 255, 0.8)'
},
data: ['2020-01','2020-02','2020-03','2020-04','2020-05','2020-06'],
},
yAxis: {
name: "(分鐘)",
nameTextStyle: {
color: 'rgba(255, 255, 255, 0.8)',
align: 'right'
},
splitLine: {
lineStyle: {
type: 'dashed',
color: '#0092D5',
opacity: 0.3
}
},
axisLine: {
show: false,
},
axisLabel: {
color: 'rgba(255, 255, 255, 0.8)'
},
},
grid: {
top: '35%',
bottom: '17%',
left: '7%',
right: '2%'
},
series: [{
name: "主煤流系統手動啟動時長",
barWidth: 15,
type: 'bar',
data: [1,2,3,4,5,6],
itemStyle: {
normal: {
label: {
show: true, //開啟顯示
position: 'insideLeft', //在上方顯示
offset: [-8, 0],
textStyle: { //數值樣式
color: '#fff',
fontSize: 10
}
},
color: new echarts.graphic.LinearGradient(0, 1, 0, 0, [{
offset: 0,
color: "#0069F5" // 0% 處的顏色
}, {
offset: 1,
color: "#35C3FF" // 100% 處的顏色
}], false)
}
},
}, {
name: "主煤流系統智能啟動時長",
barWidth: 15,
type: 'bar',
data: [2,3,4,5,6,7],
itemStyle: {
normal: {
label: {
show: true, //開啟顯示
position: 'insideRight', //在上方顯示
offset: [8, 0],
textStyle: { //數值樣式
color: '#fff',
fontSize: 10
}
},
color: new echarts.graphic.LinearGradient(0, 1, 0, 0, [{
offset: 0,
color: "#03AC32" // 0% 處的顏色
}, {
offset: 1,
color: "#69EF00" // 100% 處的顏色
}], false)
}
},
}]
};
多條曲線圖

option = {
color: ['#1890FF', '#FF7D00'],
tooltip: {},
legend: {
show: true,
top: 15,
right: 0,
align: 'left',
x: 'center',
y: 'top',
icon: 'rect',
itemHeight: 5,
itemWidth: 15,
data: ["智能配煤","非智能配煤"],
textStyle: {
color: 'rgba(255, 255, 255, 0.8)',
fontSize: 12
},
},
xAxis: {
axisTick: {
show: false
},
axisLine: {
lineStyle: {
color: '#0092D5'
}
},
axisLabel: {
color: 'rgba(255, 255, 255, 0.8)'
},
data: ['2020-01','2020-02','2020-03','2020-04','2020-05','2020-06']
},
yAxis: {
name: "(萬元)",
nameTextStyle: {
color: 'rgba(255, 255, 255, 0.8)',
align: 'right'
},
splitLine: {
lineStyle: {
type: 'dashed',
color: '#0092D5',
opacity: 0.3
}
},
axisLine: {
show: false,
},
axisLabel: {
color: 'rgba(255, 255, 255, 0.8)'
},
},
grid: {
top: '25%',
bottom: '10%',
left: '10%',
right: '2%'
},
series: [{
name: "智能配煤",
barWidth: 15,
type: 'line',
smooth: true,
data: [1,2,3,4,5,6],
}, {
name: "非智能配煤",
barWidth: 15,
type: 'line',
smooth: true,
data: [3,4,5,6,7,8],
}]
};
柱形圖配折線圖

option = {
title: {
text: '近一周全礦井產量',
textAlign: 'left',
x: 'center',
y: 'top',
textStyle: {
color: 'rgba(255, 255, 255, 0.8)',
fontSize: 14
}
},
color: ['#0d81f7', '#0fb42c', '#e97507'],
tooltip: {},
legend: {
show: true,
top: 3,
right: 0,
data: ["綜采1","綜采2", "總計"],
textStyle: {
color: 'rgba(255, 255, 255, 0.8)',
fontSize: 12
},
itemWidth: 12,
itemHeight: 12
},
xAxis: {
axisTick: {
show: false
},
axisLine: {
lineStyle: {
color: '#0092D5'
}
},
axisLabel: {
color: 'rgba(255, 255, 255, 0.8)'
},
data: ['2020-01','2020-02','2020-03','2020-04','2020-05','2020-06']
},
yAxis: {
name: "(噸)",
nameTextStyle: {
color: 'rgba(255, 255, 255, 0.8)',
align: 'right'
},
splitLine: {
lineStyle: {
type: 'dashed',
color: '#0092D5',
opacity: 0.3
}
},
axisLine: {
show: false,
},
axisLabel: {
color: 'rgba(255, 255, 255, 0.8)'
},
},
grid: {
top: '20%',
bottom: '10%',
left: '10%',
right: '2%'
},
series: [{
name: "綜采1",
barWidth: 15,
type: 'bar',
data: [1,2,3,4,5,6],
itemStyle: {
normal: {
label: {
show: true, //開啟顯示
position: 'insideLeft', //在上方顯示
offset: [-8, 0],
textStyle: { //數值樣式
color: '#fff',
fontSize: 10
}
},
color: new echarts.graphic.LinearGradient(0, 1, 0, 0, [{
offset: 0,
color: "#0069F5" // 0% 處的顏色
}, {
offset: 1,
color: "#35C3FF" // 100% 處的顏色
}], false)
}
},
}, {
name: "綜采2",
barWidth: 15,
type: 'bar',
data: [3,4,5,6,7,8],
itemStyle: {
normal: {
label: {
show: true, //開啟顯示
position: 'insideRight', //在上方顯示
offset: [8, 0],
textStyle: { //數值樣式
color: '#fff',
fontSize: 10
}
},
color: new echarts.graphic.LinearGradient(0, 1, 0, 0, [{
offset: 0,
color: "#03AC32" // 0% 處的顏色
}, {
offset: 1,
color: "#69EF00" // 100% 處的顏色
}], false)
}
},
}, {
name: "總計",
barWidth: 15,
type: 'line',
color: '#f67a03',
data: [8,9,10,11,12,13],
}]
};
柱形圖堆積

option = {
color: ['#acff02', '#fac800', '#ff7d00', '#0fb42c'],
tooltip: {
trigger: 'axis',
axisPointer: { // Use axis to trigger tooltip
type: 'shadow' // 'shadow' as default; can also be 'line' or 'shadow'
}
},
legend: {
show: true,
top: 15,
right: 0,
x: 'center',
y: 'top',
data: ["生產隊1","生產隊2","生產隊3", "總計"],
textStyle: {
color: 'rgba(255, 255, 255, 0.8)',
fontSize: 12
},
itemWidth: 12,
itemHeight: 12
},
xAxis: {
axisTick: {
show: false
},
axisLine: {
lineStyle: {
color: '#0092D5'
}
},
axisLabel: {
color: 'rgba(255, 255, 255, 0.8)'
},
data: ['2020-01','2020-02','2020-03','2020-04','2020-05','2020-06']
},
yAxis: {
name: "(噸)",
nameTextStyle: {
color: 'rgba(255, 255, 255, 0.8)',
align: 'right'
},
splitLine: {
lineStyle: {
type: 'dashed',
color: '#0092D5',
opacity: 0.3
}
},
axisLine: {
show: false,
},
axisLabel: {
color: 'rgba(255, 255, 255, 0.8)'
},
},
grid: {
top: '25%',
bottom: '10%',
left: '12%',
right: '2%'
},
series: [{
name: "生產隊1",
barWidth: 15,
type: 'bar',
stack: 'total',
emphasis: {
focus: 'series'
},
data: [1,2,3,4,5,6],
itemStyle: {
normal: {
label: {
show: true, //開啟顯示
position: 'insideRight', //在上方顯示
offset: [-8, 0],
textStyle: { //數值樣式
color: '#fff',
fontSize: 10
}
},
}
},
},
{
name: "生產隊2",
barWidth: 15,
type: 'bar',
stack: 'total',
emphasis: {
focus: 'series'
},
data:[2,3,4,5,6,7],
itemStyle: {
normal: {
label: {
show: true, //開啟顯示
position: 'insideRight', //在上方顯示
offset: [-8, 0],
textStyle: { //數值樣式
color: '#fff',
fontSize: 10,
}
},
}
},
},
{
name: "生產隊3",
barWidth: 15,
type: 'bar',
stack: 'total',
emphasis: {
focus: 'series'
},
data:[5,6,7,8,9,10],
itemStyle: {
normal: {
label: {
show: true, //開啟顯示
position: 'insideRight', //在上方顯示
offset: [-8, 0],
textStyle: { //數值樣式
color: '#fff',
fontSize: 10
}
},
}
},
}, {
name: '總計',
barWidth: 15,
type: 'bar',
data: [21,22,23,34,25,25],
itemStyle: {
normal: {
label: {
show: true, //開啟顯示
position: 'insideLeft', //在上方顯示
offset: [8, 0],
textStyle: { //數值樣式
color: '#fff',
fontSize: 10
}
},
color: new echarts.graphic.LinearGradient(0, 1, 0, 0, [{
offset: 0,
color: "#0069F5" // 0% 處的顏色
}, {
offset: 1,
color: "#35C3FF" // 100% 處的顏色
}], false)
}
},
}]
};
餅圖

option = {
title: {
text: '各生產隊工效',
textAlign: 'left',
x: 'center',
y: 'top',
top: '7%',
textStyle: {
color: 'rgba(255, 255, 255, 0.8)',
fontSize: 12
}
},
tooltip: {},
legend: {
orient: 'vertical',
top: '50%',
left: '15%',
textStyle: {
color: 'rgba(255, 255, 255, 0.8)',
fontSize: 12
},
itemWidth: 12,
itemHeight: 12
},
grid: {
top: '20%',
bottom: '10%',
left: '10%',
right: '10%'
},
series: [{
name: '功效',
type: 'pie',
radius: [15, 70],
center: ['68%', '60%'],
// roseType: 'area',
itemStyle: {
borderRadius: 2
},
label: {
position: 'inside',
formatter: '{c}噸/人天',
fontWeight: 600,
color: '#fff'
},
data: [{
value:12,
name: "生產隊1"
},{
value:34,
name: "生產隊2"
},{
value:23,
name: "生產隊3"
}]
}]
};
進度環形圖

option = {
color: ['#414f5b', '#1890ff'],
series: [
{
name: '任務進度',
type: 'pie',
radius: ['75%', '100%'],
avoidLabelOverlap: false,
hoverAnimation: false,
labelLine: {
normal: {
show: false
}
},
data: [{
value: 25,
label: {
normal: {
show: false,
}
}
}, { // 資料值
value: 75,
// 資料項名稱
name: "采煤機開機率",
//該資料項是否被選中
selected: false,
// 單個扇區的標簽配置
label: {
// 是顯示標簽
show: true,
position: 'center',
fontSize: 14,
color: '#fff',
lineHeight: 15,
formatter: '\n{b}\n\n ' + `{a| {c} }` + '\n\n%',
rich: {
a: {
color: '#1890ff',
fontSize: 30,
fontWeight: 600,
}
}
},
}]
}
]
};
雷達圖

option = {
color: ['#fa0145', '#02f8f9'],
tooltip: {
show: true
},
radar: {
nameGap: 7,
axisLine: {
lineStyle: {
color: '#0781c0',
type: 'dashed'
}
},
name: {
color: '#fff'
},
splitLine: {
lineStyle: {
color: '#0781c0',
type: 'dashed'
}
},
splitArea: {
show: false,
areaStyle: {
color: 'rgba(255,0,0,0)', // 圖表背景的顏色
},
},
indicator: ["人員","設備","環境","管理"]
},
series: [{
name: '',
type: 'radar',
data: [
{
value: //[4200, 3000, 20000, 35000],
name: '',
areaStyle: {
color: '#fa0145',
opacity: 0.1,
},
itemStyle: { // 折線拐點標志的樣式,
normal: { // 普通狀態時的樣式
lineStyle: {
width: 1
},
opacity: 0.2
},
emphasis: { // 高亮時的樣式
lineStyle: {
width: 5
},
opacity: 1
}
},
},
{
value: [6200, 2000, 30000, 25000],
name: '風險評估',
areaStyle: {
color: '#02f8f9',
opacity: 0.1,
},
itemStyle: { // 折線拐點標志的樣式,
normal: { // 普通狀態時的樣式
lineStyle: {
width: 1
},
opacity: 0.2
},
emphasis: { // 高亮時的樣式
lineStyle: {
width: 5
},
opacity: 1
}
},
}
]
}]
};
標線、柱形圖重疊
這個是臨時補充的一個,因為有的報表需要展示一根標準線,比如達到多少是標準,在圖表上顯示標準是多少需要在x軸或者是y軸畫一條標準線,
另一個就是有的設計師設計兩條柱形圖相交在一起,這里也配置了一下,根據實際情況自己稍微修改就可以了,

option = {
title: {
text: 'World Population'
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow'
}
},
legend: {},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis: {
type: 'value',
boundaryGap: [0, 0.01]
},
yAxis: {
type: 'category',
data: ['Brazil', 'Indonesia', 'USA', 'India', 'China', 'World']
},
series:[
{
name: '2011',
type: 'bar',
data: [18203, 23489, 29034, 104970, 131744, 630230],
barGap: '-50%',
z: 3,
markLine: {
data: [{
name: 'X 軸值為 100 的豎直線',
xAxis: 123456
}],
silent: true,
symbolSize: 'minorSplitLine',
}
},
{
name: '2012',
type: 'bar',
data: [19325, 23438, 31000, 121594, 134141, 681807]
}
]
};
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/308808.html
標籤:其他
上一篇:了解一個特定的遞回演算法
