Skip to content

Repository files navigation

silverstripe-gridfield-chart

A SilverStripe GridField component that renders a uPlot line chart above or below any GridField, based on a live COUNT or SUM query against the GridField's model table.

Installation

composer require hamaka/silverstripe-gridfield-chart

Usage

Add the component to any GridField config:

use Hamaka\GridFieldChart\GridFieldUPlotGraph;

$gridField->getConfig()->addComponent(
    GridFieldUPlotGraph::create(
        sTargetFragment: 'before',
        sSeriesLabel:    'Registrations',
        iDaysBack:       30,
        aExtraFilters:   ['Status' => 'Active'],
    )
);

Constructor parameters

Parameter Type Default Description
sTargetFragment string 'before' Where to render: 'before' or 'after'
sSeriesLabel string 'Records' Series label shown in the chart legend
sSumField ?string null Field to SUM; null uses COUNT(*)
iDaysBack int 30 Number of days to include
sDateField string 'Created' Date column to group by
aExtraFilters array [] Additional WHERE conditions, e.g. ['Status' => 'Active']
sStrokeColor string '#004e7f' Line colour
sFillColor string 'rgba(0,78,127,0.1)' Fill colour under the line

All parameters also have fluent setters, e.g. ->setDaysBack(60).

License

BSD-3-Clause

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages