HighCharts добавляет еще одну переменнуюPhp

Кемеровские программисты php общаются здесь
Ответить
Anonymous
 HighCharts добавляет еще одну переменную

Сообщение Anonymous »

У меня есть сценарий, который вызывает данные из таблицы данных MySQl и использует их в диаграмме HighCharts. У меня все работает нормально, но я хочу добавить еще одну переменную (поле) из таблицы данных с именем «uniqueid».
Сценарий № 1;

Код: Выделить всё

$categories = array();
$categories['name'] = 'Room';

$rows1 = array();
$rows1['name'] = 'Temp C';

$uniqueid = array();
$uniqueid['name'] = 'UniqueID';

while($row_AvgWaterTemp = mysql_fetch_assoc($AvgWaterTemp)) {
$categories['data'][] = $row_AvgWaterTemp['Room'];
$rows1['data'][] = $row_AvgWaterTemp['SeqID1306'];
$uniqueid['data'][] = $row_AvgWaterTemp['UniqueID']; // NEW FIELD
}
$result = array();

array_push($result,$categories);
array_push($result,$rows1);
array_push($result,$uniqueid); // NEW FIELD
У меня также есть сценарий, который вызывает сценарий № 1 и создает диаграмму:

Сценарий № 2

Код: Выделить всё

$(function () {

var categories=[];
var data =[];

var chart;
$(document).ready(function() {

$.getJSON("../charts/chart.php", function(json) {
$.each(json,function(i,el) {
if (el.name=="Room")
categories = el.data;
else data.push(el);
});

$('#container1').highcharts({
chart: {
renderTo: 'container',
type: 'line',
zoomType: 'x',
marginTop: 40,
marginRight: 30,
marginBottom: 50,
plotBackgroundColor: '#FCFFC5'
},
title: {
text: 'Room hot water temperatures ',
x: -20, //center
style: {
fontFamily: 'Tahoma',
color: '#000000',
fontWeight: 'bold',
fontSize: '10px'
}
},
subtitle: {
text: 'Zoom: hold cursor over chart, hold left mouse button and drag, release button',
x: -20
},
xAxis: {
categories: categories,

labels: {
enabled: false
}
},

yAxis: {

plotLines: [{
value: '',
color: '#FF0000',
width: 1,
zIndex: 10,
label: {
text: 'Maximum  °C',
align: 'center',
x: -10,
y: -5,
style: {
color: '#FF0000'
}
}
}, {
value: '',
color: '#0000CC',
width: 1,
zIndex: 10,
label: {
text: 'Minimum   °C',
align: 'center',
x: -10,
y: 20,
style: {
color: '#0000CC'
}
}
}],

showFirstLabel: false,
lineColor:'#999',
lineWidth:0.2,
tickColor:'#666',
tickWidth:1,
tickLength:2,
tickInterval: 10,
gridLineColor:'#ddd',
title: {
text: 'Temperature °C',
style: {
fontFamily: 'Tahoma',
color: '#000000',
fontWeight: 'bold',
fontSize: '10px'
}
},

},

legend: {
enabled: false,
itemStyle: {
font: '11px Trebuchet MS, Verdana, sans-serif',
color: '#000000'
},
itemHoverStyle: {
color: '#000000'
},
itemHiddenStyle: {
color: '#444'
}

},

colors: [
'#009900',

],

plotOptions: {
style: { textShadow: false },
column: {
color:'#ff00ff'
},

series: {

cursor: 'pointer',
point: {
events: {
click: function() {
window.top.location.href = "../chart_click_hot_water.php?room=" + this.category;

}
}
},

lineWidth: 1,
dataLabels: {
enabled: false,
rotation: 0,
color: '#000000',
align: 'center',
//format: '{point.y:.1f}', // one decimal
y: 0, // 10 pixels down from the top
style: {
textShadow: false,
fontSize: '10px',
fontFamily: 'Verdana, sans-serif'
}
}
}

},

tooltip: {

enabled: true,
crosshairs: [false, true],
positioner: function () {
return { x: 5, y: -5 };
},
shadow: false,
borderWidth: 0,
backgroundColor: 'rgba(255,255,255,0.8)',
formatter: function () {
return 'Room: ' + this.x +
'[/b] is [b]' + this.y + ' °C[/b]';
}
},

credits: {
enabled: false
},

series: data
});
});

});

});
Мой вопрос: как включить новое поле «uniqueid» и использовать его в функции щелчка:

Код: Выделить всё

 click: function() {
window.top.location.href ="../chart_click_hot_water.php?uniqueid=" + this.category;
}
В настоящее время у меня есть «Подсказки», отображающие номер комнаты и температуру воды, но когда я включаю дополнительное поле в сценарий № 1, подсказки отображают только номер комнаты и отображают «не определено» для температуры воды.

Можно ли вызвать дополнительное поле из таблицы данных и использовать его в моей функции щелчка, если да, то как мне это сделать? это.

Заранее большое спасибо за вашу помощь и время.

С уважением.

ОБНОВЛЕНИЕ:

У меня есть следующее

Код: Выделить всё

$.getJSON("../charts/imaint_water_avg_temp_chart.php", function(json) {
$.each(json,function(i,el) {
if (el.name=="Room")
categories = el.data;
else if (el.name=="UniqueID")  {
uniqueid = el.data;
} else data.push(el);
});
then
console.log(uniqueid, "UniqueID"); Я вижу UniqueID в журнале.

Тогда у меня есть:

Код: Выделить всё

series: {
cursor: 'pointer',
point: {
events: {
click: function() {
window.top.location.href = "../imaint_chart_click_hot_water.php?room=" + this.uniqueid;
}
}
},
но ?room= не заполняется.

Знаете ли вы или кто-нибудь еще, где я я ошибаюсь.
Спасибо

Подробнее здесь: https://stackoverflow.com/questions/377 ... r-variable
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Php»