(类型:负载)是什么意思?
有谁知道Javascript ( type: load )
是什么意思?我收集它是一个事件,但它应该是一个对象?
任何建议表示赞赏!
中断-> var data = new google.visualization.DataTable(jsonData.jsonObj);
使用 Google 图表....
charts.js
(function($){
var charts = {
init: function(){
this.services();
},
services: function(){
var data = {
uri : SITEURL + '/moduleTest/servicelist', //siteurl defined in index.php
div : 'service-chart',
title : 'Service List'
}
charts.ajaxCallback(data);
},
ajaxCallback : function(data){
$.ajax({
url : data.uri,
type : 'POST',
dataType : 'json',
success : function(callback){
var jsonData = {
div : data.div,
jsonObj : callback,
title : data.title
}
drawCharts(jsonData);
}
});
}
}
$(function(){
charts.init();
});
})(jQuery);
google.load('visualization', '1.0', {'packages':['corechart']});
google.setOnLoadCallback(drawCharts);
function drawCharts(jsonData){
var data = new google.visualization.DataTable(jsonData.jsonObj);//Break point ( type : load )
var options =
{
'title': jsonData.title,
'width':250,
'height':300
};
var chart = new google.visualization.PieChart(document.getElementById(jsonData.div));
chart.draw(data, options);
}
Services.php(功能测试)
public function servicelist(){ //TEST data
if($this->input->is_ajax_request()){
echo "
{
cols: [{id: 'task', label: 'Employee Name', type: 'string'},
{id: 'startDate', label: 'Start Date', type: 'date'}],
rows: [{c:[{v: 'Mike'}, {v: new Date(2008, 1, 28), f:'February 28, 2008'}]},
{c:[{v: 'Bob'}, {v: new Date(2007, 5, 1)}]},
{c:[{v: 'Alice'}, {v: new Date(2006, 7, 16)}]},
{c:[{v: 'Frank'}, {v: new Date(2007, 11, 28)}]},
{c:[{v: 'Floyd'}, {v: new Date(2005, 3, 13)}]},
{c:[{v: 'Fritz'}, {v: new Date(2011, 6, 1)}]}
]
}
";
}
}
好的,我可以这个问题没有任何意义(当时是早上 6 点)。
我将一个 json 对象传递给我的谷歌图表构造函数(drawCharts())。
var jsonData = {
cols: [{id: 'task', label: 'Employee Name', type: 'string'},
{id: 'startDate', label: 'Start Date', type: 'date'}],
rows: [{c:[{v: 'Mike'}, {v: new Date(2008, 1, 28), f:'February 28, 2008'}]},
{c:[{v: 'Bob'}, {v: new Date(2007, 5, 1)}]},
{c:[{v: 'Alice'}, {v: new Date(2006, 7, 16)}]},
{c:[{v: 'Frank'}, {v: new Date(2007, 11, 28)}]},
{c:[{v: 'Floyd'}, {v: new Date(2005, 3, 13)}]},
{c:[{v: 'Fritz'}, {v: new Date(2011, 6, 1)}]}
]
}
console.log(typeof jsonData) === object // Correct, what I expect!
console.log(jsonData) === load // not what I expect, I expect json object
Does anyone know what Javascript ( type: load )
means? I gather its an event however it should be an object?
Any advice appreciated!
BREAK -> var data = new google.visualization.DataTable(jsonData.jsonObj);
Working with Google charts....
charts.js
(function($){
var charts = {
init: function(){
this.services();
},
services: function(){
var data = {
uri : SITEURL + '/moduleTest/servicelist', //siteurl defined in index.php
div : 'service-chart',
title : 'Service List'
}
charts.ajaxCallback(data);
},
ajaxCallback : function(data){
$.ajax({
url : data.uri,
type : 'POST',
dataType : 'json',
success : function(callback){
var jsonData = {
div : data.div,
jsonObj : callback,
title : data.title
}
drawCharts(jsonData);
}
});
}
}
$(function(){
charts.init();
});
})(jQuery);
google.load('visualization', '1.0', {'packages':['corechart']});
google.setOnLoadCallback(drawCharts);
function drawCharts(jsonData){
var data = new google.visualization.DataTable(jsonData.jsonObj);//Break point ( type : load )
var options =
{
'title': jsonData.title,
'width':250,
'height':300
};
var chart = new google.visualization.PieChart(document.getElementById(jsonData.div));
chart.draw(data, options);
}
Services.php ( function test )
public function servicelist(){ //TEST data
if($this->input->is_ajax_request()){
echo "
{
cols: [{id: 'task', label: 'Employee Name', type: 'string'},
{id: 'startDate', label: 'Start Date', type: 'date'}],
rows: [{c:[{v: 'Mike'}, {v: new Date(2008, 1, 28), f:'February 28, 2008'}]},
{c:[{v: 'Bob'}, {v: new Date(2007, 5, 1)}]},
{c:[{v: 'Alice'}, {v: new Date(2006, 7, 16)}]},
{c:[{v: 'Frank'}, {v: new Date(2007, 11, 28)}]},
{c:[{v: 'Floyd'}, {v: new Date(2005, 3, 13)}]},
{c:[{v: 'Fritz'}, {v: new Date(2011, 6, 1)}]}
]
}
";
}
}
Ok I may not have made any sense with the question(it was 6am).
I am passing in a json object to the my google charts constructor ( drawCharts() ).
var jsonData = {
cols: [{id: 'task', label: 'Employee Name', type: 'string'},
{id: 'startDate', label: 'Start Date', type: 'date'}],
rows: [{c:[{v: 'Mike'}, {v: new Date(2008, 1, 28), f:'February 28, 2008'}]},
{c:[{v: 'Bob'}, {v: new Date(2007, 5, 1)}]},
{c:[{v: 'Alice'}, {v: new Date(2006, 7, 16)}]},
{c:[{v: 'Frank'}, {v: new Date(2007, 11, 28)}]},
{c:[{v: 'Floyd'}, {v: new Date(2005, 3, 13)}]},
{c:[{v: 'Fritz'}, {v: new Date(2011, 6, 1)}]}
]
}
console.log(typeof jsonData) === object // Correct, what I expect!
console.log(jsonData) === load // not what I expect, I expect json object
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在我看来,就像代码中的这个注释:
对于某些代理(可能是寻找某些注释的调试器)来说,意味着在页面加载时应该在此处设置一个断点。
It looks to me like this comment in the code:
means to some agent (probably a debugger looking for certain comments) that there should be a breakpoint set here at page load time.