marineusde / larapex-charts

A Laravel wrapper for apex charts
https://github.com/marineusde/larapex-charts
MIT License
1 stars 2 forks source link

->setOptions doesn't work #21

Closed lukejames1111 closed 5 days ago

lukejames1111 commented 2 months ago

Continuing from this thread.

I am trying to add basic options to the chart, but when I try to use the chart I received Call to undefined method marineusde\LarapexCharts\Charts\LineChart::setOptions()

Here's my most basic example

use marineusde\LarapexCharts\Charts\LineChart AS OriginalLineChart;

class AverageTimeOnMarketChart
{
    public function build(): OriginalLineChart
    {
        $options = [
            'yaxis' => [
                'decimalsInFloat' => 0,
            ]
        ];

        return (new OriginalLineChart)
            ->setXAxis(['January'])
            ->addData('Time on Market', ['10'])
            ->setOptions($options)
        ;
    }
}

The only way I can get options to work is if I edit the LarapexChart.php getDefaultOptions() directly.

marineusde commented 1 month ago

I fixed it some weeks ago, but didnt publish a release, sorry.

You can do it in 1.3.2 with the method "setAdditionalOptions":

use marineusde\LarapexCharts\Charts\LineChart AS OriginalLineChart;

class AverageTimeOnMarketChart
{
    public function build(): OriginalLineChart
    {
        $options = [
            'yaxis' => [
                'decimalsInFloat' => 0,
            ]
        ];

        return (new OriginalLineChart)
            ->setXAxis(['January'])
            ->addData('Time on Market', ['10'])
            ->setAdditionalOptions($options)
        ;
    }
}