Time-based

This is the official documentation of the forestadmin/laravel-forestadmin v2+ and forestadmin/symfony-forestadmin PHP agents.

Time-based charts are very similar to distribution charts, the only differences being that:

  • An additional parameter tells the frontend if the dates should be displayed by Day, Week, Month, or Year,

  • The keys of the returned object must be ISO-8601 compliant dates.

use ForestAdmin\AgentPHP\DatasourceCustomizer\Context\AgentCustomizationContext;
use ForestAdmin\AgentPHP\DatasourceCustomizer\Decorators\Chart\ResultBuilder;

$forestAgent->addChart(
    'transactionVolume',
    fn(AgentCustomizationContext $context, ResultBuilder $resultBuilder) => $resultBuilder->timeBased(
        'Month',
        [
            '2017-02-01' => 636,
            '2017-03-01' => 740,
            '2017-04-01' => 648,
            '2017-05-01' => 726,
        ]
    )
);

Last updated