$(function () { var seriesColor = new Array(); var is_set = 0; $('#redstar_cpu_loadavg').highcharts({ chart: { zoomType: 'x', backgroundColor: '#1d2132', marginTop: 5, marginBottom: 15, marginLeft: 10, marginRight: 0 }, title: { text: null }, subtitle: { text: null }, xAxis: { type: 'category', tickWidth: 0, tickInterval: 55, gridLineWidth: 1, labels: { align: 'center', x: 0, y: 12 }, }, yAxis: { tickWidth: 0, tickAmount: 3, min: 0, labels: { align: 'left', x: 7, y: 12, format: '{value:.,0f}' }, title: { text: null }, showFirstLabel: false }, legend: { itemStyle: { fontSize: '8pt', fontWeight: 'normal', }, floating: true, align: 'right', x: 15, y: -17, verticalAlign: 'top', borderWidth: 0 }, plotOptions: { area: { fillColor: { linearGradient: { x1: 0, y1: 70, x2: 0, y2: 0 }, stops: [ [0, Highcharts.getOptions().colors[0]], [1, Highcharts.Color(Highcharts.getOptions().colors[0]).setOpacity(0).get('rgba')] ] }, marker: { radius: 0 }, lineWidth: 2, states: { hover: { lineWidth: 2 } }, threshold: 'null' }, series: { type: 'area', borderWidth: 0, dataLabels: { enabled: false, format: '
{point.y:,.0f}
' } } }, navigation: { buttonOptions: { enabled: false } }, credits: { enabled: false }, series: [{ type: 'area', name: '1min', lineWidth: 1, data: [] }, { type: 'area', name: '5min', lineWidth: 1, data: [], }, { type: 'area', name: '15min', lineWidth: 1, data: [], }], tooltip: { shared: true, crosshairs: true, pointFormat: '{series.name} : {point.y:,.0f}%
', backgroundColor: { linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 }, stops: [ [0, 'rgba(96, 96, 96, .8)'], [1, 'rgba(16, 16, 16, .8)'], [2, 'rgba(16, 16, 16, .8)'] ] }, borderWidth: 0, style: { color: '#FFF' } }, }, function(chart) { setInterval(function refresh() { var series1min = chart.series[0]; var series5min = chart.series[1]; var series15min = chart.series[2]; $.ajax({ url: './data/redstar_cpuload_1min.json', dataType: 'json', success: function(data) { if (is_set[0] == 1) { series1min.addPoint(eval(data[data.length - 1]), true, true); } if (is_set[0] != 1) { series1min.setData(data); is_set[0] = 1; } }, cache: false }), $.ajax({ url: './data/redstar_cpuload_5min.json', dataType: 'json', success: function(data) { if (is_set[1] == 1) { series5min.addPoint(eval(data[data.length - 1]), true, true); } if (is_set[1] != 1) { series5min.setData(data); is_set[1] = 1; } }, cache: false }), $.ajax({ url: './data/redstar_cpuload_15min.json', dataType: 'json', success: function(data) { if (is_set[2] == 1) { series15min.addPoint(eval(data[data.length - 1]), true, true); } if (is_set[2] != 1) { series15min.setData(data); is_set[2] = 1; } }, cache: false }) return refresh; }(), 301000); }); });