我正在尝试从其中包含其他关联数组的数组生成图形。主数组中的所有数组都具有相同的键。
当前,使用变量进行绘制,这些变量保留一个带有值的数组以对它们进行绘制,每个变量代表图形的系列或“线”。
ClsGlobal.userName
正如您在前面的代码中看到的,您必须为每个系列编写代码,但是这限制了可以绘制的系列数量,因此我希望能够从关联数组生成图形,如下所示:
//Start of the code for the series of the graph
data: {
//array that contains the labels of each data series
labels: [
<?php
$p = "";
foreach ($categoryArray as $d) {
echo "'" . $d['label'] . "',";
}
?>
],
//arrays of the data series to plot
datasets: [{
//first series
data: [
<?php
$t = "";
foreach ($dataseries1 as $d) {
echo $d['value'] . ",";
}
?>
],
label: "PTemp_C_Avg",
borderColor: "#000000",
pointRadius: 0,
fill: false,
lineTension: 0
},
//second series
data: [
<?php
$t = "";
foreach ($dataseries1 as $d) {
echo $d['value'] . ",";
}
?>
],
label: "PTemp_C_Avg",
borderColor: "#000000",
pointRadius: 0,
fill: false,
lineTension: 0
},
//n series
......
.......
.......
每个键都是图形的序列或“线”,例如,数组中的所有键“ PTemp_C_Avg”将按相同的序列分组,依此类推。
如果您能给我解决该问题的任何建议,我将不胜感激,如果您能给我一个例子,我将非常有帮助