我怎样才能改变我的高图饼图的颜色? [英] How can I change the colors of my highcharts piechart?
本文介绍了我怎样才能改变我的高图饼图的颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用highcharts制作饼图,但无法为我的图表加载自定义颜色集。
I'm using highcharts to make a piechart but I'm having trouble loading a custom color set for my chart.
以下是我的代码:
<script type="text/javascript">
$(function () {
Highcharts.setOptions({
colors: ['#50B432', '#ED561B', '#DDDF00', '#24CBE5', '#64E572', '#FF9655', '#FFF263', '#6AF9C4']
});
return new Highcharts.Chart({
chart: {
renderTo: 'trailpiechart',
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
backgroundColor: "#f8f8f8",
margin: [20, 20, 20, 20]
},
credits: {
enabled: false
},
title: {
text: caption
},
tooltip: {
formatter: function () {
return this.y + ' links';
}
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: false
},
showInLegend: true
}
},
legend: {
layout: 'vertical',
floating: false,
borderRadius: 0,
borderWidth: 0
},
series: [{
type: 'pie',
name: 'Browser share',
data: data
}]
});
});
</script>
我的饼图适用于此代码,但它仅使用默认颜色托盘。
My pie chart works with this code but it only uses the default color pallet.
你如何指定一个自定义颜色集?
How do you specify a custom color set?
推荐答案
Highcharts.setOptions({
colors: ['#50B432', '#ED561B', '#DDDF00', '#24CBE5', '#64E572', '#FF9655', '#FFF263', '#6AF9C4']
});
看下面的例子
http://jsfiddle.net/8QufV/
这篇关于我怎样才能改变我的高图饼图的颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文