Use xy chart to combine line chart and column chart - Javascript highcharts

Javascript examples for highcharts:Line Chart

Description

Use xy chart to combine line chart and column chart

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.10.1.js"></script> 
      <script type="text/javascript">
    $(window).load(function(){//from  w ww. jav  a  2 s  .  c om
$(function () {
        $('#container').highcharts({
            chart: {
                zoomType: 'xy'
            },
            title: {
                text: null
            },
            xAxis: [{
                categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
                    'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
            }],
            yAxis: [{ // Primary yAxis
                labels: {
                    format: '{value}?m',
                    style: {
                        color: '#666666'
                    }
                },
                title: {
                    text: null,
                    style: {
                        color: '#45C2C5'
                    }
                }
            }],
            tooltip: {
                shared: true
            },
            legend: {
                layout: 'vertical',
                align: 'left',
                x: 120,
                verticalAlign: 'top',
                y: 170,
                floating: true,
                backgroundColor: '#FFFFFF'
            },
            series: [{
                name: 'Budget',
                color: '#4A3950',
                type: 'column',
                yAxis: 0,
                data: [23.9, 20.9, 22.7, 23.8, 24.7, 23.3, 27.2, 23.4, 26.8, 27.5, 25.5, 26.5],
                tooltip: {
                    valueSuffix: '?m'
                }
            }, {
                name: 'Actual',
                color: '#45C2C5',
                type: 'spline',
                data: [24.5, 22.5, 30 ],
                tooltip: {
                    valueSuffix: '?m'
                },
            marker: {
                   lineWidth: 2,
                   lineColor: Highcharts.getOptions().colors[3],
                   fillColor: 'white'
                }
            }]
        });
    });
    });

      </script> 
   </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>  
   </body>
</html>

Related Tutorials