Skip to content

Novis\Spreadsheet\Chart::Kind

The type of a chart.

Each case of the enum has a method of Chart that makes a chart of that type:

  • Column is Chart::column, vertical bars.
  • Bar is Chart::bar, horizontal bars.
  • Line is Chart::line, the values of each series joined by a line.
  • Area is Chart::area, a line chart with the space under each line filled.
  • Pie is Chart::pie, and Doughnut is Chart::doughnut, a pie with a hole in the middle.
  • Scatter is Chart::scatter, points with an x value and a y value.

The property kind of a Chart is its type. A chart made with combinedWith keeps the type of the first chart. Only Column, Line and Area charts can be combined. A combined chart has two different types from these three.

Examples

The type of each chart

<?nvs
// Shows the `Chart::Kind` of a column chart, a pie chart, a scatter chart and a combined chart.
use Novis\Spreadsheet\Chart;
class Kinds
{
public static function name(Chart::Kind $kind): string
{
return match ($kind) {
Chart::Kind::Column => 'Column',
Chart::Kind::Bar => 'Bar',
Chart::Kind::Line => 'Line',
Chart::Kind::Area => 'Area',
Chart::Kind::Pie => 'Pie',
Chart::Kind::Doughnut => 'Doughnut',
Chart::Kind::Scatter => 'Scatter',
};
}
}
// `kind` is the type of the chart. This prints "Column", "Pie" and "Scatter".
array<Chart> $charts = [Chart::column(), Chart::pie(), Chart::scatter()];
foreach ($charts as Chart $chart) {
echo Kinds::name($chart->kind), "\n";
}
// `combinedWith` keeps the type of the first chart. This prints "Column".
var $both = Chart::column()->withSeries('B2:B9')->combinedWith(Chart::line()->withSeries('C2:C9'));
echo Kinds::name($both->kind), "\n";
Output
Column
Pie
Scatter
Column