මචන්ලා මට php වලින් charts generate කරන්න ඕනේ
highcharts හොදයි නේද
…මේක පවිච්චි කරන කවුරුහරි ඉන්නවද
…මට පොඩ්ඩක් කියල දෙන්න පුලුවන්ද
…mysql database එකකින් ගන්න data set එකක් highcharts වලට දෙන්නෙ කොහමඩ කියලා
උඩ code එකෙන් මෙන්න මේ වගේ output එකක් දෙනවා
[["Michael",55000],["Praveen",50000],["Nuwan",120000],["Thilan",100000]]
ඊට පස්සේ මේක මෙන්න මේ වගේ html එකක paste කලාම මුකුත් පෙන්නන්නේ නැහැ නේ
මේ යට තියෙන code මම එහෙන් පිටින්ම වෙන තැනකින් ගත්තේ
මට මේක වැඩිය තේරෙන්නේ නැහැ
කාට හරි කියන්න පුලුවන්ද මොකක්ද කරන්න ඕනේ මේකෙන් chart එක පෙන්න ගන්න
මේකේ එහෙම වෙනස් කරන්න ඕන තැන් මොනාද
එහෙම නැත්තම් සාමාන්යෙන් මොනාද පාවිච්චි කරන්නේ php වලින් charts generate කරන්න
පොඩි උදව්වක් දෙන්න
බම්ප් හරි කරන්න
…
highcharts හොදයි නේද
…මේක පවිච්චි කරන කවුරුහරි ඉන්නවද
…මට පොඩ්ඩක් කියල දෙන්න පුලුවන්ද
…mysql database එකකින් ගන්න data set එකක් highcharts වලට දෙන්නෙ කොහමඩ කියලා
Code:
//file name is data.php
<?php
require_once '../includes/database.php';
require_once '../includes/customer.php';
$customers= Customer::find_by_sql("SELECT firstname,monthly_income FROM customer");
$rows=array();
foreach ($customers as $customer) {
$row[0]=$customer->firstname;
$row[1]=$customer->monthly_income;
array_push($rows,$row);
}
print json_encode($rows, JSON_NUMERIC_CHECK);
?>
[["Michael",55000],["Praveen",50000],["Nuwan",120000],["Thilan",100000]]
ඊට පස්සේ මේක මෙන්න මේ වගේ html එකක paste කලාම මුකුත් පෙන්නන්නේ නැහැ නේ
මේ යට තියෙන code මම එහෙන් පිටින්ම වෙන තැනකින් ගත්තේ
මට මේක වැඩිය තේරෙන්නේ නැහැ
කාට හරි කියන්න පුලුවන්ද මොකක්ද කරන්න ඕනේ මේකෙන් chart එක පෙන්න ගන්න
මේකේ එහෙම වෙනස් කරන්න ඕන තැන් මොනාද
Code:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Highcharts Pie Chart</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var options = {
chart: {
renderTo: 'container',
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false
},
title: {
text: 'Customer Vs Income'
},
tooltip: {
formatter: function() {
return '<b>'+ this.point.name +'</b>: '+ this.percentage +' %';
}
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
color: '#000000',
connectorColor: '#000000',
formatter: function() {
return '<b>'+ this.point.name +'</b>: '+ this.percentage +' %';
}
}
}
},
series: [{
type: 'pie',
name: 'Browser share',
data: []
}]
}
$.getJSON("data.php", function(json) {
options.series[0].data = json;
chart = new Highcharts.Chart(options);
});
});
</script>
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>
</head>
<body>
<div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
</body>
</html>
එහෙම නැත්තම් සාමාන්යෙන් මොනාද පාවිච්චි කරන්නේ php වලින් charts generate කරන්න
පොඩි උදව්වක් දෙන්න
බම්ප් හරි කරන්න
…