猿问

​js怎么使用tp发过来的数组

$(document).ready(function() {

var yuqi="{$yuqi}";

var shiji={$shiji};

var shijian={shijian};

var data = [[20,20,11,30],[22,20,10,11,]];

alert(data)

var data_max = 30; //Y轴最大刻度

var line_title = ["预期","实际"]; //曲线名称

var y_label = "这是Y轴"; //Y轴标题

var x_label = "这是X轴"; //X轴标题

var x = [1,2,3,4,5,6,7,8,9]; //定义X轴刻度值

var title = "这是标题"; //统计图标标题

j.jqplot.diagram.base("chart1", data, line_title, "这是统计标题", x, x_label, y_label, data_max, 1);

j.jqplot.diagram.base("chart2", data, line_title, "这是统计标题", x, x_label, y_label, data_max, 2);

});

我想把data里的值替换成我接过来的数组的内容,但是现在感觉没法下手,求大神指导


Guard丿星魂
浏览 2452回答 1
1回答

Caballarii

php数组是没法转成js数组的,只能用字符串,可以在php里拼接出20&20&11&30这样的字符串,到js里再split('&')就能得到js数组了建议把data改成json字符串的形式,使用起来会方便很多

慕瓜9220888

UALHFYOHRRSOAKTDGWRBQBGKEVLDDSXLIEKWYCDIAKZPMELQSEOEUXLVXCXDWWMARMKZSTCSEZHVDNMEUVJUWEEQNGTUZUVFBOHBCNPNGTCALIAPNNGZPPWVTAPZSBOIQVNQPVYUYTTRLSBBIZESUTJLXMXIASPIILIZOCUKXQZGEMRPLIXERCAFNDJYVMDIXTDSBRWKTRZMYYEVWBZUXMWPUVGSDZFIFQXIGIBBASXRZHMLEBMRSAPEEHHUPCBPWZVEHYJFRGNQUAHVTEMWPLIAHCVUDZZCDRWOMMVIYXGEAIBAGJGEMRCYMCZQNFKSOHXTELEQIREUDVWHMADZIDLYTOHJTSCOFTSGGRUKOPRXIMLIOXBJBAGJOIOIJYNUKHAFJUPLXAJTCNBGLHNXGWASWFOUXCQXGSXPSOOYCEZNNDFZBMAFEXWWJDGUPEDGWZUBAIXWPINARCAJSELXTAFUWLELXPZBDSYUGTXHZKCUTWFPDHNPYYHHGXXZYXHQJBPUVKDTMMCUNVUMWZSESQFLBBAQIMEIKQZZ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