John travolta
Posts: 1
Joined: Thu Feb 16, 2023 5:37 pm

How to set start position for negative column chart ?

Is it possible in HighchartsJS to set the starting position for negative values, for example 200. So that the chart less than 200 is drawn down. By default position starts from zero.
I need to draw chart like this:
Image

https://codepen.io/4zhar12/pen/poOJvQb?editors=0010

If i set min max/value it does not work correct, you can watch example on codepen.
Please, can you exmplain me how can i draw the chart ?

Code: Select all

Highcharts.chart('container', {
  chart: {
    type: 'column'
  },
  title: {
    text: 'Column chart with negative values'
  },
  xAxis: {
    categories: ['Apples', 'Oranges', 'Pears', 'Grapes', 'Bananas']
  },
//   it does not work
  // yAxis:[{
  //   min:30
  // }],
  credits: {
    enabled: false
  },
  series: [{
    name: 'John',
    data: [50, 30, 40, 70, 20]
  }, {
    name: 'Jane',
    data: [20, -20, -30, 20, 10]
  }, {
    name: 'Joe',
    data: [30, 40, 40, -20, 50]
  }]
});
jakub.j
Posts: 1091
Joined: Tue Jan 24, 2023 11:14 am

Re: How to set start position for negative column chart ?

Welcome to our forum and thanks for contacting us with your question!

The min/max values won't work for you because they refer to the values on whole yAxis, from top to bottom.
In your case, you need to use series.threshold which allows you to set base level for your series.
I prepared a demo for you using it.

Demo: https://jsfiddle.net/BlackLabel/osynhLtu/
API: https://api.highcharts.com/highcharts/p ... .threshold

Let me know if that was what you were looking for!

Regards
Jakub

Return to “Highcharts Stock”