我正在尝试将 apexcharts 导入到我的 nuxt 项目中。我同时使用了 vanilla lib 和 vue 包装器。简单的导入库会导致以下错误
就像我说的,我已经尝试导入
import ApexCharts from "apexcharts"
和
import VueApexCharts from "vue-apexcharts"
两者都返回相同的错误。这是我必须在 nuxt.config.js 文件中配置的东西吗?
我正在尝试让 ApexCharts 在我的 Vue 项目(我使用 Vue3)上运行,但我遇到了饼图/圆环图问题。如果我将模板标签下的类型更改为,下面的代码将起作用 "bar"
<template>
<div>
<apexchart v-if="loaded" width="500" type="pie" :options="chartOptions" :series="series"></apexchart>
</div>
</template>
<script>
export default {
data() {
return {
loaded:true,
series: [{
data:[23, 11, 54, 72, 12]
}],
chartOptions: {
labels: ["Apple", "Mango", "Banana", "Papaya", "Orange"],
dataLabels: {
enabled: true
},
responsive: [{
breakpoint: 480,
options: {
chart: {
width: 200
},
legend: {
positon:'bottom',
show: false
}
}
}],
}
}
}
};
</script>
Run Code Online (Sandbox Code Playgroud)
我需要使用饼图和圆环图以及从 API 获取的数据,但即使使用静态硬编码数据也无法运行。
我已经使用ApexCharts库构建了一个图表,并且我想禁用拖动图表的可能性。我应该如何更新我的配置(见下文)?我在文档中找不到任何详细信息。这是我的图表:
//My component
<Chart
options={performanceLineChart.options}
series={performanceLineChart.series}
/>
//My configurations
export const performanceLineChart = {
options: {
chart: {
id: 'my-chart',
type: 'line' as 'line',
toolbar: {
show: false //Disable toolbar
}
},
stroke: {
width: 5,
curve: 'smooth' as 'smooth'
},
markers: {
size: 4,
hover: {
size: undefined,
sizeOffset: 2
}
},
xasis: {
type: 'numeric',
}
},
series: [{
name: 'Line 1',
data: [
[3066, 323],
[6317, 312],
[12498, 313],
[24091, 326]
]
},{
name: 'Line …Run Code Online (Sandbox Code Playgroud) apexcharts ×4
javascript ×3
reactjs ×2
vue.js ×2
charts ×1
icons ×1
nuxt.js ×1
typescript ×1
vuejs3 ×1