柱状图:
option = {
legend: {
data: ['系列1', '系列2', '系列3']
},
xAxis: {
type: 'category',
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
},
yAxis: {
type: 'value'
},
series: [
{
name: '系列1',
type: 'bar',
data: [120, 200, 150, 80, 70, 110, 130],
itemStyle: {
color: 'red' // 定义系列1的颜色
}
},
{
name: '系列2',
type: 'bar',
data: [60, 90, 200, 30, 90, 120, 150],
itemStyle: {
color: 'blue' // 定义系列2的颜色
}
},]
}
饼状图:
option = {
legend: {
data: ['类别1', '类别2', '类别3', '类别4', '类别5']
},
series: [
{
name: '访问来源',
type: 'pie',
radius: '55%',
data: [
{value: 335, name: '类别1', itemStyle: {color: 'red'}},
{value: 310, name: '类别2', itemStyle: {color: 'blue'}},
{value: 234, name: '类别3', itemStyle: {color: 'green'}},
{value: 135, name: '类别4', itemStyle: {color: 'yellow'}},
{value: 1548, name: '类别5', itemStyle: {color: 'purple'}}
],
emphasis: {
itemStyle: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
}
}
]
};