Skip to content

Commit

Permalink
release: v1.11.0
Browse files Browse the repository at this point in the history
  • Loading branch information
plainheart committed Sep 30, 2022
1 parent 14485d1 commit a6df526
Show file tree
Hide file tree
Showing 20 changed files with 530 additions and 166 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

[Online example on CodePen](https://codepen.io/plainheart/pen/qBbdNYx)

This is an AMap extension for [Apache ECharts](https://echarts.apache.org/en/index.html) which is used to display visualizations such as [Scatter](https://echarts.apache.org/en/option.html#series-scatter), [Lines](https://echarts.apache.org/en/option.html#series-lines), [Heatmap](https://echarts.apache.org/en/option.html#series-heatmap).
This is an AMap extension for [Apache ECharts](https://echarts.apache.org/en/index.html) which is used to display visualizations such as [Scatter](https://echarts.apache.org/en/option.html#series-scatter), [Lines](https://echarts.apache.org/en/option.html#series-lines), [Heatmap](https://echarts.apache.org/en/option.html#series-heatmap), and [Pie](https://echarts.apache.org/en/option.html#series-pie).

### Examples

Expand All @@ -26,6 +26,10 @@ Lines: [examples/lines.html](https://github.com/plainheart/echarts-extension-ama

![Preview-Lines](https://user-images.githubusercontent.com/26999792/101313379-fca43c80-3890-11eb-9dea-46230dc432d5.gif)

Pie: [examples/pie.html](https://github.com/plainheart/echarts-extension-amap/blob/master/examples/pie.html) (**Since v1.11.0**)

![Preview-Pie](https://user-images.githubusercontent.com/26999792/193215980-cd6736f5-a63d-4085-8012-d519e9e78398.png)

### Installation

```shell
Expand Down Expand Up @@ -70,7 +74,7 @@ Use the latest version

Use a specific version

[https://cdn.jsdelivr.net/npm/echarts-extension-amap@1.10.1/dist/echarts-extension-amap.min.js](https://cdn.jsdelivr.net/npm/echarts-extension-amap@1.10.1/dist/echarts-extension-amap.min.js)
[https://cdn.jsdelivr.net/npm/echarts-extension-amap@1.11.0/dist/echarts-extension-amap.min.js](https://cdn.jsdelivr.net/npm/echarts-extension-amap@1.11.0/dist/echarts-extension-amap.min.js)

[**unpkg**](https://unpkg.com/)

Expand All @@ -80,7 +84,7 @@ Use the latest version

Use a specific version

[https://unpkg.com/echarts-extension-amap@1.10.1/dist/echarts-extension-amap.min.js](https://unpkg.com/echarts-extension-amap@1.10.1/dist/echarts-extension-amap.min.js)
[https://unpkg.com/echarts-extension-amap@1.11.0/dist/echarts-extension-amap.min.js](https://unpkg.com/echarts-extension-amap@1.11.0/dist/echarts-extension-amap.min.js)

This extension will register itself as a component of `echarts` after it is imported.

Expand Down
10 changes: 7 additions & 3 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

[在线示例](https://codepen.io/plainheart/pen/qBbdNYx)

[Apache ECharts](https://echarts.apache.org/zh/index.html) 高德地图扩展,可以在高德地图上展现 [点图](https://echarts.apache.org/zh/option.html#series-scatter)[线图](https://echarts.apache.org/zh/option.html#series-lines)[热力图](https://echarts.apache.org/zh/option.html#series-heatmap) 等可视化。
[Apache ECharts](https://echarts.apache.org/zh/index.html) 高德地图扩展,可以在高德地图上展现 [点图](https://echarts.apache.org/zh/option.html#series-scatter)[线图](https://echarts.apache.org/zh/option.html#series-lines)[热力图](https://echarts.apache.org/zh/option.html#series-heatmap)[饼图](https://echarts.apache.org/zh/option.html#series-pie) 等可视化。

### 示例

Expand All @@ -26,6 +26,10 @@ Lines 线图: [examples/lines.html](https://github.com/plainheart/echarts-extens

![Preview-Lines](https://user-images.githubusercontent.com/26999792/101313379-fca43c80-3890-11eb-9dea-46230dc432d5.gif)

Pie 饼图: [examples/pie.html](https://github.com/plainheart/echarts-extension-amap/blob/master/examples/pie_zh_CN.html) (**自 v1.11.0 开始支持**)

![Preview-Pie](https://user-images.githubusercontent.com/26999792/193215980-cd6736f5-a63d-4085-8012-d519e9e78398.png)

### 安装

```shell
Expand Down Expand Up @@ -70,7 +74,7 @@ import 'echarts-extension-amap';

使用指定版本

[https://cdn.jsdelivr.net/npm/echarts-extension-amap@1.10.1/dist/echarts-extension-amap.min.js](https://cdn.jsdelivr.net/npm/echarts-extension-amap@1.10.1/dist/echarts-extension-amap.min.js)
[https://cdn.jsdelivr.net/npm/echarts-extension-amap@1.11.0/dist/echarts-extension-amap.min.js](https://cdn.jsdelivr.net/npm/echarts-extension-amap@1.11.0/dist/echarts-extension-amap.min.js)

[**unpkg**](https://unpkg.com/)

Expand All @@ -80,7 +84,7 @@ import 'echarts-extension-amap';

使用指定版本

[https://unpkg.com/echarts-extension-amap@1.10.1/dist/echarts-extension-amap.min.js](https://unpkg.com/echarts-extension-amap@1.10.1/dist/echarts-extension-amap.min.js)
[https://unpkg.com/echarts-extension-amap@1.11.0/dist/echarts-extension-amap.min.js](https://unpkg.com/echarts-extension-amap@1.11.0/dist/echarts-extension-amap.min.js)

插件会自动注册相应的组件。

Expand Down
79 changes: 65 additions & 14 deletions dist/echarts-extension-amap.cjs.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*!
* echarts-extension-amap
* @version 1.10.1
* @version 1.11.0
* @author plainheart
*
* MIT License
*
* Copyright (c) 2019-2021 Zhongxiang.Wang
* Copyright (c) 2019-2022 Zhongxiang.Wang
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand All @@ -32,7 +32,8 @@ Object.defineProperty(exports, '__esModule', { value: true });

var echarts = require('echarts/lib/echarts');

var isV5 = echarts.version.split('.')[0] > 4;
var ecVer = echarts.version.split('.');
var isNewEC = ecVer[0] > 4;
/* global AMap */
// `AMap.version` only exists in AMap 2.x
// For AMap 1.x, it's `AMap.v`
Expand Down Expand Up @@ -145,6 +146,20 @@ AMapCoordSysProto.prepareCustoms = function () {
};
};

AMapCoordSysProto.convertToPixel = function (ecModel, finder, value) {
// here we don't use finder as only one amap component is allowed
return this.dataToPoint(value);
};

AMapCoordSysProto.convertFromPixel = function (ecModel, finder, value) {
// here we don't use finder as only one amap component is allowed
return this.pointToData(value);
}; // less useful
// AMapCoordSysProto.containPoint = function(point) {
// return this._amap.getBounds().contains(this.pointToData(point));
// }


AMapCoordSys.create = function (ecModel, api) {
var amapCoordSys;
ecModel.eachComponent('amap', function (amapModel) {
Expand All @@ -153,7 +168,7 @@ AMapCoordSys.create = function (ecModel, api) {
}

if (amapCoordSys) {
throw new Error('Only one amap component can exist');
throw new Error('Only one amap component is allowed');
}

var amap = amapModel.getAMap();
Expand Down Expand Up @@ -271,12 +286,16 @@ AMapCoordSys.create = function (ecModel, api) {
});
ecModel.eachSeries(function (seriesModel) {
if (seriesModel.get('coordinateSystem') === 'amap') {
// inject coordinate system
seriesModel.coordinateSystem = amapCoordSys;
}
});
}); // return created coordinate systems

return amapCoordSys && [amapCoordSys];
};

AMapCoordSysProto.dimensions = AMapCoordSys.dimensions = ['lng', 'lat'];
AMapCoordSysProto.type = 'amap';

var AMapModel = {
type: 'amap',
Expand Down Expand Up @@ -322,7 +341,7 @@ var AMapModel = {
returnMapCameraState: false
}
};
var AMapModel$1 = isV5 ? echarts.ComponentModel.extend(AMapModel) : AMapModel;
var AMapModel$1 = isNewEC ? echarts.ComponentModel.extend(AMapModel) : AMapModel;

var _isAMap2X;

Expand Down Expand Up @@ -477,9 +496,9 @@ var AMapView = {

this._isFirstRender = rendering = false;
},
dispose: function dispose(ecModel) {
dispose: function dispose() {
clearLogMap();
var component = ecModel.getComponent('amap');
var component = this.__model;

if (component) {
component.getAMap().destroy();
Expand All @@ -498,19 +517,51 @@ var AMapView = {
}
}
};
var AMapView$1 = isV5 ? echarts.ComponentView.extend(AMapView) : AMapView;
var AMapView$1 = isNewEC ? echarts.ComponentView.extend(AMapView) : AMapView;

var name = "echarts-extension-amap";
var version = "1.10.1";
var version = "1.11.0";

/**
* AMap component extension
*/
/**
* @typedef {import('../export').EChartsExtensionRegisters} EChartsExtensionRegisters
*/

/**
* AMap extension installer
* @param {EChartsExtensionRegisters} registers
*/

function install(registers) {
// Model
isV5 ? registers.registerComponentModel(AMapModel$1) : registers.extendComponentModel(AMapModel$1); // View
// add coordinate system support for pie series for ECharts < 5.4.0
if (!isNewEC || ecVer[0] == 5 && ecVer[1] < 4) {
registers.registerLayout(function (ecModel, api) {
ecModel.eachSeriesByType('pie', function (seriesModel) {
var coordSys = seriesModel.coordinateSystem;
var data = seriesModel.getData();
var valueDim = data.mapDimension('value');

if (coordSys && coordSys.type === 'amap') {
var center = seriesModel.get('center');
var point = coordSys.dataToPoint(center);
var cx = point[0];
var cy = point[1];
data.each(valueDim, function (value, idx) {
var layout = data.getItemLayout(idx);
layout.cx = cx;
layout.cy = cy;
});
}
});
});
} // Model


isNewEC ? registers.registerComponentModel(AMapModel$1) : registers.extendComponentModel(AMapModel$1); // View

isV5 ? registers.registerComponentView(AMapView$1) : registers.extendComponentView(AMapView$1); // Coordinate System
isNewEC ? registers.registerComponentView(AMapView$1) : registers.extendComponentView(AMapView$1); // Coordinate System

registers.registerCoordinateSystem('amap', AMapCoordSys); // Action

Expand All @@ -532,7 +583,7 @@ function install(registers) {
* to avoid self-registered `CanvasRenderer` and `DataSetComponent` in Apache ECharts 5
* but it's not compatible with echarts v4. Leave it to 2.0.
*/
isV5 ? echarts.use(install) : install(echarts);
isNewEC ? echarts.use(install) : install(echarts);

exports.name = name;
exports.version = version;
79 changes: 65 additions & 14 deletions dist/echarts-extension-amap.esm.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*!
* echarts-extension-amap
* @version 1.10.1
* @version 1.11.0
* @author plainheart
*
* MIT License
*
* Copyright (c) 2019-2021 Zhongxiang.Wang
* Copyright (c) 2019-2022 Zhongxiang.Wang
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand All @@ -29,7 +29,8 @@
import * as echarts from 'echarts/lib/echarts';
import { version as version$1, graphic, matrix, util, ComponentModel, ComponentView, throttle, getInstanceByDom } from 'echarts/lib/echarts';

var isV5 = version$1.split('.')[0] > 4;
var ecVer = version$1.split('.');
var isNewEC = ecVer[0] > 4;
/* global AMap */
// `AMap.version` only exists in AMap 2.x
// For AMap 1.x, it's `AMap.v`
Expand Down Expand Up @@ -142,6 +143,20 @@ AMapCoordSysProto.prepareCustoms = function () {
};
};

AMapCoordSysProto.convertToPixel = function (ecModel, finder, value) {
// here we don't use finder as only one amap component is allowed
return this.dataToPoint(value);
};

AMapCoordSysProto.convertFromPixel = function (ecModel, finder, value) {
// here we don't use finder as only one amap component is allowed
return this.pointToData(value);
}; // less useful
// AMapCoordSysProto.containPoint = function(point) {
// return this._amap.getBounds().contains(this.pointToData(point));
// }


AMapCoordSys.create = function (ecModel, api) {
var amapCoordSys;
ecModel.eachComponent('amap', function (amapModel) {
Expand All @@ -150,7 +165,7 @@ AMapCoordSys.create = function (ecModel, api) {
}

if (amapCoordSys) {
throw new Error('Only one amap component can exist');
throw new Error('Only one amap component is allowed');
}

var amap = amapModel.getAMap();
Expand Down Expand Up @@ -268,12 +283,16 @@ AMapCoordSys.create = function (ecModel, api) {
});
ecModel.eachSeries(function (seriesModel) {
if (seriesModel.get('coordinateSystem') === 'amap') {
// inject coordinate system
seriesModel.coordinateSystem = amapCoordSys;
}
});
}); // return created coordinate systems

return amapCoordSys && [amapCoordSys];
};

AMapCoordSysProto.dimensions = AMapCoordSys.dimensions = ['lng', 'lat'];
AMapCoordSysProto.type = 'amap';

var AMapModel = {
type: 'amap',
Expand Down Expand Up @@ -319,7 +338,7 @@ var AMapModel = {
returnMapCameraState: false
}
};
var AMapModel$1 = isV5 ? ComponentModel.extend(AMapModel) : AMapModel;
var AMapModel$1 = isNewEC ? ComponentModel.extend(AMapModel) : AMapModel;

var _isAMap2X;

Expand Down Expand Up @@ -474,9 +493,9 @@ var AMapView = {

this._isFirstRender = rendering = false;
},
dispose: function dispose(ecModel) {
dispose: function dispose() {
clearLogMap();
var component = ecModel.getComponent('amap');
var component = this.__model;

if (component) {
component.getAMap().destroy();
Expand All @@ -495,19 +514,51 @@ var AMapView = {
}
}
};
var AMapView$1 = isV5 ? ComponentView.extend(AMapView) : AMapView;
var AMapView$1 = isNewEC ? ComponentView.extend(AMapView) : AMapView;

var name = "echarts-extension-amap";
var version = "1.10.1";
var version = "1.11.0";

/**
* AMap component extension
*/
/**
* @typedef {import('../export').EChartsExtensionRegisters} EChartsExtensionRegisters
*/

/**
* AMap extension installer
* @param {EChartsExtensionRegisters} registers
*/

function install(registers) {
// Model
isV5 ? registers.registerComponentModel(AMapModel$1) : registers.extendComponentModel(AMapModel$1); // View
// add coordinate system support for pie series for ECharts < 5.4.0
if (!isNewEC || ecVer[0] == 5 && ecVer[1] < 4) {
registers.registerLayout(function (ecModel, api) {
ecModel.eachSeriesByType('pie', function (seriesModel) {
var coordSys = seriesModel.coordinateSystem;
var data = seriesModel.getData();
var valueDim = data.mapDimension('value');

if (coordSys && coordSys.type === 'amap') {
var center = seriesModel.get('center');
var point = coordSys.dataToPoint(center);
var cx = point[0];
var cy = point[1];
data.each(valueDim, function (value, idx) {
var layout = data.getItemLayout(idx);
layout.cx = cx;
layout.cy = cy;
});
}
});
});
} // Model


isNewEC ? registers.registerComponentModel(AMapModel$1) : registers.extendComponentModel(AMapModel$1); // View

isV5 ? registers.registerComponentView(AMapView$1) : registers.extendComponentView(AMapView$1); // Coordinate System
isNewEC ? registers.registerComponentView(AMapView$1) : registers.extendComponentView(AMapView$1); // Coordinate System

registers.registerCoordinateSystem('amap', AMapCoordSys); // Action

Expand All @@ -529,6 +580,6 @@ function install(registers) {
* to avoid self-registered `CanvasRenderer` and `DataSetComponent` in Apache ECharts 5
* but it's not compatible with echarts v4. Leave it to 2.0.
*/
isV5 ? echarts.use(install) : install(echarts);
isNewEC ? echarts.use(install) : install(echarts);

export { name, version };
Loading

0 comments on commit a6df526

Please sign in to comment.