我从数据库中获取数据。成功执行查询后,结果如下。对于每个BRANCH
,有4个值。
<?php
$data =
'{"8":{"SDATE":"01-APR-2013","BRANCH":"MEDICAL","FEES":"16000","PER_INC":".68","CLG_RANK":"7"},
"9":{"SDATE":"01-AUG-2012","BRANCH":"MEDICAL","FEES":"14000","PER_INC":".047","CLG_RANK":"6"},
"10":{"SDATE":"01-DEC-2012","BRANCH":"MEDICAL","FEES":"15500","PER_INC":".87","CLG_RANK":"7"},
"11":{"SDATE":"01-FEB-2013","BRANCH":"MEDICAL","FEES":"17500","PER_INC":".72","CLG_RANK":"7"},
"12":{"SDATE":"01-JAN-2013","BRANCH":"ELECTRICAL","FEES":"12200","PER_INC":".18","CLG_RANK":"7"},
"13":{"SDATE":"01-JUL-2012","BRANCH":"ELECTRICAL","FEES":"17000","PER_INC":".071","CLG_RANK":"6"},
"14":{"SDATE":"01-JUL-2013","BRANCH":"ELECTRICAL","FEES":"15700","PER_INC":".044","CLG_RANK":"8"},
"15":{"SDATE":"01-JUN-2013","BRANCH":"ELECTRICAL","FEES":"13000","PER_INC":".78","CLG_RANK":"8"},
"16":{"SDATE":"01-MAR-2013","BRANCH":"MECHANICAL","FEES":"13200","PER_INC":".95","CLG_RANK":"7"},
"17":{"SDATE":"01-MAY-2013","BRANCH":"MECHANICAL","FEES":"16000","PER_INC":".27","CLG_RANK":"8"},
"18":{"SDATE":"01-NOV-2012","BRANCH":"MECHANICAL","FEES":"14000","PER_INC":".82","CLG_RANK":"7"},
"19":{"SDATE":"01-OCT-2012","BRANCH":"MECHANICAL","FEES":"17500","PER_INC":".32","CLG_RANK":"7"},
"20":{"SDATE":"01-SEP-2012","BRANCH":"CIVIL","FEES":"13500","PER_INC":".67","CLG_RANK":"6"},
"21":{"SDATE":"01-APR-2013","BRANCH":"CIVIL","FEES":"14700","PER_INC":".56","CLG_RANK":"8"},
"22":{"SDATE":"01-AUG-2012","BRANCH":"CIVIL","FEES":"18000","PER_INC":"0","CLG_RANK":"7"},
"23":{"SDATE":"01-DEC-2012","BRANCH":"CIVIL","FEES":"15000","PER_INC":"0","CLG_RANK":"8"}}';
?>
我必须将数据转换为数组并将数组值传递给图形。请查看此图http://www.highcharts.com/demo/area-stacked。 x轴值必须是SDATE
值,即日期。 y轴值必须为FEES
。在我发布的链接中,可以在图表中和x轴下方看到的国家/地区将替换为BRANCH
的值。
$(function () {
var data = new Array();
data = '<?php echo $data; ?>';
// code to be written
});
总结是我在上面的URL中提到的图表将被BRANCH
的$ data值替换,即基于分支x轴和y轴值是显示。
我该怎么办?请任何人帮忙。我试了一整天。但由于我不擅长数组,我无法做到这一点。 Atleast告诉如何根据BRANCH
值
答案 0 :(得分:0)
通常问题是它不是JSON /正确的字符串。所以在开始时我建议你注意你的格式然后结构。它应该是系列和数据的数组。字段应使用highcharts标准正确命名,而不是自定义名称。日期必须是时间戳。在SO,有许多类似的主题。
可能有用的文章: