nova-chartjs icon indicating copy to clipboard operation
nova-chartjs copied to clipboard

How to hide unknown line?

Open 4n70w4 opened this issue 5 years ago • 2 comments

Hi! I copy examples from readme and pass my parameters and data attributes:

    /**
     * Should return settings for Nova Chart in prescribed format
     *
     * @return array
     */
    public function getNovaChartjsSettings() : array {
        return [
            'default' => [
                'type' => 'line',
                'titleProp' => 'name',
                'identProp' => 'id',
                'height' => 400,
                'indexColor' => '#999999',
                'color' => '#FF0000',
                'parameters' => collect(self::data($this->getAttribute('id')))->pluck('k')->toArray(),
                'options' => ['responsive' => true, 'maintainAspectRatio' => false],
            ]
        ];
    }



    /**
     * Return a list of additional datasets added to chart
     *
     * @return array
     */
    public function getAdditionalDatasets(): array {
        return [
            'default' => [
                [
                    'label' => 'Distribution',
                    'borderColor' => '#f87900',
                    'fill' => '+1',
                    'backgroundColor' => 'rgba(20,20,20,0.2)',//For bar charts, this will be the fill color of the bar
                    'data' => collect(self::data($this->getAttribute('id')))->pluck('v')->toArray(),
                ],
            ]
        ];
    }

A line appears with the title of the Unknown. I don't understand how to remove it at all.

image

4n70w4 avatar Jan 13 '21 13:01 4n70w4

@4n70w4 Can you just confirm what the final dataset that's being sent to the panel is? From this screenshot, it looks like there might be an extra array key (possibly empty) in the dataset that's causing that Unknown element to be displayed.

dvanscott avatar Jan 13 '21 19:01 dvanscott

image

https://gist.github.com/4n70w4/4d6852fae2310c8bb0d8965b47e30ea2

4n70w4 avatar Jan 14 '21 09:01 4n70w4