forked from github/dataease
feat(视图): 视图组件临时封装
This commit is contained in:
parent
d50fbd21ca
commit
3f5d2bee53
21
frontend/src/views/chart/chart/bar/baseBar.js
Normal file
21
frontend/src/views/chart/chart/bar/baseBar.js
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
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
|
||||||
|
}
|
||||||
|
|
21
frontend/src/views/chart/chart/line/baseLine.js
Normal file
21
frontend/src/views/chart/chart/line/baseLine.js
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
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>
|
<script>
|
||||||
import { BASE_BAR, BASE_LINE } from '../chart/chart'
|
import { BASE_BAR, BASE_LINE } from '../chart/chart'
|
||||||
|
import { baseBarOption } from '../chart/bar/baseBar'
|
||||||
|
import { baseLineOption } from '../chart/line/baseLine'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'ChartComponent',
|
name: 'ChartComponent',
|
||||||
@ -35,28 +37,11 @@ export default {
|
|||||||
let chart_option = {}
|
let chart_option = {}
|
||||||
// todo type
|
// todo type
|
||||||
if (chart.type === 'bar') {
|
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') {
|
} 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);
|
// 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)
|
this.myEcharts(chart_option)
|
||||||
},
|
},
|
||||||
myEcharts(option) {
|
myEcharts(option) {
|
||||||
|
Loading…
Reference in New Issue
Block a user