This repository has been archived by the owner on May 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
liuwei
committed
Aug 19, 2019
1 parent
aee2a2c
commit a497f6f
Showing
6 changed files
with
140 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import echarts from 'echarts/lib/echarts' | ||
import AMapEcharts from './core/amap-echarts' | ||
import AMapCoordinate from './core/amap-coordinate' | ||
import forBidAnimation from './plugins/forbid-animation' | ||
import ForbidAnimation from './plugins/forbid-animation' | ||
|
||
// 注册坐标系 | ||
echarts.registerCoordinateSystem('amap', AMapCoordinate) | ||
|
||
// 注册插件 | ||
AMapEcharts.register(forBidAnimation) | ||
AMapEcharts.registerPlugin(new ForbidAnimation()) | ||
|
||
export default AMapEcharts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/** | ||
* 插件基类 | ||
*/ | ||
import EventNames from '../core/amap-events' | ||
|
||
const toString = obj => { | ||
const values = [] | ||
for (const key in obj) { | ||
if (obj.hasOwnProperty(key)) { | ||
values.push(obj[key]) | ||
} | ||
} | ||
return values.join(', ') | ||
} | ||
|
||
// 为了让 `vscode` 有提示 | ||
export const PluginTypes = Object.assign({}, EventNames) | ||
|
||
for (const key in PluginTypes) { | ||
if (PluginTypes.hasOwnProperty(key) && key.indexOf('__') > -1) { | ||
delete PluginTypes[key] | ||
} | ||
} | ||
|
||
export default class PluginBase { | ||
constructor() { | ||
const type = this.getType() | ||
if (type) { | ||
if (!PluginTypes[type.toUpperCase()]) { | ||
throw new Error( | ||
`type property is '${type}', but expect one of [ ${toString( | ||
PluginTypes | ||
)} ]` | ||
) | ||
} | ||
} else { | ||
throw new Error('type property must not be empty') | ||
} | ||
} | ||
|
||
getType() { | ||
throw new Error('getType function is not implemented') | ||
} | ||
|
||
// eslint-disable-next-line no-unused-vars | ||
apply(instance) { | ||
throw new Error('apply function is not implemented') | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,20 @@ | ||
import PluginBase, { PluginTypes } from './base' | ||
|
||
/** | ||
* 禁止动画效果,防止地图移动缩放时 echarts 刷新不及时 | ||
* | ||
* @param {object} options 参数 | ||
*/ | ||
export default function forbidAnimation(options) { | ||
const { series } = options | ||
if (series) { | ||
series.forEach(item => { | ||
if (item.coordinateSystem === 'amap') { | ||
item.animation = false | ||
} | ||
}) | ||
export default class ForbidAnimation extends PluginBase { | ||
getType() { | ||
return PluginTypes.UPDATE | ||
} | ||
apply(instance) { | ||
const { series } = instance.getOption() | ||
if (series) { | ||
series.forEach(item => { | ||
if (item.coordinateSystem === 'amap') { | ||
item.animation = false | ||
} | ||
}) | ||
} | ||
} | ||
return options | ||
} |