XyChart Class

class XyChart

Represents an XY Chart

render(array $attributes)

Render the Mermaid code enclosed in a <pre> tag

Parameters:
  • $attributes (array) – HTML attributes for the enclosing <pre> tag

Returns:

Mermaid code enclosed in a <pre> tag

Return type:

string

addDataset(DatasetType $type, array $data)

Add a dataset

Parameters:
  • $type (DatasetType) – The dataset type

  • $data (array) – The dataset

Returns:

A new instance of XyChart with the dataset

Return type:

XyChart

withTitle(string $title)

Set the chart title

Parameters:
  • $title (string) – The title

Returns:

A new instance of XyChart with the title

Return type:

XyChart

withOrientation(Orientation $orientation)

Set the chart orientation

The default chart orientation is Orientation::vertical

Parameters:
Returns:

A new instance of XyChart with the orientation set

Return type:

XyChart

withXAxis(?string $title = null, array|int|null $min = null, ?int $max = null)

Define the chart X-axis

Parameters:
  • $title (?string) – The X-axis title

  • $min (array|int|null) – Array of categories or minimum value

  • $max (?int) – Maximum value; only used if $min is int

Returns:

A new instance of XyChart with the X-axis defined

Return type:

XyChart

withYAxis(?string $title = null, ?int $min = null, ?int $max = null)

Define the chart Y-axis

Parameters:
  • $title (?string) – The Y-axis title

  • $min (?int) – Minimum value

  • $max (?int) – Maximum value

Returns:

A new instance of XyChart with the Y-axis defined

Return type:

XyChart