Highcharts - Weather Symbols series
by Ben Clayton
HTML
<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>
JavaScript
var file = 'https://staging-vending.lrsdedicated.com/dyn/_pictures/weather-icons/{windex}.svg';
$(function() {
$('#container').highcharts({
chart: {
type: 'spline',
events: {
load: function() {
var s = 0; // this.series.length;
var series = this.series[s];
for (var v = 0; v < series.points.length; v++) {
var p = series.points[v];
var f = file;
f=f.replace(/\{windex\}/,p.y);
p.y = 20;
p.update({
marker: {
width: 40,
height: 40,
symbol: 'url(' + f + ')'
}
});
}
}
}
},
title: {
text: 'Monthly Average Temperature'
},
subtitle: {
text: 'Source: WorldClimate.com'
},
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
]
},
yAxis: {
title: {
text: 'Temperature'
},
labels: {
formatter: function() {
return this.value + '°';
}
}
},
tooltip: {
crosshairs: true
},
plotOptions: {
spline: {
marker: {
radius: 4,
lineColor: '#666666',
lineWidth: 1
}
}
},
series: [{
name: 'Weather symbol ',
showInLegend: false,
lineWidth: 0,
data: [15, 2, 3, 4, 5, 22, 7, 8, 9, 18, 24, 0]
}, {
name: 'London',
marker: {
symbol: 'diamond'
},
data: [1, 4.2, 5.7, 8.5, 11.9, 15.2, 17, 16.6, 14.2, 10.3, 6.6, 4.8]
}]
});
});