chart data formatter - Javascript highcharts

Javascript examples for highcharts:Chart Data

Description

chart data formatter

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>Highcharts Demo</title> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
   </head> 
   <body> 
      <script src="https://code.highcharts.com/highcharts.js"></script> 
      <script src="https://code.highcharts.com/modules/exporting.js"></script> 
      <div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div> 
      <script type="text/javascript">
//First array/*from w  w  w.  j a v  a2  s.  c  o m*/
var dates = ["201401", "201401", "201401", "201402", "201402", "201402"];
//Second array
var krc = ["2.22", "3.67", "3.03", "2.22", "3.03", "3.67"].map(Number);
//Last array
var pB = ["2", "4", "3", "2", "3", "4"].map(Number);
Highcharts.chart('container', {
  chart: {
    type: 'spline'
  },
  title: {
    text: " Dates",
    x: -20 //center
  },
  subtitle: {
    text: '',
    x: -20
  },
  xAxis: {
    categories: dates
  },
  yAxis: {
    min: 1,
    title: {
      text: 'Krc Values'
    },
    plotLines: [{
      value: 0,
      width: 1,
      color: '#000000'
    }]
  },
  tooltip: {
    valueDecimals: 2
  },
  series: [{
      name: 'Krc Values',
      color: '#F7A35C',
      data: krc
    }, {
      name: 'pB Values',
      color: '#A7A35C',
      data: pB
    }]
});

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

Related Tutorials