允许echart在组件内更换图标类型

This commit is contained in:
aixianling
2024-03-25 17:49:57 +08:00
parent 4c220621b5
commit 5273f300ea
4 changed files with 27 additions and 9 deletions

View File

@@ -15,6 +15,7 @@ export default {
data: {default: () => []},
ops: {default: () => ({})},
type: {default: "line"},
tpl: String,
series: Object,
theme: {
default: '0'
@@ -51,14 +52,13 @@ export default {
return ['#FFBA44', '#EC6666', '#FF3E18', '#C9FF82', '#29D7FA', '#ea7ccc']
},
chartOptions() {
let {type, data, ops: options = {}} = this,
style = this.series ? this.series : this.ops.daemon ? this.ops.daemon : {},
colors = this.theme === '1' ? this.colors : (options.color || this.colors),
legend = {textStyle: {color: '#fff', padding: [0, 0, 0, 8], fontSize: 14}, show: false},
series = data?.[0] ? Array(Object.keys(data?.[0]).length - 1).fill(1)
.map((e, i) => ({type, ...(typeof style == 'object' ? style : style(colors[i]))})) : []
.map((e, i) => ({type, ...(typeof style == 'object' ? style : style(colors[i]))})) : []
return {
tooltip: {},
xAxis: {
@@ -118,9 +118,11 @@ export default {
this.getChartData(oldDims != current)
}
},
theme() {
this.refresh()
},
tpl(v) {
v && this.refresh()
}
},
methods: {
@@ -149,7 +151,7 @@ export default {
if (copy && typeof copy == 'object') {
// 递归调用
target[name] = this.deepAssign( src, copy)
target[name] = this.deepAssign(src, copy)
} else if (copy !== undefined) {
target[name] = copy
}