Change highchart attribute via Javascript - Javascript highcharts

Javascript examples for highcharts:Chart Configuration

Description

Change highchart attribute via Javascript

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <style id="compiled-css" type="text/css">

#container {/*  ww w. j a va 2s  .  c  o m*/
   min-width: 300px;
   max-width: 800px;
   height: 300px;
   margin: 1em auto;
}


      </style> 
   </head> 
   <body> 
      <script src="https://code.highcharts.com/highcharts.js"></script> 
      <script src="https://code.highcharts.com/modules/xrange.js"></script> 
      <script src="https://code.highcharts.com/modules/exporting.js"></script> 
      <div id="container"></div> 
      <script type="text/javascript">
var thisChart = Highcharts.chart('container', {
  chart: {
    type: 'xrange'
  },
  title: {
    text: 'Highcharts X-range'
  },
  xAxis: {
    type: 'datetime'
  },
  yAxis: {
    title: {
      text: ''
    },
    categories: ['Prototyping', 'Development', 'Testing'],
    reversed: true
  },
  series: [{
    name: 'Project 1',
    borderColor: 'gray',
    pointWidth: 20,
    partialFill: {
      fill:'#469E5A' /* default color of the filled part of the bar */
    },
    data: [{
      x: Date.UTC(2014, 10, 21),
      x2: Date.UTC(2014, 11, 2),
      y: 0,
      partialFill: 0.50,
      color: 'white' /* color of the unfilled part of the bar */
    }],
    dataLabels: {
      enabled: true
    }
  }]
});
if (thisChart.series[0].data[0].partialFill < 0.5) {
  thisChart.series[0].update({
    partialFill: {
      fill: 'red'
    }
  });
} else {
  thisChart.series[0].update({
    partialFill: {
      fill: '#469E5A'
    }
  });
}

      </script>  
   </body>
</html>

Related Tutorials