<?php

namespace Shm\ShmTypes\CompositeTypes;

use Shm\Shm;
use Shm\ShmTypes\StructureType;

class VizType extends StructureType
{
    public string $type = 'viz';


    public bool $compositeType = true;



    public static $viz = null;


    public const VIZ_TYPES = [
        'line',
        'bar',
        'pie',
        'doughnut',
        'polarArea',
        'radar',
    ];

    public function __construct($viz)
    {


        if (!in_array($viz, self::VIZ_TYPES)) {
            throw new \Exception("Invalid viz type: " . $viz);
        }

        self::$viz = $viz;


        parent::__construct([
            'values' => Shm::arrayOf(
                Shm::structure([
                    'key' => Shm::mixed(),
                    'value' => Shm::mixed(),
                ])->staticBaseTypeName("VizValueItem")
            )

        ]);
    }
}
