echart图-柱状图(简单的数据集)

import * as echarts from ‘echarts‘;

var app = {};

var chartDom = document.getElementById(‘main‘);
var myChart = echarts.init(chartDom);
var option;

option = {

color:[‘#4472C5‘,‘#ED7C30‘,‘#ED7C30‘], //设置每个legend的颜色(这里三个颜色对应三个legend)


legend: {},
tooltip: {},
dataset: {
source: [
[‘product‘, ‘2015‘, ‘2016‘, ‘2017‘],
[‘Matcha Latte‘, 43.3, 85.8, 93.7],
[‘Milk Tea‘, 83.1, 73.4, 55.1],
[‘Cheese Cocoa‘, 86.4, 65.2, 82.5],
[‘Walnut Brownie‘, 72.4, 53.9, 39.1]
]
},
xAxis: {type: ‘category‘},
yAxis: {},
// Declare several bar series, each will be mapped
// to a column of dataset.source by default.
series: [
{
type: ‘bar‘,
itemStyle: { //设置每个柱条的颜色
normal: {
        //这里是重点
color: function(params) {
//注意,如果颜色太少的话,后面颜色不会自动循环,最好多定义几个颜色
var colorList = [‘rgb(127,154,229)‘,‘rgb(127,154,229)‘,‘rgb(127,154,229)‘,‘rgb(127,154,229)‘];
return colorList[params.dataIndex]
}
}
}
},
{type: ‘bar‘},
{type: ‘bar‘},

]
};

option && myChart.setOption(option);

echart图-柱状图(简单的数据集)

上一篇:POST和PUT一个比较冷门的区别(自认为)


下一篇:电脑常用快捷键及常用的DOS命令