【发布时间】:2014-01-13 12:58:20
【问题描述】:
可能是非常基本的问题:
我正在使用两个系列的 highcharts,一个用行表示,另一个用列表示,数据是使用 json 加载的,问题是如何告诉 highcharts 一个系列应该用线条表示,另一个用列类型表示,喜欢this
当highcharts的json模式下的Series选项只有这样的时候(对我来说)问题就来了:
},
series: json
});
在“正常模式”下,您可以设置例如:
series: [{
**type: 'column',**
name: 'Name',
data: [],
},{
type: 'spline',
name: 'Max Pax',
data: [],
draggableY: true,
dragMinY: 0,
dragMaxY: 200,
.......
我错过了什么吗?
从 db 中检索数据的 php 代码:
$con = mysql_connect("localhost", "*******","*******");
if (!$con) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db("wordpress_8", $con);
$sth = mysql_query("SELECT * FROM wp_maxpax_A where fecha='12/11/2013' ");
$rows = array();
$rows['name'] = 'MaxPax';
while($r = mysql_fetch_array($sth)) {
$rows['data'][] = $r['a1300'];
$rows['data'][] = $r['a1315'];
$rows['data'][] = $r['a1330'];
$rows['data'][] = $r['a1345'];
}
$sth = mysql_query("SELECT overhead FROM projections_sample");
$rows1 = array();
$rows1['name'] = 'Overhead';
while($rr = mysql_fetch_assoc($sth)) {
$rows1['data'][] = $rr['overhead'];
}
$result = array();
array_push($result,$rows);
array_push($result,$rows1);
print json_encode($result, JSON_NUMERIC_CHECK);
输出如下:
[{"name":"MaxPax","data":[40,19,40,21]},{"name":"Overhead","data": [21990,22365,21987,22369,22558,22987,23521,23003,22756,23112,22987,22897]}]
【问题讨论】:
-
你能告诉我们你用来返回 json 数据的服务器端代码吗?
标签: charts highcharts