Closed Fahrur-R closed 3 years ago
@Fahrur-R can you post exactly all parameters how you call LaravelChart()
new object?
$chart_options = [
'chart_title' => 'Keuntungan berdasarkan bulan',
'chart_type' => 'bar',
'report_type' => 'group_by_date',
'model' => 'App\Models\Analisis_keuntungan',
'group_by_field' => 'periode_keuntungan',
'group_by_period' => 'month',
'aggregate_function' => 'sum',
'aggregate_field' => 'keuntungan',
'continuous_time' => true, // show continuous timeline including dates without data
];
$chart = new LaravelChart($chart_options);
return view('livewire.data-pemesanan',[
'analisis_keuntungans'=> Analisis_keuntungan::all(), 'chart' => $chart
]);
thats on my component livewire
Schema::create('analisis_keuntungans', function (Blueprint $table) {
$table->id();
$table->date('periode_keuntungan');
$table->integer('modal');
$table->integer('penghasilan');
$table->integer('keuntungan');
$table->timestamps();
});
and this is inside my migration for the table
@Fahrur-R in the source I found this code
if ($entry->{$this->options['group_by_field']} && $this->options['group_by_field_format']) { return \Carbon\Carbon::createFromFormat($this->options['group_by_field_format'], $entry->{$this->options['group_by_field']} )
So probably try to specify one more parameter group_by_field_format => 'Y-m-d'
can you show me how the code is? i'm sorry for that, i got confused where to put that parameter at. i'm still at early stage learning back-end and stuff.
@Fahrur-R just try to add this, see last parameter:
$chart_options = [
'chart_title' => 'Keuntungan berdasarkan bulan',
'chart_type' => 'bar',
'report_type' => 'group_by_date',
'model' => 'App\Models\Analisis_keuntungan',
'group_by_field' => 'periode_keuntungan',
'group_by_period' => 'month',
'aggregate_function' => 'sum',
'aggregate_field' => 'keuntungan',
'continuous_time' => true, // show continuous timeline including dates without data
'group_by_field_format' => 'Y-m-d'
];
@Fahrur-R just try to add this, see last parameter:
$chart_options = [ 'chart_title' => 'Keuntungan berdasarkan bulan', 'chart_type' => 'bar', 'report_type' => 'group_by_date', 'model' => 'App\Models\Analisis_keuntungan', 'group_by_field' => 'periode_keuntungan', 'group_by_period' => 'month', 'aggregate_function' => 'sum', 'aggregate_field' => 'keuntungan', 'continuous_time' => true, // show continuous timeline including dates without data 'group_by_field_format' => 'Y-m-d' ];
Thank you so much, sir. this solved it. i'm sorry for the inconvenience
i got some issue that said "Undefined index: group_by_field_format" i use field from my table that has the field type date but it doesnt work, when i changed it to type datetime field (created_at) the chart is working. i also try to group it by period of month