提交 c65f335a authored 作者: lidongxu's avatar lidongxu

feat(gradientarea): 新增面积图转折线图效果

同上
上级 8e547f4f
...@@ -34,10 +34,23 @@ const props = defineProps({ ...@@ -34,10 +34,23 @@ const props = defineProps({
const echartsRef = ref(null) const echartsRef = ref(null)
const chart = shallowRef(null) const chart = shallowRef(null)
let myThousand = false // 是否显示万单位 let myThousand = false // 是否显示万单位
let isArea = ref(true) // 是否面积图
const emits = defineEmits(['changeType']) const emits = defineEmits(['changeType'])
const setOptions = () => { const setOptions = () => {
// 面积图是否切换
const seriesResult = props.chartData.series.map(o => {
if (!isArea.value) {
const obj = {...o}
delete obj.areaStyle
delete obj.lineStyle
return obj
} else {
return o
}
})
chart.value.setOption({ chart.value.setOption({
tooltip: { tooltip: {
trigger: 'axis', trigger: 'axis',
...@@ -87,6 +100,14 @@ const setOptions = () => { ...@@ -87,6 +100,14 @@ const setOptions = () => {
onclick: () => { onclick: () => {
emits('changeType', 'table') emits('changeType', 'table')
} }
},
myTool2: {
show: true,
title: '面积/折线图',
icon: 'path://M5,5 L5,30 L15,30 L25,20 L35,30 L45,30 L45,5 Z',
onclick: () => {
isArea.value = !isArea.value
}
} }
} }
}, },
...@@ -108,7 +129,7 @@ const setOptions = () => { ...@@ -108,7 +129,7 @@ const setOptions = () => {
type: 'value' type: 'value'
} }
], ],
series: props.chartData.series series: seriesResult
}, true) }, true)
} }
......
...@@ -34,10 +34,22 @@ const props = defineProps({ ...@@ -34,10 +34,22 @@ const props = defineProps({
const echartsRef = ref(null) const echartsRef = ref(null)
const chart = shallowRef(null) const chart = shallowRef(null)
let myThousand = false // 是否显示万单位 let myThousand = false // 是否显示万单位
let isArea = ref(true) // 是否面积图
const emits = defineEmits(['changeType']) const emits = defineEmits(['changeType'])
const setOptions = () => { const setOptions = () => {
// 面积图是否切换
const seriesResult = props.chartData.series.map(o => {
if (!isArea.value) {
const obj = { ...o }
delete obj.areaStyle
delete obj.lineStyle
return obj
} else {
return o
}
})
chart.value.setOption({ chart.value.setOption({
tooltip: { tooltip: {
trigger: 'axis', trigger: 'axis',
...@@ -87,6 +99,14 @@ const setOptions = () => { ...@@ -87,6 +99,14 @@ const setOptions = () => {
onclick: () => { onclick: () => {
emits('changeType', 'table') emits('changeType', 'table')
} }
},
myTool2: {
show: true,
title: '面积/折线图',
icon: 'path://M5,5 L5,30 L15,30 L25,20 L35,30 L45,30 L45,5 Z',
onclick: () => {
isArea.value = !isArea.value
}
} }
} }
}, },
...@@ -108,7 +128,7 @@ const setOptions = () => { ...@@ -108,7 +128,7 @@ const setOptions = () => {
type: 'value' type: 'value'
} }
], ],
series: props.chartData.series series: seriesResult
}, true) }, true)
} }
......
<template> <template>
<div class="dashboard-editor-container app-container"> <div class="dashboard-editor-container app-container">
<panel-group @handleSetLineChartData="handleSetLineChartData" /> <panel-group @handleSetLineChartData="handleSetLineChartData" />
<div class="row"> <common-menu class="row"></common-menu>
<common-menu></common-menu> <el-row :gutter="32"
</div> class="row">
<el-row :gutter="32" class="row">
<el-col :xs="24" <el-col :xs="24"
:sm="24" :sm="24"
:lg="8"> :lg="8">
...@@ -29,7 +27,7 @@ ...@@ -29,7 +27,7 @@
</el-col> </el-col>
</el-row> </el-row>
<el-row class="line-chart row"> <el-row class="line-chart row">
<line-chart :chartData="lineChartData"/> <line-chart :chartData="lineChartData" />
</el-row> </el-row>
</div> </div>
</template> </template>
...@@ -69,7 +67,7 @@ const handleSetLineChartData = (type) => { ...@@ -69,7 +67,7 @@ const handleSetLineChartData = (type) => {
<style lang="scss" <style lang="scss"
scoped> scoped>
.dashboard-editor-container { .dashboard-editor-container {
.row{ .row {
margin-top: 20px; margin-top: 20px;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论