CoolCMS API

StatisticsBucketLabels
in package

FinalYes

Single implementation of x-axis bucket labels for the ChartJS statistics (orders, products, imports).

The key must match the MySQL DATE_FORMAT expression used in SQL (%x-%v equals PHP o-W), otherwise a series does not line up with the axis.

Table of Contents

Methods

build()  : array<int|string, string>
Builds the `bucketKey => label` map for the whole `from..to` range, including empty buckets.

Methods

build()

Builds the `bucketKey => label` map for the whole `from..to` range, including empty buckets.

public static build(DateTimeInterface $from, DateTimeInterface $to, string $granularity) : array<int|string, string>

For week the cursor snaps to the Monday of the ISO week containing from and runs through the week containing to, so a partial first and last week still get a key (the SQL filter trims the range itself).

Parameters
$from : DateTimeInterface
$to : DateTimeInterface
$granularity : string
Return values
array<int|string, string> —

numeric keys (year) are cast to int by PHP

On this page

Search results