柱形图
const xData: ["收录信息1", 收录信息2", "收录信息3", "收录信息4"],
const legendData: [
{
name: "未读",
num: 25,
rate: "25%"
},
{
name: "已读",
num: 75,
rate: "75%"
}
]
const option = {
tooltip: {
trigger: "axis",
axisPointer: {
// 坐标轴指示器,坐标轴触发有效
type: "shadow" // 默认为直线,可选为:'line' | 'shadow'
}
},
legend: {
orient: "vertical",
top: "3%",
right: "0%",
itemWidth: 12,
itemHeight: 12,
textStyle: {
color: "rgba(0,0,0,.85)",
fontSize: 14
},
// data: legendData,
formatter: function(name) {
let num = 0;
legendData.map((i) => {
if (name == i.name) {
num = i.num;
}
});
// console.log(name)
return "{a|" + name + "}" + " " + "{b|" + num + "条" + "}" + " " + "{b|" + num + "%" + "}";
},
textStyle: {
color: "#000",
fontSize: 14,
lineHeight: 18,
rich: {
a: {
fontSize: 14,
// fontWeight: 400,
color: "#000",
lineHeight: 14
},
b: {
fontSize: 14,
// fontWeight: "bold",
color: "#737373",
lineHeight: 14
}
}
}
},
grid: {
//图表的位置
top: "25%",
left: "8%",
right: "15%",
bottom: "11%"
},
yAxis: [
{
name: "总数(条)",
nameTextStyle: {
color: "rgba(0,0,0,0.65)"
},
type: "value",
axisLabel: {
show: true,
color: "rgba(0,0,0,.45)",
interval: "auto",
formatter: "{value} "
},
axisTick: {
show: false
},
axisLine: {
show: false
},
splitLine: {
lineStyle: {
color: "#e7eaf0",
type: "dashed"
}
},
show: true
}
],
xAxis: [
{
name: "公告类型",
nameTextStyle: {
color: "rgba(0,0,0,0.65)"
},
type: "category",
axisTick: {
show: false
},
axisLine: {
lineStyle: {
color: "#e7eaf0"
}
},
axisLabel: {
interval: 0,
show: true,
textStyle: {
fontSize: 12,
color: "#000"
}
},
data: xData
}
],
series: [
{
name: "已读",
type: "bar",
stack: "sum",
barWidth: "20px",
data: hasRead,
itemStyle: {
normal: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{
offset: 1,
color: "#3295FF"
},
{
offset: 0,
color: "#81BEFF"
}
])
}
}
},
{
name: "未读",
type: "bar",
barWidth: "20px",
stack: "sum",
itemStyle: {
normal: {
barBorderRadius: [2, 2, 0, 0],
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{
offset: 1,
color: "#FFC53E"
},
{
offset: 0,
color: "#FFF88F"
}
])
}
},
data: noRead
}
]
};
饼状图
var data = [
{
name: '2018级',
value: 255,
itemStyle: {
normal: { //颜色渐变
color: new echarts.graphic.LinearGradient(
0, 0, 0, 1,
[{
offset: 0,
color: '#81BEFF',
},
{
offset: 1,
color: '#3295FF',
}
]
)
}
}
},
{
name: '2019级',
value: 103,
itemStyle: {
normal: { //颜色渐变
color: new echarts.graphic.LinearGradient(
0, 0, 0, 1,
[{
offset: 0,
color: '#FECC84',
},
{
offset: 1,
color: '#FF983E',
}
]
)
}
}
},
{
name: '2020级',
value: 80,
itemStyle: {
normal: { //颜色渐变
color: new echarts.graphic.LinearGradient(
0, 0, 0, 1,
[{
offset: 0,
color: '#70F3C2',
},
{
offset: 1,
color: '#48D69E',
}
]
)
}
}
},
{
name: '2021级',
value: 33,
itemStyle: {
normal: { //颜色渐变
color: new echarts.graphic.LinearGradient(
0, 0, 0, 1,
[{
offset: 0,
color: '#9F9BFF',
},
{
offset: 1,
color: '#826CFF',
}
]
)
}
}
}
];
const option = {
tooltip: {
trigger: 'item',
formatter: '{b} : {c} ({d}%)'
},
legend: {
orient: "vertical",
// right: "10%",
left: "60%",
top: "25%",
itemWidth: 12,
itemHeight: 12,
textStyle: {
fontSize: 14,
lineHeight: 18,
}
},
series: [
{
type: 'pie',
data: data,
label: {
show: false
},
radius: ["0%", "60%"],
center: ['30%', '50%'],
itemStyle: {
borderWidth: 2,
borderColor: "#fff"
},
}
]
};
进度条圆环
var value = {"name":"在用课程数","rat": 45,"num":5326};
option = {
backgroundColor: '#fff', //背景颜色
title: [ //标题显示
{
text: value["rat"] + '%',
subtext: value["name"],
left: "center",
top: "43%",
textStyle: {
fontSize: 50,
color: '#397EF0',
},
subtextStyle: {
fontSize: 30,
color: '#000',
}
}
],
legend:{
orient: 'vertical',
right: 200,
top: 500,
formatter: function (v) {
// console.log(v)
return v +' '+ value["rat"]+'%';
},
},
polar: { //圆环显示
radius: ['40%', '35%'],
center: ['50%', '50%'],
},
angleAxis: {
max: 100,
// clockwise: false, //刻度增长是否按顺时针
axisLine: {
show: false,
},
axisTick: {
show: false,
},
axisLabel: {
show: false,
},
splitLine: {
show: false,
},
},
radiusAxis: { //极坐标系的径向轴
type: 'category',
// show: true,
// axisLabel: {
// show: false,
// },
axisLine: {
show: false,
},
// axisTick: {
// show: false,
// },
},
series: [
{
type: 'pie',
radius: [0, '30%'],
animation : false,
itemStyle: {
normal: {
color: '#EAF1FD',
}
},
silent: true, //图形是否不响应和触发鼠标事件
label: {
show: false
},
data: [100]
},
{
name: value["name"],
type: 'bar',
roundCap: true,
// animation : false,
z: 2,
showBackground: true,
backgroundStyle: {
color: '#EAF1FD',
},
data: [value["rat"]],
coordinateSystem: 'polar',
itemStyle: {
normal: {
color: new echarts.graphic.LinearGradient(0, 0, .5, 1, [
{
offset: 0,
color: '#3295FF',
},
{
offset: 1,
color: '#81BEFF',
},
]),
},
},
},
],
};
进度条
···
option = {
grid: {
left: ‘5%’,
right: ‘5%’,
bottom: ‘5%’,
top: ‘10%’,
containLabel: true,
},
// backgroundColor: ‘#101129’,
xAxis: {
show: false,
type: ‘value’,
max: 1520,
},
yAxis: [
{
type: ‘category’,
inverse: true,
axisLabel: {
show: true,
textStyle: {
fontSize: ‘12’,
color: ‘#03fcfe’,
},
},
splitLine: {
show: false,
},
axisTick: {
show: false,
},
axisLine: {
show: false,
},
},
{
type: ‘category’,
inverse: true,
axisTick: ‘none’,
axisLine: ‘none’,
show: true,
data: [1520],
},
],
series: [
{
type: ‘bar’,
showBackground: true,
backgroundStyle: {
color: ‘rgba(231,234,240,0.45)’,
borderRadius:10
},
label:{
show:true,
position:‘right’,
padding: [3,0,0,-35],
formatter:’{@score}’,
textStyle: {
color: ‘#fff’,
fontSize: ‘12’,
},
verticalAlign: “middle”
},
itemStyle: {
normal: {
barBorderRadius: 10,
color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [
{
offset: 0,
color: ‘#4EE7F9’,
},
{
offset: 1,
color: ‘#3295FF’,
},
]),
},
},
barWidth: 20,
data: [500],
},
],
};
···
地图
const option = {
tooltip: {
trigger: 'item'
},
visualMap: {
min: 0,
max: 2500,
left: 'left',
top: 'bottom',
text: ['高', '低'], // 文本,默认为数值文本
calculable: false,
left: 10,
itemWidth: 8,
itemHeight: 60,
color: ['#7babfb', '#e1eeff']
},
series: [
{
name: '各省**分布',
type: 'map',
mapType: 'china',
roam: false,
emphasis: {
label: {
show: true,
color:"#fff",
},
itemStyle:{
areaColor:"#315b9b"
}
},
itemStyle: {
borderColor: "#fff"
},
data: [
{ name: '北京', value: Math.round(Math.random() * 1000) },
{ name: '天津', value: Math.round(Math.random() * 1000) },
{ name: '上海', value: Math.round(Math.random() * 1000) },
{ name: '重庆', value: Math.round(Math.random() * 1000) },
{ name: '河北', value: Math.round(Math.random() * 1000) },
{ name: '河南', value: Math.round(Math.random() * 1000) },
{ name: '云南', value: Math.round(Math.random() * 1000) },
{ name: '辽宁', value: Math.round(Math.random() * 1000) },
{ name: '黑龙江', value: Math.round(Math.random() * 1000) },
{ name: '湖南', value: Math.round(Math.random() * 1000) },
{ name: '安徽', value: Math.round(Math.random() * 1000) },
{ name: '山东', value: Math.round(Math.random() * 1000) },
{ name: '新疆', value: Math.round(Math.random() * 1000) },
{ name: '江苏', value: Math.round(Math.random() * 1000) },
{ name: '浙江', value: Math.round(Math.random() * 1000) },
{ name: '江西', value: Math.round(Math.random() * 1000) },
{ name: '湖北', value: Math.round(Math.random() * 1000) },
{ name: '广西', value: Math.round(Math.random() * 1000) },
{ name: '甘肃', value: Math.round(Math.random() * 1000) },
{ name: '山西', value: Math.round(Math.random() * 1000) },
{ name: '内蒙古', value: Math.round(Math.random() * 1000) },
{ name: '陕西', value: Math.round(Math.random() * 1000) },
{ name: '吉林', value: Math.round(Math.random() * 1000) },
{ name: '福建', value: Math.round(Math.random() * 1000) },
{ name: '贵州', value: Math.round(Math.random() * 1000) },
{ name: '广东', value: Math.round(Math.random() * 1000) },
{ name: '青海', value: Math.round(Math.random() * 1000) },
{ name: '西藏', value: Math.round(Math.random() * 1000) },
{ name: '四川', value: Math.round(Math.random() * 1000) },
{ name: '宁夏', value: Math.round(Math.random() * 1000) },
{ name: '海南', value: Math.round(Math.random() * 1000) },
{ name: '台湾', value: Math.round(Math.random() * 1000) },
{ name: '香港', value: Math.round(Math.random() * 1000) },
{ name: '澳门', value: Math.round(Math.random() * 1000) }
]
},
]
};