CSS Style applied to a series in Highchart - Javascript highcharts

Javascript examples for highcharts:Chart Series

Description

CSS Style applied to a series in Highchart

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> 
      <style id="compiled-css" type="text/css">

g.highcharts-series:nth-child(3) > path:first-child {
   stroke: #e98300 !important;//from w  w w  . jav  a  2s .  c om
}
g.highcharts-series:nth-child(1) > path:first-child {
   stroke: #7ab800 !important;
}


      </style> 
      <script type="text/javascript">
$(function () {
    $('#container').highcharts({
        title: {
            text: 'Monthly Average Temperature',
            x: -20 //center
        },
        subtitle: {
            text: 'Source: WorldClimate.com',
            x: -20
        },
        xAxis: {
            categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
                'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
        },
        yAxis: {
            title: {
                text: 'Temperature (?C)'
            },
            plotLines: [{
                value: 0,
                width: 1,
                color: '#808080'
            }]
        },
        tooltip: {
            valueSuffix: '?C',
            enabled: false
        },
        legend: {
            layout: 'vertical',
            align: 'right',
            verticalAlign: 'middle',
            borderWidth: 0
        },
        series: [{
            name: "Cost Estimate Today",
            cls: 'costToday',
            data: [1, 2, 3],
            pointPadding: -0.05
        }, {
            name: "Cost Estimate Yesterday",
            cls: 'costYesterday',
            data: [10, 5, 8],
            pointPadding: -0.05,
            dashStyle: 'dash'
        }]
    });
});

      </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