1 回答

TA貢獻1797條經驗 獲得超6個贊
根據Charts外觀的用法,我假設您使用的是consoletvs/charts包的5.x 版。
這個包需要數組作為labels()andvalues()方法的參數。在render()最終調用的方法中,傳遞給labels()andvalues()方法的值將傳遞給count(),所以如果它們不可數,你會得到一個錯誤(在 PHP >= 7.2 中)。
更新您的代碼以將數組傳遞給labels()andvalues()方法。
foreach ($sumBrpro as $index) {
$chartbr = Charts::create('bar', 'highcharts')
->title("production")
->labels([$index->branche])
->values([$index->totalpro])
->dimensions(1000,500)
->responsive(true);
}
但是,我假設您正在嘗試創建一個圖表,其中所有branches 都是標簽,所有totalpros 都是值。在這種情況下,您正在尋找更多類似這樣的東西:
$chartbr = Charts::create('bar', 'highcharts')
->title("production")
->labels($sumBrpro->pluck('branche')->all())
->values($sumBrpro->pluck('totalpro')->all())
->dimensions(1000,500)
->responsive(true);
- 1 回答
- 0 關注
- 144 瀏覽
添加回答
舉報