我有一个由数组组成的简单图表,如下所示:
var plot2 = [[1,1.3,"1.3"],[2,0.3,"0.3"],[3,3.3,"3.3"],[4,1.7,"1.7"]];
然后将其添加到这样的 div 中。
var plot1 = $.jqplot ('graph', [plot2],{
grid:{
background:"transparent",
borderColor:"#6c9922",
gridLineColor:"#6c9922",
shadow:false
},
axes: {
xaxis: {
tickOptions:{formatString:'%.0f'},
pad: 0,
min:0,
max:5
},
yaxis: {
tickOptions:{formatString:'%.1f'},
pad: 0,
min:0,
max:5
},
},
series:[{
lineWidth:2,
markerOptions: {size:2,style:"circle"}
}],
seriesDefaults:{
showMarker:true,
pointLabels:{ show:true }
},
seriesColors:["#ffffff"]
});
我的问题是,我网站的一些用户报告他们无法看到图表,无论使用最新的 Chrome 还是 Firefox,他们都会收到错误消息
Uncaught Canvas dimension not set jquery.jqplot.min.js:57
他们中的一些人说,只有将缩放级别设置为 100% 时,图表才有效。
这一切都没有多大意义,因为在我尝试过的每个系统上一切都很完美。
那么有人知道可能出了什么问题吗?
我已经搜索了该错误,但我唯一能找到它的地方是 jqplot 插件的源代码。
最佳答案
我对属性数组进行了以下更改,这似乎有效。它一定与轴上的最小值和/或最大值有关,尽管我不确定,因为我从未收到任何错误。
var plot1 = $.jqplot ('graph', [plot2],{
grid:{
background:"transparent",
borderColor:"#6c9922",
gridLineColor:"#6c9922",
shadow:false
},
axes: {
xaxis: {
tickOptions:{formatString:'%.0f'},
pad: 0
},
yaxis: {
tickOptions:{formatString:'%.1f'},
pad: 0
},
},
series:[{
lineWidth:2,
markerOptions: {size:2,style:"circle"}
}],
seriesDefaults:{
showMarker:true,
pointLabels:{ show:true }
},
seriesColors:["#ffffff"]
});
关于javascript - jqplot错误: Uncaught Canvas dimension not set,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13247880/