0
我有一個數據庫來保存一些值,這是gerilim,akim和power。如何用數據庫值創建折線圖?
我想打一個折線圖與數據庫中的這些值。我在網上搜索,找不到任何東西。這是我的腳本代碼;
* LINE CHART
* ----------
*/
//LINE randomly generated data
var data = [],id=0;
<?php
include"../../pages/veri_ayar.php";
$verileriCek = mysql_query("SELECT * FROM etkin");
while ($b=mysql_fetch_array($verileriCek)){
$akim = $b['akim'];
$id=$b['id'];
}
data=$akim;
id=$id;?>
var i=0;
while(i < id) {
data;
i++;
}
var line_data1 = {
data: data,
color: "#3c8dbc"
};
$.plot("#line-chart", [line_data1], {
grid: {
hoverable: true,
borderColor: "#f3f3f3",
borderWidth: 1,
tickColor: "#f3f3f3"
},
series: {
shadowSize: 0,
lines: {
show: true
},
points: {
show: true
}
},
lines: {
fill: false,
color: ["#3c8dbc"]
},
yaxis: {
show: true,
},
xaxis: {
show: true
}
});
//Initialize tooltip on hover
$('<div class="tooltip-inner" id="line-chart-tooltip"></div>').css({
position: "absolute",
display: "none",
opacity: 0.8
}).appendTo("body");
$("#line-chart").bind("plothover", function (event, pos, item) {
if (item) {
var x = item.datapoint[0].toFixed(2),
y = item.datapoint[1].toFixed(2);
$("#line-chart-tooltip").html(item.series.label + " of " + x + " = " + y)
.css({top: item.pageY + 5, left: item.pageX + 5})
.fadeIn(200);
} else {
$("#line-chart-tooltip").hide();
}
});
/* END LINE CHART */
圖表是基於JavaScript的。看起來你正在試圖在PHP中運行JavaScript而沒有標籤。你應該看看Charts.js – Sedrick