我目前正在使用图书馆 ApexChart更特别的是 Vue 顶点图表与 nuxt 相结合。
我正在构建一个仪表板,我正在尝试构建一个由以下内容组成的混合图表:
- 面积图
- 条形图
- 折线图
三个图表按以下顺序显示(从后到前):区域 - 条形 - 线
我想更改顺序以使条形图靠后,但我不知道该怎么做。
我试过的
我尝试更改系列的顺序以将条形图放在最后
series() {
return [
{
name: 'My Line chart',
type: 'line',
data: this.capacityCalls
},
{
name: 'My Area Chart',
type: 'area',
data: this.callsRealProd
},
{
name: 'My Bar Chart',
type: 'bar',
data: this.callsToMake
},
]
},
最小可重现示例
这是一个最小的可重现事件。
<template>
<VueApexCharts type="line" height="700" :options="chartOptions" :series="series" />
</template>
<script>
export default {
name: "Hello",
data: () => {
return {
series: [{
name: 'TEAM A',
type: 'line',
data: [23, 11, 22, 27, 13, 22, 37, 21, 44, 22, 30]
}, {
name: 'TEAM B',
type: 'area',
data: [44, 55, 41, 67, 22, 43, 21, 41, 56, 27, 43]
}, {
name: 'TEAM C',
type: 'bar',
data: [30, 25, 36, 30, 45, 35, 64, 52, 59, 36, 39]
}],
chartOptions: {
colors: ['#F44E7C','#FBBC04','#49619C'],
plotOptions: {
bar: {
columnWidth: '100%'
}
},
stroke: {
curve: 'smooth',
width: [3, 3, 1]
},
fill: {
opacity: [1, 0.6, 0.2]
},
},
}
},
}
</script>
我正在使用 nuxt.js 并通过以下插件加载 npm 库 apexChart:
import Vue from 'vue'
import VueApexCharts from 'vue-apexcharts'
Vue.component('VueApexCharts', VueApexCharts);
最佳答案
它可能会在每个图表分别完成加载时依次添加它们。如何为每个图表创建一个单独的组件并通过在模板中定义组件来定义顺序?
<line-chart></line-chart>
<area-chart></area-chart>
<bar-chart></bar-chart>
关于javascript - 混合图表中的顶点图表图表顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70078359/