Skip to content
This repository has been archived by the owner on May 15, 2023. It is now read-only.

Commit

Permalink
feat(core): 扩展实例配置,修改主题配置方式,防止存在多个版本的 echarts 时主题配置无效
Browse files Browse the repository at this point in the history
  • Loading branch information
liuwei committed Aug 21, 2019
1 parent dff4a2c commit c9d1041
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
13 changes: 10 additions & 3 deletions src/libs/core/amap-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@ export default class AMapContainer {
visible = true
disposed = false

constructor(map) {
constructor(
options = {
map: null,
zIndex: 0,
opacity: 1,
zooms: [0, 0]
}
) {
this.promise = new Promise((resolve, reject) => {
try {
AMap.plugin('AMap.CustomLayer', () => {
Expand All @@ -20,9 +27,9 @@ export default class AMapContainer {
}
const container = document.createElement('div')
this.layer = new AMap.CustomLayer(container, {
map,
zIndex: 120,
alwaysRender: false
alwaysRender: false,
...options
})
this.container = container
this._setSize()
Expand Down
14 changes: 11 additions & 3 deletions src/libs/core/amap-echarts.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ const config = (
}
}
) => {
AMapEcharts._configs = options
let { theme } = options
if (theme && typeof theme === 'object') {
echarts.registerTheme(theme.name, theme)
theme = theme.name
}
AMapEcharts._configs = { theme, ...options }
}

export default class AMapEcharts extends events {
Expand All @@ -75,7 +80,10 @@ export default class AMapEcharts extends events {
constructor(map, configs) {
super()
this._configs = configs
this._amapContainer = new _amapContainer(map)
this._amapContainer = new _amapContainer({
map,
...config
})
this._amapContainer.ready(() => {
// 用户销毁的时候可能还没加载完,此处需要再次销毁
if (this._disposed) {
Expand Down Expand Up @@ -153,7 +161,7 @@ export default class AMapEcharts extends events {
this._amapContainer.hide()
}

getConfigs() {
getConfig() {
return this._configs
}

Expand Down

0 comments on commit c9d1041

Please sign in to comment.