1
我与jqplot的工作,我已经绘制的是来自数组PHP中的数据,但是当我试图从JavaScript来绘制不工作携带一个PHP数组javascript和情节witjh jqplot
这是PHP代码:
$array= array();
$array[] = 34.890;
$array[] = 25.090;
现在代码吸收水分:
<script>
$(function() {
var array = new Array();
<?php
for($i=0; $i<count($array); $i++){
echo "\narray[$i] = '$array[$i]';";
}
?>
graficar( array );
});
</script>
功能graficar是:
function graficar(array)
{
var plot2 = $.jqplot('lienzo',
[
array
],
{
seriesDefaults: {
renderer: $.jqplot.BarRenderer,
// Show point labels to the right ('e'ast) of each bar.
// edgeTolerance of -15 allows labels flow outside the grid
// up to 15 pixels. If they flow out more than that, they
// will be hidden.
pointLabels: {show: true, location: 'e', edgeTolerance: -15},
// Rotate the bar shadow as if bar is lit from top right.
shadowAngle: 135,
// Here's where we tell the chart it is oriented horizontally.
rendererOptions: {
barDirection: 'horizontal',
barWidth:18
}
},
axes: {
yaxis: {
renderer: $.jqplot.CategoryAxisRenderer
}
}
}
);
}
我得到的错误是:
TypeError: this[r]._ticks[0] is undefined
[Break On This Error]
...{href:function(a){return a.getAttribute("href")},type:function(a){return a.getAt...
的图表显示:
如何解决我的麻烦?
坦克。
与PHP和JS中parseJson(jQuery的)json_encode :-) – 2013-03-22 16:10:43
也试试,智者可以让你通过PHP数组到HTML页面,然后你可以调用与JavaScript – 2013-03-22 16:20:39
这些阵列作为KA_lin说使用json_encode在PHP使你的数组可以通过JavaScript来理解。但是,不需要在Javascript中使用parseJson,Jqplot可以处理它 – AnthonyLeGovic 2013-03-22 16:49:57