问题
我正在尝试在使用 Phonegap 开发的移动应用程序上使用 Highcharts。我已经通过 AJAX 从数据库中获取数据。当我根据我在 highcharts 代码中获得的数据设置If{}Else{}条件时,这基本上已经过测试并且工作正常,它给了我一个错误。无论哪种情况,我在$(function () {之后放置的 ELSE 条件都会引发错误。代码附在下面。有什么方法可以正常放置条件吗?提前致谢
代码
//Get values from local storage
var teamactivitygameGraph = window.localStorage.getItem("teamactivitygameGraph");
AGW = JSON.parse(teamactivitygameGraph);
//Assign values to the variables
var game_start_on = AGW.game_start_on;
var data_string = AGW.data_string;
var data_avail = AGW.data_avail;
var subText = AGW.subText;
var graphdefault = user.graphdefault;
var noofsundays = AGW.noofsundays;
var total_user = AGW.total_user;
var data = AGW.data;
var yellowLineData = AGW.yellowLineData;
var game_type = AGW.game_type;
var danger_point = AGW.danger_point;
var graph_image = AGW.graph_image;
//Graph..
$(function () {
//var graphdefault = graphdefault;
//var noofsundays = noofsundays;
if(data_avail == 'no') {
var styles = "x: -60,y:100,style: {color: '#8eb3ef',fontWeight: 'bold',fontSize: '36px'}";
}else{
var styles = "x: -25,";
}
if(graphdefault == 1 || (noofsundays == 1 && graphdefault == 1)){
var showLabels = 'showFirstLabel: false,showLastLabel: false,';
}
$('#team_container').highcharts({
chart: {
type: 'bar',
renderTo: 'container',
zoomType: 'xy',
events: {
load: function() {
this.renderer.image(graph_image)
.add();
}
},
zIndex: 5
},
title: {
text: 'Team Activity Game',
x: -20 //center
},
subtitle: {
text: subText,
if(data_avail == 'no') {
x: -60, //center
y:100,
style: {
color: '#8eb3ef',
fontWeight: 'bold',
fontSize: '36px'
}
}else{
x: -25, //center
}
},
xAxis: {
showLabels
title: {
text: 'Week Ending'
},
type: 'datetime',
maxZoom: 24 * 3600000, // Two days
labels: {
rotation: -45,
align: 'right',
formatter: function() {
return Highcharts.dateFormat('%d/%m/%Y', this.value);
}
},
if(graphdefault == 0){
tickInterval: 24 * 3600 * 1000 * 7,
startOfWeek: 0
}elseif(graphdefault == 1){
tickInterval: 24 * 3600 * 1000
}
},
json问题
//I am taking this data from my Local Storage
var teamactivitygameGraph = window.localStorage.getItem("teamactivitygameGraph");
AGW = JSON.parse(teamactivitygameGraph);
var data = AGW.data;
alert (data);
当我警告 var data 时,它会输出正确的响应,即 "{name: "Joe",data: [[Date.parse('10/20/2013 UTC'), 8.9905667952813 ]]},{name: "Mark",data :[]},{名称:“唐”,数据:[]}”
但是当我将相同的变量放入我的 Highchart 代码(如下)中时,它不会显示任何内容。
series: [
data
,{
name: 'yellowline',
visible: false,
showInLegend: false,
data: yellowLineData
}
]
});