echarts之玫瑰图(底部有图)

var data = [
[
"溃坝 13",
57
],
[
"滑坡 2",
10
],
[
"格及未建 2",
10
],
[
"洪水浸顶 4",
24
]
];
var myChart = echarts.init(document.getElementById('main'));
var sData = [];
var lData = [];
$.each(data, function (i, v) {
var json = {};
json.name = v[0];
json.value = v[1];
sData.push(json);
lData.push(v[0]);
});
option = null;
option = {
/*tooltip : {
trigger: 'item',
formatter: "{c}"
},*/
legend: {
orient: 'vertical',
x: 'center',
y: 'bottom',
data: lData,
textStyle: {
color: '#ff0',
rich: {
a: {
borderColor: '#ff0',
borderWidth: [0, 1, 0, 1]
},

}
},
itemGap: 20,
top: "75%",
},
calculable: true,
series: [{
type: 'pie',
radius: [20, 80],
center: ['50%', '40%'],
// roseType : 'area',
roseType: 'radius',
data: sData,
/* itemStyle: {
normal:{
color:new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
offset: 0, color: 'red'},
{offset: 1, color: 'blue' }
], false)}
}*/
itemStyle: {
normal: {
color: function (params) {
var colorList = [
['#EED2EE', '#E066FF', '#CD00CD'],
['#63D360', '#089C04', '#1FCD1B'],
['#87CEEB', '#54FF9F', '#43CD80'],
['#87CEFF', '#4F94CD', '#1C86EE']
];
return new echarts.graphic.LinearGradient(0, 1, 0, 0, [
{offset: 0, color: colorList[params.dataIndex][0]},
{offset: 0.5, color: colorList[params.dataIndex][1]},
{offset: 1, color: colorList[params.dataIndex][2]}
])
}
}
},
label: {
normal: {
// formatter: '{c}',
formatter: function (v) {
return v.data.name
},
color: '#fff'
}
}
}]
};
myChart.setOption(option, true);


posted @ 2018-07-18 10:14  纵使上线又怎样  阅读(6420)  评论(0编辑  收藏  举报