1

I receive both negative and positive values from an api, which I feed into my column chart.

http://jsfiddle.net/jn7Lvoz4/3/

The problem is that I don't want my negative values to be displayed below the x-axis, but above, just like the positive values. I still want to keep the values negative though, so that I can color them red and pass them into a function when the values are hovered. (I am just outputting them with a console.log in my fiddle, but I think you get the idea.)

I found a solution to this problem right here, but they solve it by using H.seriesTypes.column. Hightcharts.seriesTypes doesn't seem to exist in angular-highcharts so this sadly didn't really help me.

Does anybody know how I could achieve this?

SadHippo123
  • 177
  • 3
  • 12
  • Hi @SadHippo123, I think that you should be able to use the solution from a link that you have provided. Could you elaborate on this problem? – ppotaczek Dec 20 '19 at 11:46

1 Answers1

2

I think this is what you're going for http://jsfiddle.net/fq2u76hg/2/.

The main change was adding a map function to convert each [x, y] to an object.

function mapData([x, y]) {
    return {
        name: x,
        x: x,
        y: Math.abs(y),
        actualY: y,
        color: y >= 0 ? '#63CCA6' : '#E6496F'
    }
}

Then Highcarts will automatically use the absolute y value and the color provided for each data element and in your listener function you can grab the 'actualY' value instead of 'y'.

Frederick
  • 832
  • 6
  • 14