Advanced timeline
author(s): Torstein Hønsi
by jrdiaz
HTML
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="https://code.highcharts.com/stock/highstock.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>
<div id="container"></div>
CSS
#container, .highcharts-data-table table {
min-width: 310px;
max-width: 900px;
margin: 1em auto;
}
#container {
height: 480px;
}
.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
/**
* This is an advanced demo of setting up Highcharts with the flags feature borrowed from Highstock.
* It also shows custom graphics drawn in the chart area on chart load.
*/
/**
* Fires on chart load, called from the chart.events.load option.
*/
function onChartLoad() {
var centerX = 140,
centerY = 110,
path = [],
angle,
radius,
badgeColor = Highcharts.color(Highcharts.getOptions().colors[0]).brighten(-0.2).get(),
spike,
empImage,
big5,
label,
left,
right,
years,
renderer;
if (this.chartWidth < 530) {
return;
}
// Prepare mouseover
renderer = this.renderer;
if (renderer.defs) { // is SVG
$.each(this.get('employees').points, function () {
var point = this,
pattern;
if (point.image) {
pattern = renderer.createElement('pattern').attr({
id: 'pattern-' + point.image,
patternUnits: 'userSpaceOnUse',
width: 400,
height: 400
}).add(renderer.defs);
renderer.image(
'https://www.highcharts.com/images/employees2014/' + point.image + '.jpg',
centerX - 80,
centerY - 80,
160,
213
).add(pattern);
Highcharts.addEvent(point, 'mouseOver', function () {
empImage
.attr({
fill: 'url(#pattern-' + point.image + ')'
})
.animate({ opacity: 1 }, { duration: 500 });
});
Highcharts.addEvent(point, 'mouseOut', function () {
empImage.animate({ opacity: 0 }, { duration: 500 });
});
}
});
}
}
var options = {
chart: {
...