<?php

namespace App\Document;

use App\Document\User;
use Doctrine\Bundle\MongoDBBundle\Validator\Constraints\Unique as MongoDBUnique;
use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
use Symfony\Component\Validator\Constraints as Assert;

#[MongoDB\Document(collection: 'charts')]
class Chart
{
    /**
     * @MongoDB\Id
     */
    #[MongoDB\Id]
    protected ?string $id = null;

    #[MongoDB\ReferenceOne(targetDocument: User::class, inversedBy: "charts")]
    protected $user;

    #[MongoDB\Field(type: 'string', options: ['default' => "Graf"])]
    #[Assert\NotBlank]
    protected string $name = "Graf";

    #[MongoDB\Field(type: 'raw')]
    #[Assert\NotBlank]
    protected $metadata = [
        "type" => "line",
        "margin" => 40,
        "xLabel" => "x",
        "yLabel" => "y",
        "displayLegend" => true,
        "displayPoints" => true,
        "displaySupport" => true,
        "backgroundColor" => "#f6f5f4",
        "title" => "Nadpis",
        "displayTitle" => true,
        "yStep" => 1,
        "displaySupportLines" => true,
        "displayAxisValues" => true,
        "pointSize" => 7,
        "titleFont" => ["font" => 'Courier New', "size" => 25],
        "labelFont" => ["font" => 'Georgia', "size" => 15],
        "legendFont" => ["font" => 'Arial', "size" => 10],
        "pointBorderSize" => 2,
        "pointBorderColor" => "#241f31",
        "horizontalZoom" => true,
        "lineWidth" => 3
    ];

    #[MongoDB\Field(type: 'hash')]
    #[Assert\NotBlank]
    protected array $table = [
        ['col_name' => 'sloupec 1','values' => [1,6,3, 2],'color' => '#ff0000'],
        ['col_name' => 'sloupec 2','values' => [4,2.5,-1, 1],'color' => '#57e389']
    ];

    public function getId(): string
    {
        return $this->id;
    }

    /**
     * Get the user associated with the chart.
     *
     * @return User
     */
    public function getUser(): ?User
    {
        return $this->user;
    }

    /**
     * Set the user associated with the chart.
     *
     * @param User $user The user to set
     */
    public function setUser(?User $user): void
    {
        $this->user = $user;
    }

    public function getName(): ?string
    {
        return $this->name;
    }

    public function setName(?string $name): void
    {
        $this->name = $name;
    }

    public function getMetadata()
    {
        return $this->metadata;
    }

    public function setMetadata($metadata): void
    {
        $this->metadata = $metadata;
    }

    public function getTable(): ?array
    {
        return $this->table;
    }

    public function setTable(?array $table): void
    {
        $this->table = $table;
    }
}