我刚刚在Laravel 5应用程序中实现了Lavacharts,但我似乎无法找到解决这个小问题的方法。
这是我目前的图表:
从图中可以看出,即使我的所有图表输入数据都是整数,所有数据都表示为浮点数。是不是有办法删除这个间隔并将数据表示为?
我想要实现的目标:
这是与我的控制器中的图表相关的代码提取:
//Instatiate chart
$favoritesChart = LavachartsFacade::DataTable();
$favoritesChart->addNumberColumn('Day of month')
->addNumberColumn('Amount');
foreach($favorites as $favorite)
{
//both $favorite->day and $favorite->favorite_count come as an Integer
$favoritesChart->addRow(array($favorite->day, $favorite->favorite_count));
}
$linechart = LavachartsFacade::ColumnChart('favoritesChart')
->dataTable($favoritesChart)
->title('Number of favorites this month');
有没有办法做到这一点?提前谢谢。
答案 0 :(得分:1)
尝试替换
$linechart = LavachartsFacade::ColumnChart('favoritesChart')
->dataTable($favoritesChart)
->title('Number of favorites this month');
用这个
$linechart = LavachartsFacade::ColumnChart('favoritesChart')
->dataTable($favoritesChart)
->title('Number of favorites this month')
->hAxis(new HorizontalAxis(['gridlines' => ['count' => -1, 'color' => '#CCC']]))
->vAxis(new VerticalAxis(['gridlines' => ['count' => -1, 'color' => '#CCC']]));