$(function () { var seriesColor = new Array(); var is_set = 0; $('#core_used').highcharts({ chart: { backgroundColor:'rgba(255, 255, 255, 0)', type: 'column', animation: { duration: 500 }, marginTop: 10, marginBottom: 15, marginLeft: 5, marginRight: 5 }, title: { text: null }, subtitle: { text: null }, legend: { enabled: false }, xAxis: { type: 'category', tickWidth: 0, tickInterval: 1, gridLineWidth: 0, title: { enabled: false }, labels: { align: 'center', x: 0, y: 9 }, }, yAxis: { min: 0, tickAmount: 4, labels: false, title: { text: null }, showFirstLabel: false }, plotOptions: { series: { borderWidth: 0, pointWidth: 20, dataLabels: { enabled: true, format: '
{y}
' } } }, credits: { enabled: false }, navigation: { buttonOptions: { enabled: false } }, tooltip: { pointFormat: '{point.y}%', backgroundColor: { linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 }, stops: [ [0, 'rgba(96, 96, 96, .8)'], [1, 'rgba(16, 16, 16, .8)'] ] }, borderWidth: 0, style: { color: '#FFF' } }, series: [{ name: 'Load', data: [], colorByPoint: true, colors: seriesColor }] }, function(chart) { setInterval(function refresh() { var seriesLoad = chart.series[0], data_used; $.ajax({ url: './data/core_used.json', dataType: 'json', success: function(data) { for (var i = 0; i < data.length; i++) { data_used = data[i][1]; if (data_used < 1) { seriesColor[i] = '#2d5467'; } else { seriesColor[i] = '#2d5467'; } if (is_set == 1) { seriesLoad.data[i].update(data[i]); seriesLoad.data[i].update({color: seriesColor[i]}); } } if (is_set != 1) { seriesLoad.setData(data); is_set = 1; } }, cache: false }) return refresh; }(), 5000); }); });