Предыдущий вопрос пока без ответа
Кому надо поменять цвета по-умолчанию:
Есть код страницы
Код: Выделить всё
<script type="text/javascript" src="../../highcharts/js/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="../../highcharts/js/highstock.js"></script>
<script type="text/javascript">
$(function () {
var seriesOptions = [],
obsss = 0,
seriesCounter = 0,
timeback = 0,
names = ['кухня','гостиная','спальня','холл','кабинет'],
sensornames = ['KitchenArea.Temperature',
'Livingroom.Temperature',
'Bedroom.Temperature',
'HallArea.Temperature',
'OfficeRoom.Temperature'];
Highcharts.setOptions({
lang: {
months: ['Январь','Февраль','Март','Апрель','Май','Июнь','Июль',
'Август','Сентябрь','Октябрь','Ноябрь','Декабрь'],
shortMonths: ['Янв','Фев','Мар','Апр','Май','Июн','Июл',
'Авг','Сен','Окт','Ноя','Дек'],
weekdays: ['Вск','Пнд','Втр','Срд','Чтв','Птн','Сбт'],
rangeSelectorZoom: 'Маcштаб',
rangeSelectorFrom: 'От',
rangeSelectorTo: 'До',
thousandsSep: ' '
},
global: {
useUTC: false
}
});
// create the chart when all data is loaded
createChart = function () {
$('#container').highcharts('StockChart', {
rangeSelector: {
buttons: [{ type: 'hour', count: 1, text: '1h' },
{ type: 'day', count: 1, text: '1d' },
{ type: 'day', count: 2, text: '2d' },
{ type: 'week', count: 1, text: '1w' },
{ type: 'month', count: 1, text: '1m' },
{ type: 'month', count: 6, text: '6m' },
{ type: 'year', count: 1, text: '1y' },
{ type: 'all', text: 'All' }],
selected: 1 // Какая кнопка выбрана по умолчанию
},
title: { text : 'График температур в доме'},
legend: { enabled : true,
layout : 'horizontal',
align : 'center',
verticalAlign : 'top',
borderWidth: 0,
x : 0,
y : 20 },
xAxis : {
minRange: 3600 * 1000 // one hour
},
yAxis: {
title: {
text: 'Температура (°C)'
}
},
plotOptions: {
series: {
lineWidth: 1,
point: {
events: {
'click': function () {
if (this.series.data.length > 1) {
this.remove();
}
}
}
}
}
},
exporting: {
enabled: false
},
series: seriesOptions
});
};
$.each(names, function (i, name) {
$.getJSON('/objects/?script=jconhs&name='+sensornames[i]+'&callback=?', function (data) {
seriesOptions[i] = {
name: name,
data: data,
type: 'spline'
};
// As we're loading the data asynchronously, we don't know what order it will arrive. So
// we keep a counter and create the chart when all the data is loaded.
seriesCounter += 1;
if (seriesCounter === names.length) {
createChart();
}
});
});
});
</script>
<div id="container" style="height: 500px; min-width: 500px"></div>
Добавляем строку
color = ['red','green','blue','yellow','orange'],
Код: Выделить всё
names = ['кухня','гостиная','спальня','холл','кабинет'],
color = ['red','green','blue','yellow','orange'],
sensornames = ['KitchenArea.Temperature',
'Livingroom.Temperature',
'Bedroom.Temperature',
'HallArea.Temperature',
'OfficeRoom.Temperature'];
и ещё строку в секции seriesOptions
Код: Выделить всё
seriesOptions[i] = {
name: name,
data: data,
color:color[i],
type: 'spline'
};