莫里斯线不起作用
Morris line do not work
我正在尝试显示 Morris 折线图,但线没有显示,就像这样
这是我的代码
<div class="panel-body">
<div id="morris_area_operation"></div>
<?php
$operation_quey = DB::table('station_vehicule')
->select('operation_date as date',
DB::raw('COUNT(operation_date) as nombre'))
->where('operation_name', '=', 'Carburant')
->groupBy('operation_date')
->orderBy('operation_date', 'asc')
->get();
?>
<script>
var data_collection = <?php echo json_encode($operation_quey); ?>;
new Morris.Line({
element: 'morris_area_operation',
data: data_collection,
xkey: 'date',
ykeys: 'nombre',
xLabelFormat: function(x) {
return x.toDateString();
},
ymax: 'auto',
hideHover: true,
resize: true
});
</script>
</div>
如您所见,数据存在(日期和名称),但我看不到图表中的线条
求助
你的ykeys
应该是一个数组:
ykeys: ['nombre'],
(working jsFiddle based on your example)
ykeys (required): A list of strings containing names of attributes that contain Y values (one for each series of data to be plotted).
我正在尝试显示 Morris 折线图,但线没有显示,就像这样
这是我的代码
<div class="panel-body">
<div id="morris_area_operation"></div>
<?php
$operation_quey = DB::table('station_vehicule')
->select('operation_date as date',
DB::raw('COUNT(operation_date) as nombre'))
->where('operation_name', '=', 'Carburant')
->groupBy('operation_date')
->orderBy('operation_date', 'asc')
->get();
?>
<script>
var data_collection = <?php echo json_encode($operation_quey); ?>;
new Morris.Line({
element: 'morris_area_operation',
data: data_collection,
xkey: 'date',
ykeys: 'nombre',
xLabelFormat: function(x) {
return x.toDateString();
},
ymax: 'auto',
hideHover: true,
resize: true
});
</script>
</div>
如您所见,数据存在(日期和名称),但我看不到图表中的线条
求助
你的ykeys
应该是一个数组:
ykeys: ['nombre'],
(working jsFiddle based on your example)
ykeys (required): A list of strings containing names of attributes that contain Y values (one for each series of data to be plotted).