Set color-information for each point with JSON-Data - Javascript highcharts

Javascript examples for highcharts:Chart Json Data

Description

Set color-information for each point with JSON-Data

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://code.jquery.com/jquery-1.9.1.js"></script> 
      <script type="text/javascript">
$(function () {//ww w  . j av  a2  s.  c  o  m
    // create the chart
    $('#container').highcharts('StockChart', {
        plotOptions: {
            ohlc: {
                colorByPoint: true,
            }
        },
        rangeSelector: {
            inputEnabled: $('#container').width() > 480,
            selected: 2
        },
        title: {
            text: 'AAPL Stock Price'
        },
        series: [{
            type: 'ohlc',
            name: 'AAPL Stock Price',
            data: [{
                open: 8.34,
                high: 8.56,
                low: 5.47,
                close: 6.15,
                color: 'yellow'
            }, {
                open: 8.34,
                high: 8.56,
                low: 5.47,
                close: 6.15,
                color: 'green'
            }],
            dataGrouping: {
                units: [
                    [
                        'week', // unit name
                    [1] // allowed multiples
                    ],
                    [
                        'month', [1, 2, 3, 4, 6]]
                ]
            }
        }]
    });
});

      </script> 
   </head> 
   <body> 
      <script src="https://code.highcharts.com/stock/highstock.js"></script> 
      <script src="https://code.highcharts.com/stock/modules/exporting.js"></script> 
      <div id="container" style="height: 400px; min-width: 310px"></div>  
   </body>
</html>

Related Tutorials