Skip to content

ChartJsDataset

Viames Marino edited this page Feb 23, 2026 · 1 revision

Pair framework: ChartJsDataset

Pair\Helpers\ChartJsDataset represents one dataset definition for ChartJs.

Main methods

  • label(string $label): self
  • type(string $type): self
  • backgroundColors(array $colors): self
  • colorFunction(callable $callback): self
  • borderColor(string $color): self, borderWidth(int $width): self
  • fill(bool $fill): self, pointRadius(int $radius): self
  • interpolation(string $mode = 'default', float $tension = 0.4): self
  • labels(array $labels): self
  • export(): array

Implementation example

$dataset = (new \Pair\Helpers\ChartJsDataset([34, 28, 41], 'Sales'))
    ->type('line')
    ->borderColor('#1f77b4')
    ->borderWidth(2)
    ->fill(false)
    ->labels(['Jan', 'Feb', 'Mar']);

$configDataset = $dataset->export();

Notes

  • Designed to compose cleanly with ChartJs helper output.

See also: ChartJs.

Clone this wiki locally