Risk Trend Chart

author(s): Amit Sinha

by Amit Sinha

HTML

<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/export-data.js"></script>
<script src="https://code.highcharts.com/modules/accessibility.js"></script>

<figure class="highcharts-figure">
    <div id="container"></div>
   
</figure>

CSS

#container {
    height: 400px; 
}

.highcharts-figure, .highcharts-data-table table {
    min-width: 310px; 
    max-width: 800px;
    margin: 1em auto;
}

.highcharts-data-table table {
    font-family: Verdana, sans-serif;
    border-collapse: collapse;
    border: 1px solid #EBEBEB;
    margin: 10px auto;
    text-align: center;
    width: 100%;
    max-width: 500px;
}
.highcharts-data-table caption {
    padding: 1em 0;
    font-size: 1.2em;
    color: #555;
}
.highcharts-data-table th {
	font-weight: 600;
    padding: 0.5em;
}
.highcharts-data-table td, .highcharts-data-table th, .highcharts-data-table caption {
    padding: 0.5em;
}
.highcharts-data-table thead tr, .highcharts-data-table tr:nth-child(even) {
    background: #f8f8f8;
}
.highcharts-data-table tr:hover {
    background: #f1f7ff;
}

JavaScript

Highcharts.chart('container', {
    chart: {
        type: 'areaspline'
    },
    title: {
        text: 'Risk Trend Chart'
    },
    legend: {

    },
    xAxis: {
        categories: [
            '2014',
            '2015',
            '2016',
            '2017',
            '2018',
            '2019',
            '2020'
        ]

    },
    yAxis: {
        title: {
            text: 'Risks'
        }
    },
    tooltip: {
        shared: false,
        useHTML: true,
        headerFormat: '<small>{point.key} - {series.name}</small><table>',
        pointFormat: '<tr><td style="color: {series.color}">Total Issue(s): </td>' +
            '<td style="text-align: right"><b>{point.y}</b></td></tr><tr><td>High</td><td>{series.options.severity.High}</td></tr><tr><td>Medium</td><td>{series.options.severity.Medium}</td></tr><tr><td>Low</td><td>{series.options.severity.Low}</td></tr><tr><td>Critical</td><td>{series.options.severity.Critical}</td></tr>',
        footerFormat: '</table>',
        valueDecimals: 0
    },
    credits: {
        enabled: false
    },
    plotOptions: {
        areaspline: {
            fillOpacity: 0.3
        },
        series: {
            point: {
                events: {
                    mouseOver: function (e) {
                        var categoryName = this.category;
                        var options = this.series.options;
                        //var severity = options.categoryName.High;

                       // alert(categoryName)
                        
                    }
                }
            }
        }
    },
    series: [{
        name: 'BU1',
        data: [3, 4, 3, 5, 4, 10, 12],
        severity: {
            High: "4",
            Medium: "5",
            Low: "6",
            Critical: "7"
        }
    }, {
        name: 'BU2',
        data: [13, 3, 4, 3, 3, 5, 4],
        high: [3, 4, 5, 6, 7, 8, 9],
        severity: {
            High: "1",
            Medium: "3",
            Low: "5",
    ...