嘿伙计们,我正在尝试在我的刀片模板中附加一个看起来像这样的高图
<body>
...
<div id="chart_div" style="width: 500px;height: 220px;"></div>
<div id="test_length">Test Length: </div>
<script type="text/javascript">
$(function () {
var myData = {!! json_encode($data['income_data']) !!};
$('#test_length').append(myData.length); //This shows the number on
var chart = Highcharts.chart('chart_div', {
credits: false,
title: {
text: ''
},
yAxis: {
labels: {
enabled: true,
formatter: function () {
return this.value;
}
},
gridLineWidth: 1,
minorGridLineWidth: 0,
title: {
text: ''
},
},
plotOptions: {
series: {
animation: false
}
},
series: [{
showInLegend: false,
data: myData,
tooltip: {
valueDecimals: 5
}
}]
});
});//end onload
</script>
</body>
</html>
我做了dd(json_encode($data['income_data']));
,输出看起来像这样
var myData output
"[["2012-11-30","10154.01"],["2012-12-31","10332.01"],["2013-01-31","10622.72"],["2013-02-28","10865.79"],["2013-03-31","10939.57"],["2013-04-30","10967.78"],["2013-05-31","11159.82"],["2013-06-30","10981.49"],["2013-07-31","11229.1"],["2013-08-31","11220.21"],["2013-09-30","11443.22"],["2013-10-31","11901.36"],["2013-11-30","12125.58"],["2013-12-31","12322.39"],["2014-01-31","12386.36"]]"
我怀疑这与我如何将数据传递到编码之间的高图表库之间有关,它是一个数组而不是JSON。任何帮助都会非常感激,因为我一直试图解决这个问题几个小时没有运气!