Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Async charts for cases when data/series calculation is heavy (separate chart instantiation and calculation) #118

Open
alies-dev opened this issue Jan 20, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@alies-dev
Copy link

alies-dev commented Jan 20, 2022

Is your feature request related to a problem? Please describe.
If a chart requires heavy to calculate data, the whole page will be empty unless data calculate. This is how response of available cards looks like (for dashboard, UEL example /nova-api/dashboards/users):
image

Describe the solution you'd like
What Nova does with their default charts is to serialise meta data about the Metric and then associated vue component produces a request to fetch data for the Metric.

I tried to use LineChart is the same fashion:

final class MembershipLifetimeLIneChart extends Metric

    /** This method is called by {@see \Laravel\Nova\Metrics\Metric::resolve} */
    public function calculate(Request $request): \JsonSerializable
    {
        return LineChart::make()
            ->title($this->name())
            ->series([
                [...

but it also requires to update vue components to support such behaviour: existing components can't parse metric metadata and then produce an API request.

Nova bug makes it even more important

For every request to a Metric, added to a dashboard, Nova calls public static function allAvailableDashboardCards(NovaRequest $request) that initialises all cards and metrics. In case of this package that means if you have 20 charts on a dashboard, Nova will initialise them 20*20 times. Of course, that means a lot of DB queries if you fetch info for charts from DB. Implementation of this feature will solve this problem: chart instantiation and calculation will be different processes

@alies-dev alies-dev added the enhancement New feature or request label Jan 20, 2022
@bkuhl
Copy link

bkuhl commented Jan 4, 2023

I'm glad I saw this, thank you, I'll have to hold off on this package for now. I was wondering if this was the case given how the docs didn't suggest to build an object for each metric, but put it directly in the dashboard object itself...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants