javascript - Highcharts - Column With Negative Values - Column Color - Stack Overflow

I have a working chart with negative values.I would like to have columns with positive values to be bl

I have a working chart with negative values. I would like to have columns with positive values to be blue and columsn with negative vlaues to be red.

Here is what I have:

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

});

I have a working chart with negative values. I would like to have columns with positive values to be blue and columsn with negative vlaues to be red.

Here is what I have:

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

});

Share Improve this question asked Dec 30, 2013 at 19:21 user1621308user1621308 1723 silver badges15 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

Since you are not describing how you are populating moda for your data series here are some generalities:

  • The series.data.color item is accessible. So, when building the series.data up you could calculate what color it should be based on the value.
  • You are only allowing one color in your list: colors: [ 'blue' ],
  • Another option is to set the negativeColor.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744200283a4562846.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信