【问题标题】:Highcharts - Column With Negative Values - Column ColorHighcharts - 具有负值的列 - 列颜色
【发布时间】:2014-01-17 17:18:30
【问题描述】:

我有一个带有负值的工作图表。 我希望将具有正值的列设为蓝色,将具有负值的列设为红色。

这是我所拥有的:

$(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,
    }]
});

});

【问题讨论】:

    标签: javascript colors highcharts


    【解决方案1】:

    由于您没有描述如何为您的数据系列填充moda,因此这里有一些一般性:

    • series.data.color 项目是可访问的。因此,在构建series.data 时,您可以根据该值计算它应该是什么颜色。
    • 您的列表中只允许一种颜色:colors: [ 'blue' ],
    • 另一个选项是设置negativeColor

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-03
      • 1970-01-01
      相关资源
      最近更新 更多