Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Charts stop working when adding series in chart options #13

Open
darkons opened this issue May 15, 2024 · 0 comments
Open

Charts stop working when adding series in chart options #13

darkons opened this issue May 15, 2024 · 0 comments

Comments

@darkons
Copy link

darkons commented May 15, 2024

For some reason, adding series inside options object makes the chart stop working when update.

Using Laravel 10 + Inertia Vue stack.

$chart = new Chart();

return Inertia::render('Dashboard', [ 
    'chart' => fn () => $chart->setType('bar')
        ->setHeight(300)
        ->setWidth('100%')
        ->setDataset('Some name', 'bar', [1])
        ->setXaxisCategories(['Some category'])
        ->toVue()
]);
<script setup>
  defineProps({
    chart: Object,
  });
  
  const updateChart = () => {
    router.reload({
      only: ['chart'],
    })
  }
</script>

<template>
  <apexchart
    :type="chart.type"
    :width="chart.width"
    :height="chart.height"
    :series="chart.series"
    :options="chart.options"
  />
  
  <button @click="updateChart()">Update</button>
</template>

This example will break the chart throwing DOMException: Proxy object could not be cloned. in the browser console.

After commenting out this lines in Chart.php class, everything works fine:

public function setSeries(array $series): Chart
{
    $this->series = $series;

    /* $this->setOption([
        'series' => $series,
    ]); */

    return $this;
}

If you need more information, please just ask me 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant