提交 3f5d2bee authored 作者: junjie's avatar junjie

feat(视图): 视图组件临时封装

上级 d50fbd21
export function baseBarOption(chart_option, chart) {
// 处理data
if (chart.data) {
chart_option.title.text = chart.title
chart_option.xAxis.data = chart.data.x
chart.data.series.forEach(function(y) {
chart_option.legend.data.push(y.name)
chart_option.series.push(y)
})
}
// console.log(chart_option);
// 处理shape attr
if (chart.customAttr) {
const customAttr = JSON.parse(chart.customAttr)
if (customAttr.color) {
chart_option.color = customAttr.color.colors
}
}
return chart_option
}
export function baseLineOption(chart_option, chart) {
// 处理data
if (chart.data) {
chart_option.title.text = chart.title
chart_option.xAxis.data = chart.data.x
chart.data.series.forEach(function(y) {
chart_option.legend.data.push(y.name)
chart_option.series.push(y)
})
}
// console.log(chart_option);
// 处理shape attr
if (chart.customAttr) {
const customAttr = JSON.parse(chart.customAttr)
if (customAttr.color) {
chart_option.color = customAttr.color.colors
}
}
return chart_option
}
......@@ -6,6 +6,8 @@
<script>
import { BASE_BAR, BASE_LINE } from '../chart/chart'
import { baseBarOption } from '../chart/bar/baseBar'
import { baseLineOption } from '../chart/line/baseLine'
export default {
name: 'ChartComponent',
......@@ -35,28 +37,11 @@ export default {
let chart_option = {}
// todo type
if (chart.type === 'bar') {
chart_option = JSON.parse(JSON.stringify(BASE_BAR))
chart_option = baseBarOption(JSON.parse(JSON.stringify(BASE_BAR)), chart)
} else if (chart.type === 'line') {
chart_option = JSON.parse(JSON.stringify(BASE_LINE))
chart_option = baseLineOption(JSON.parse(JSON.stringify(BASE_LINE)), chart)
}
// console.log(chart_option);
// 处理data
if (chart.data) {
chart_option.title.text = chart.title
chart_option.xAxis.data = chart.data.x
chart.data.series.forEach(function(y) {
chart_option.legend.data.push(y.name)
chart_option.series.push(y)
})
}
// console.log(chart_option);
// 处理shape attr
if (chart.customAttr) {
const customAttr = JSON.parse(chart.customAttr)
if (customAttr.color) {
chart_option.color = customAttr.color.colors
}
}
this.myEcharts(chart_option)
},
myEcharts(option) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论