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

updateOptions forget other properties when called? #126

Open
cnicodeme opened this issue Oct 22, 2024 · 0 comments
Open

updateOptions forget other properties when called? #126

cnicodeme opened this issue Oct 22, 2024 · 0 comments

Comments

@cnicodeme
Copy link

Hi team

I'm setting up my charts the following way:

<template>
    <div class="app">
        <apexchart ref="myChart" :options="{ chart: { type: 'line' } }" :series="[]"></apexchart>
    </div>
</template>

<script>
export default {
    created () {
        this.loadData ()
    },
    mounted () {
        this.$refs.myChart.updateOptions({ ... all the properties goes here })
    },
    methods: {
        loadData () {
            const data = $fetch('...')
            const series = this.buildSeries(data)
            const categories = this.buildCategories(data)
            const colors = this.buildColors(data)
            const max = this.getMaxFromSeries(series)
            this.$refs.myChart.updateOptions({
                xaxis: { categories },
                yaxis: {
                    max: Math.ceil(max + (max * 0.1)) // Set the yaxis max to the highest value + 10%:
                },
                colors,
                series
            })
        }
    }
}
</script>

Oddly, when I do this that way, all my properties set on the mounted function are lost, such as setting the "min" value to the yaxis, yaxis:labels:formatted, etc.

Why is that? The documentation says that calling updateOptions will keep the existing options and update only the changed one, why is that not occurring here ?

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