我有一个Laravel 5.5应用程序,它使用此ConsoleTV Chart Package,我使用barchart在每月报告的基础上]可视化我的[[data。我在下面有以下查询。$dt = Carbon::now()->year;
$anRequest = AnalysisRequest::where(DB::raw("(DATE_FORMAT(created_at,'%Y'))"),date('Y'))->orderBy('service_id')
->get();
以及我的图表
$barChart = Charts::database($anRequest, 'bar', 'highcharts')
->title("Monthly service request")
->elementLabel("Total requests")
->dimensions(1000, 500)
->responsive(false)
->groupByMonth(date('Y'), true);
此代码运行得很好,并按显示所有数据,但是我如何添加另一个month
dataSets
或multipleDataSets
而不是仅添加一个数据集来可视化] >。例如,我将通过AnalysisRequest
进行另一个查询,但具有特定的resources。下面的示例代码,使用multi
Thequery
$tags_jan = DB::table('tags')->whereYear('created_at', $dt)->whereMonth('created_at', '1')->count();
$tags_feb = DB::table('tags')->whereYear('created_at', $dt)->whereMonth('created_at', '2')->count();
$tags_mar = DB::table('tags')->whereYear('created_at', $dt)->whereMonth('created_at', '3')->count();
// and the list goes on which is bad
[图表
使用multi
$chart = Charts::multi('bar', 'highcharts')
// Setup the chart settings
->title("Total Reports for this year")
// A dimension of 0 means it will take 100% of the space
->dimensions(0, 400) // Width x Height
// This defines a preset of colors already done:)
// ->template("material")
// ->responsive(true)
// You could always set them manually
// ->colors(['#2196F3', '#F44336', '#FFC107'])
// Setup the diferent datasets (this is a multi chart)
->colors(['green', 'aqua', 'red', 'yellow'])
->dataset('Ads', [$ads_jan,$ads_feb,$ads_mar,$ads_apr,$ads_may,$ads_june,$ads_july,$ads_aug,$ads_sept,$ads_oct,$ads_nov,$ads_dec])
->dataset('Channels', [$channels_jan,$channels_feb,$channels_mar,$channels_apr,$channels_may,$channels_june,$channels_july,$channels_aug,$channels_sept,$channels_oct,$channels_nov,$channels_dec])
->dataset('Shows', [$shows_jan,$shows_feb,$shows_mar,$shows_apr,$shows_may,$shows_june,$shows_july,$shows_aug,$shows_sept,$shows_oct,$shows_nov,$shows_dec])
->dataset('Tags', [$tags_jan,$tags_feb,$tags_mar,$tags_apr,$tags_may,$tags_june,$tags_july,$tags_aug,$tags_sept,$tags_oct,$tags_nov,$tags_dec])
上面的代码也可以正常工作,但是正如您在或使用多个dataSets解决此问题的另一种方法?感谢有人可以提供帮助。预先感谢。variable
中看到的那样,我正在查询今年的每个月,这并不是很好。如何简化此query
我有一个Laravel 5.5应用程序,该应用程序使用了ConsoleTV Chart程序包,我使用条形图以月度报告的形式显示了我的数据。我在下面有以下查询。 $ dt = Carbon :: now()-> year; ...
$ chart =新的无人认领的;$ chart-> labels($ days);$ chart-> dataset('Daily Visitors Bar','bar',$ totalNumber)-> color('white')-> backgroundColor(['#009900','#8a8a5c','#f1c40f','#e67e22 ','#16a085','#2980b9']);