Need full highchart bars between months

I have created High chart to full fill my requirement as shown in attached Image and i have tried below code in fiddle example code in fiddle is as follows

https://jsfiddle.net/vsLr07ak/

Below is my code

   Highcharts.chart('container', {
 chart: {
    type: 'column'
 },
 title: {
    text: 'HISTORICAL NEWS SENTIMENT'
 },
  yAxis: {
    title: {
        text: ''
    },
     labels: {
            enabled: false
        },
    min: -100,
    max: 100,
    tickInterval: 10,
    showLastdataLabel: true,
  },
  xAxis: {
    categories: ['26. Nov', '24. Dec', '21. Jan', '18. Feb', '18. March']
  },
  credits: {
    enabled: false
  },
  series: [{
    name: null,
    data: [15, 13, 14, 17, 12]

     }, {
    name: null,
    data: [12, -12, -13, 21, 11]
  }]
  });

Html code is as

  <script src="https://code.highcharts.com/highcharts.js"></script>
  <script src="https://code.highcharts.com/modules/exporting.js">. 
  </script>
  <script src="https://code.highcharts.com/modules/export-data.js"></script>
  <div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>

but it display 2 bar for per month, I want it show as below attached image.

Can any one help me out?

and I want my chart as shown in image chart image

Answers:

Answer

Instead of category, you should use datetime xAxis type and define x values as timestamps:

series: [{
    ...,
    data: [
        [17227780000, 15],
        [18523780000, 13],
        [19819780000, 14],
        [21115780000, 17],
        [22411780000, 12],
        [23707780000, 12],
        [25003780000, -12],
        [26299780000, -13],
        [27595780000, 21],
        [28891780000, 11]
    ]
}]

Live demo: https://jsfiddle.net/BlackLabel/83us07cx/

or use pointStart and pointInterval properties:

series: [{
    pointStart: 17227780000,
    pointInterval: 1000 * 60 * 60 * 24 * 15, // 15 days
    name: null,
    color: 'red',
    negativeColor: 'blue',
    data: [15, 13, 14, 17, 12, 12, -12, -13, 21, 11]
}]

Live demo: https://jsfiddle.net/BlackLabel/sqtha8xm/


API Reference:

https://api.highcharts.com/highcharts/series.column.data

https://api.highcharts.com/highcharts/series.column.pointStart

https://api.highcharts.com/highcharts/series.column.pointInterval

https://api.highcharts.com/highcharts/series.column.negativeColor

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.