Javascript Highcharts-带负值的列-列颜色
我有一个负值的工作图表。 我想让正值的列为蓝色,负值的列为红色 以下是我所拥有的:Javascript Highcharts-带负值的列-列颜色,javascript,colors,highcharts,Javascript,Colors,Highcharts,我有一个负值的工作图表。 我想让正值的列为蓝色,负值的列为红色 以下是我所拥有的: $(function () { // Radialize the colors Highcharts.getOptions().colors = Highcharts.map(Highcharts.getOptions().colors, function(color) { return { radialGradient: { cx: 0.5, cy: 0.3, r
$(function () {
// Radialize the colors
Highcharts.getOptions().colors = Highcharts.map(Highcharts.getOptions().colors, function(color) {
return {
radialGradient: { cx: 0.5, cy: 0.3, r: 0.7 },
stops: [
[0, color],
[1, Highcharts.Color(color).brighten(-0.3).get('rgb')] // darken
]
};
});
// Build the chart
$('#moda').highcharts({
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false
},
colors: [
'blue'
],
title: {
text: ''
},
xAxis: {
categories: moda,
},
tooltip: {
pointFormat: '{series.name}: <b>{point.y}</b>',
percentageDecimals: 0
},
series: [{
type: 'column',
data: moda,
}]
});
$(函数(){
//使颜色呈放射状
Highcharts.getOptions().colors=Highcharts.map(Highcharts.getOptions().colors,函数(color){
返回{
径向梯度:{cx:0.5,cy:0.3,r:0.7},
停止:[
[0,颜色],
[1,Highcharts.Color(Color).brighlight(-0.3).get('rgb')]//darken
]
};
});
//绘制图表
$(#moda')。高图({
图表:{
plotBackgroundColor:null,
plotBorderWidth:null,
plotShadow:false
},
颜色:[
“蓝色”
],
标题:{
文本:“”
},
xAxis:{
类别:moda,,
},
工具提示:{
pointFormat:“{series.name}:{point.y}”,
百分比小数:0
},
系列:[{
键入:“列”,
资料来源:moda,
}]
});
})) 由于您没有描述如何为您的数据系列填充
moda
,因此这里有一些概括:
- 该项目是可访问的。因此,在构建
时,您可以根据该值计算它应该是什么颜色系列.data
- 列表中只允许使用一种颜色:
colors:['blue',
- 另一个选项是设置