Я пытаюсь представить графику в PHP. У меня есть таблица persentage в MySQL.
Я пытаюсь показать процент в гугл чарте, забрал мои данные на mysql.
Мой код:
<html lang="tr">
<head>
<meta charset="utf-8" />
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">
google.charts.load('current', {'packages':['corechart','line']});
// Set a callback to run when the Google Visualization API is loaded.
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var jsonData = $.ajax({
url: "http://pediatrirutinleri.com/persentilc.php",
dataType: "json",
async: false
}).responseText;
// Create our data table out of JSON data loaded from server.
var data = new google.visualization.DataTable();
data.addColumn('number', 'Ay');
data.addColumn('number','3P', '%3');
data.addColumn('number', '%5');
data.addColumn('number', '%10');
data.addColumn('number', '%25');
data.addColumn('number', '%50');
data.addColumn('number', '%75');
data.addColumn('number', '%90');
data.addColumn('number', '%95');
data.addColumn('number', '%97');
var datum = []
var list = JSON.parse(jsonData);
for (var i = 0; i < list.length; i++) {
var item = [];
for (var j = 0; j < list[i].length; j++) {
item.push(parseFloat(list[i][j]));
}
datum.push(item);
}
data.addRows(datum);
/*function drawChart() {
var data = google.visualization.arrayToDataTable([
['Ay', '%3', '%10', '%25', '%50', '%75', '%90', '%97'],
/** İlk değişken sabit olmak üzere bu satırın altında ki her bir array
yüzde 3-97 değer aralığı için karşılık gelen aya ait verileri içeririr. */
/* ['0', 50, 60, 70, 80, 90, 100, 110],
["1", 54, 64, 74, 84, 94, 104, 114],
["2", 58, 68, 78, 88, 98, 108, 118],
["3", 62, 72, 82, 92, 102, 112, 122],
["4", 66, 76, 86, 96, 106, 116, 126],
["5", 70, 80, 90, 100, 110, 120, 130],
["6", 74, 84, 94, 104, 114, 124, 134],
["7", 78, 88, 98, 108, 118, 128, 138],
["8", 82, 92, 102, 112, 122, 132, 142],
["9", 86, 96, 106, 116, 126, 136, 146],
["10", 90, 100, 110, 120, 130, 140, 150],
["11", 94, 104, 114, 124, 134, 144, 154],
["12", 98, 108, 118, 128, 138, 148, 158],
["13", 101, 111, 121, 131, 141, 151, 161],
["14", 104, 114, 124, 134, 144, 154, 164],
["15", 107, 117, 127, 137, 147, 157, 167],
["16", 110, 120, 130, 140, 150, 160, 170],
["17", 113, 123, 133, 143, 153, 163, 173],
["18", 116, 126, 136, 146, 156, 166, 176],
["19", 119, 129, 139, 149, 159, 169, 179],
["20", 122, 132, 142, 152, 162, 172, 182],
["21", 125, 135, 145, 155, 165, 175, 185],
["22", 128, 138, 148, 158, 168, 178, 188],
["23", 131, 141, 151, 161, 171, 181, 191],
["24", 134, 144, 154, 164, 174, 184, 194],
["25", 137, 147, 157, 167, 177, 187, 197],
["26", 140, 150, 160, 170, 180, 190, 200],
["27", 143, 153, 163, 173, 183, 193, 203],
["28", 146, 156, 166, 176, 186, 196, 206],
["29", 149, 159, 169, 179, 189, 199, 209],
["30", 152, 162, 172, 182, 192, 202, 212],
["31", 155, 165, 175, 185, 195, 205, 215],
["32", 158, 168, 178, 188, 198, 208, 218],
["33", 161, 171, 181, 191, 201, 211, 221],
["34", 164, 174, 184, 194, 204, 214, 224],
["35", 167, 177, 187, 197, 207, 217, 227],
["36", 170, 180, 190, 200, 210, 220, 230]
]);
*/
var options = {
title: '0-3 Yaş Erkek Çocuklarında Boy Uzunluğu Persentil Eğrisi',
hAxis:{
title:'Yaş (Ay)'
},
vAxis: {
title:'Ağırlık'
},
curveType: 'function',
colors: ['#e2431e', '#f1ca3a', '#6f9654', '#1c91c0', '#4374e0', '#5c3292', '#572a1a'],
legend: { position: 'bottom' }
};
var chart = new google.visualization.LineChart(document.getElementById('curve_chart'));
chart.draw(data, options);
}
</script>
</head>
<body>
<div id="curve_chart" style="width: 900px; height: 500px"></div>
</body>
</html>
Задача ещё не решена.
Других решений пока нет …