Chart Widget - Multiple results

Hello! I'm having a problem creating a widget. I'm grouping visits based on the "from" field, and I need to display the results for each month, but broken down into the top 5 types of visits with the most records. For example, "from" Google, Facebook, Instagram, Pinterest, Direct, and the rest we categorize as "OTHER." The issue is that I'm not able to display them correctly. The month doesn't match, or it only shows the total. What am I doing wrong? Thank you very much. Here's the code. Could you provide the code you're working with?
No description
No description
No description
4 Replies
Filament
Filament15mo ago
Please read the #✅┊rules about how to format your code properly.
Salah Kanjo
Salah Kanjo15mo ago
GitHub
GitHub - sakanjo/laravel-easy-metrics: Generate metrics with ease a...
Generate metrics with ease and precision. Contribute to sakanjo/laravel-easy-metrics development by creating an account on GitHub.
lucianosnchz
lucianosnchzOP15mo ago
With EasyMetrics: Could you give me an example with two labels? I want two different metrics to appear along the one-month curve. Where the X axis is time and the y axis is quantity.
Salah Kanjo
Salah Kanjo15mo ago
just create two instances of the Trend and pass it to datasets Something like:
[$adminLabels, $adminData] = Trend::make(\App\Models\Admin::class)
->range($this->filter)
->rangesFromOptions($this->getFilters())
->countByMonths();

[$userLabels, $userData] = Trend::make(\App\Models\User::class)
->range($this->filter)
->rangesFromOptions($this->getFilters())
->countByMonths();
[$adminLabels, $adminData] = Trend::make(\App\Models\Admin::class)
->range($this->filter)
->rangesFromOptions($this->getFilters())
->countByMonths();

[$userLabels, $userData] = Trend::make(\App\Models\User::class)
->range($this->filter)
->rangesFromOptions($this->getFilters())
->countByMonths();
and pass the data to datasets array

Did you find this page helpful?