Codeigniter Google Charts Api & JSON

CodeIgniter, Zend Framework, Cake PHP, Yii, symfony, Prado, Seagull, Kohana, MODX, eZ Components

Moderator: Moderatori

chester31
Junior Member
Mesaje: 48
Membru din: Lun Dec 03, 2012 8:58 pm
Localitate: Cluj Napoca
Contact:

Codeigniter Google Charts Api & JSON

Mesajde chester31 » Mie Iun 12, 2013 2:27 pm

A lucrat cineva cu Codeigniter Google Charts Api & JSON ???

CODE :
*********************************************************
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script type="text/javascript">

// Load the Visualization API and the piechart package.
google.load('visualization', '1', {'packages':['corechart']});

// Set a callback to run when the Google Visualization API is loaded.
google.setOnLoadCallback(drawChart);

function drawChart() {

var jsonData = $.ajax({
url: "http://localhost/app/charts/getData.php",
dataType:"html",
async: false
}).responseText;
// Create our data table out of JSON data loaded from server.
var data = new google.visualization.DataTable(jsonData);
// Instantiate and draw our chart, passing in some options.
var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
chart.draw(data, {width: 400, height: 240});
}

</script>
<div id="chart_div" style="float:left;margin-top:20px;margin-left:10px;border-radius:3px;"></div>
******************************************************************
getData.php FILE :
$string = file_get_contents("app/charts/sampleData.json");
echo $string;
***************************************************************************
JSON FILE (sampleData.json)
{
"cols": [
{"id":"","label":"Topping","pattern":"","type":"string"},
{"id":"","label":"Slices","pattern":"","type":"number"}
],
"rows": [
{"c":[{"v":"Mushrooms","f":null},{"v":3,"f":null}]},
{"c":[{"v":"Onions","f":null},{"v":1,"f":null}]},
{"c":[{"v":"Olives","f":null},{"v":1,"f":null}]},
{"c":[{"v":"Zucchini","f":null},{"v":1,"f":null}]},
{"c":[{"v":"Pepperoni","f":null},{"v":2,"f":null}]}
]
}
*********************************************************************************
Practic am dat copy paste de aici : https://developers.google.com/chart/int ... hp_example
Am schimbat doar path urile la cele 2 file uri . Initial am bagat pe getData ca si controler iar pe sampleData in view , dar n-a mers. La momentul de fata am facut un fisier separat numit charts si am bagat acolo tot, mai putin javascriptul care intrun view. La afisare nu-mi afiseaza nik, nici macar o eroare. Astept idei ce nui bine . Multumesc



chester31
Junior Member
Mesaje: 48
Membru din: Lun Dec 03, 2012 8:58 pm
Localitate: Cluj Napoca
Contact:

Re: Codeigniter Google Charts Api & JSON

Mesajde chester31 » Mie Iun 12, 2013 2:28 pm

in localhost simplu merge, ii ceva de la codeigniter si nush ce .


Înapoi la “Framework-uri PHP”

Cine este conectat

Utilizatori ce ce navighează pe acest forum: Niciun utilizator înregistrat și 2 vizitatori