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

breaks if update the height #135

Open
NeluQi opened this issue Dec 9, 2024 · 1 comment
Open

breaks if update the height #135

NeluQi opened this issue Dec 9, 2024 · 1 comment

Comments

@NeluQi
Copy link

NeluQi commented Dec 9, 2024

The chart breaks if you update the height

I have

<VueApexChart
width="100%"
:type="optionsChart.chart.type"
:height="`${settings.chartHeight ?? 200}px`"
:options="optionsChart"
:series="optionsChart.series ?? []"
/>

When the chartHeight change- the chart disappears

@duduyo
Copy link

duduyo commented Jan 17, 2025

Same thing for me.
I found this workaround : use the height attribute only for the first display (ie provide a non reactive value), and then update it via the options object (use a reactive value).

Extract of my code :

<template>
            <apexchart
                :height="myHeight"
                :options="myOptions"
                :series="mySeries"
            ></apexchart>
</template>
<script setup lang="ts">
interface Props {
    height: number;
    options: ApexOptions;
    series: ApexAxisChartSeries;
}
const props = defineProps<Props>();

const myHeight = prop.height;  // this one is not reactive - won't change
const myOptions = computed<ApexOptions>(() => {
    chart: {
        height: prop.height;  // this one is reactive thanks to the computed
    ...
    },
    ....
});

</script>

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

2 participants