Time series, zoomable

author(s): Torstein Hønsi

by murgiaMarco

HTML

<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/data.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>
    <p class="highcharts-description">
    </p>
</figure>

CSS

.highcharts-figure, .highcharts-data-table table {
    min-width: 360px; 
    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.getJSON(
    'https://cdn.jsdelivr.net/gh/highcharts/[email protected]/samples/data/usdeur.json',
    function (data) {

        Highcharts.chart('container', {
            chart: {
                zoomType: 'x'
            },
            title: {
                text: 'Jobs'
            },
            xAxis: {
                type: 'datetime'
            },
            yAxis: {
                title: {
                    text: ''
                },
                 categories: ['Voltura', 'Soawe', 'Catasto']
            },
            legend: {
                enabled: true
            },
            plotOptions: {
                area: {
                    marker: {
                        radius: 2
                    },
                    lineWidth: 1,
                    states: {
                        hover: {
                            lineWidth: 1
                        }
                    },
                    threshold: null
                }
            },

            series: [{
        name: "Catasto",
        data: [
            [Date.UTC(1970, 10, 25), 0],
            [Date.UTC(1970, 10,  27), 0],
            [Date.UTC(1970, 10, 27), null],
            [Date.UTC(1970, 10,  29), 0],
            [Date.UTC(1970, 11,  1), 0]
        ]
    }, {
        name: "Soawe",
        data: [
            [Date.UTC(1970, 10, 26), 1],
            [Date.UTC(1970, 10,  28), 1],
            [Date.UTC(1970, 10, 28), null],
            [Date.UTC(1970, 10,  30), 1],
            [Date.UTC(1970, 11,  2), 1]
        ]
    }, {
        name: "Voltura",
        data: [
            [Date.UTC(1970, 10, 27), 2],
            [Date.UTC(1970, 10,  29), 2],
            [Date.UTC(1970, 10, 29), null],
            [Date.UTC(1970, 10,  30), 2],
            [Date.UTC(1970, 11,  3), 2]
        ]
    }],
        });
    }
);