F
Filament16mo 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
awcodes16mo 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
NoorOP16mo 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
awcodes16mo ago
can you provide your widget code?
Noor
NoorOP16mo ago
Noor
NoorOP16mo ago
Noor
NoorOP16mo ago
Noor
NoorOP16mo ago
@awcodes
awcodes
awcodes16mo 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
NoorOP16mo ago
and labels like this ? 'labels' => $submissionData->map(fn (TrendValue $value) => $value->date), 'labels' => $leadData->map(fn (TrendValue $value) => $value->date), @awcodes
awcodes
awcodes16mo ago
you can only have one set of labels
Noor
NoorOP16mo ago
then it shows data error
awcodes
awcodes16mo ago
but since both would have the same dates you could use either one for the lables
Noor
NoorOP16mo ago
undefined variable $data
awcodes
awcodes16mo 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
NoorOP16mo ago
okay I'll try that thankyou so much @awcodes
Want results from more Discord servers?
Add your server