F
Filament11mo ago
Noor

charts

I'm building mixed chart type widget, One chart is line and the other is Bar both of them have data from different tables.. so how can I retrieve there data from each table ... and I'm not using apex chart so if there is any other solution please tell me........ I'm already using getFilter and trenvalue map function but it only retrieve data of one graph ty
15 Replies
awcodes
awcodes11mo ago
Is the problem only happening when you filter? If it’s only querying one table then I’d recommend just doing two separate queries with Trend::query. Then just map each one separately into different data objects.
Noor
Noor11mo ago
Can you please show me an example because If I use two trend queries with the same filter attribute twice, it doesn't work @awcodes
awcodes
awcodes11mo ago
can you provide your widget code?
Noor
Noor11mo ago
Noor
Noor11mo ago
Noor
Noor11mo ago
Noor
Noor11mo ago
@awcodes
awcodes
awcodes11mo ago
$submissionData = Trend::model(Submission::class)....
$leadData = Trend::model(Lead::class)....

'datasets' => [
[
'label' => 'Submissions',
'data' => $submissionData->map(fn (TrendValue $value) => $value->aggregate),
],
[
'label' => 'Leads',
'data' => $leadData->map(fn (TrendValue $value) => $value->aggregate),
],
],
$submissionData = Trend::model(Submission::class)....
$leadData = Trend::model(Lead::class)....

'datasets' => [
[
'label' => 'Submissions',
'data' => $submissionData->map(fn (TrendValue $value) => $value->aggregate),
],
[
'label' => 'Leads',
'data' => $leadData->map(fn (TrendValue $value) => $value->aggregate),
],
],
This is what i meant
Noor
Noor11mo ago
and labels like this ? 'labels' => $submissionData->map(fn (TrendValue $value) => $value->date), 'labels' => $leadData->map(fn (TrendValue $value) => $value->date), @awcodes
awcodes
awcodes11mo ago
you can only have one set of labels
Noor
Noor11mo ago
then it shows data error
awcodes
awcodes11mo ago
but since both would have the same dates you could use either one for the lables
Noor
Noor11mo ago
undefined variable $data
awcodes
awcodes11mo ago
'datasets' => [
[
'label' => 'Submissions',
'data' => $submissionData->map(fn (TrendValue $value) => $value->aggregate),
],
[
'label' => 'Leads',
'data' => $leadData->map(fn (TrendValue $value) => $value->aggregate),
],
],
'labels' => $leadData->map(fn (TrendValue $value) => $value->date)
'datasets' => [
[
'label' => 'Submissions',
'data' => $submissionData->map(fn (TrendValue $value) => $value->aggregate),
],
[
'label' => 'Leads',
'data' => $leadData->map(fn (TrendValue $value) => $value->aggregate),
],
],
'labels' => $leadData->map(fn (TrendValue $value) => $value->date)
in my head that should work
Noor
Noor11mo ago
okay I'll try that thankyou so much @awcodes
Want results from more Discord servers?
Add your server
More Posts