Commit 3d54f64d 3d54f64de7baee9ac2ef916fd120eecb786fe2a9 by zhanghao

commit

1 parent 86e63006
Showing 1000 changed files with 4822 additions and 0 deletions

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

.DS_Store
node_modules/
npm-debug.log
MIT License
Copyright (c) 2017 billy-poon
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
# ECharts Extension AMap
An echarts extension to support AMap(http://lbs.amap.com/), Ported from the offical echarts `extension-bmap`
> https://github.com/ecomfe/echarts/tree/master/extension/bmap
## Install
```bash
npm install -S echarts-amap
```
## Get Started
**Using Script Tag**
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>ECharts AMap Test</title>
<style>
html,body,#map {
margin: 0;
padding: 0;
height: 100%;
}
</style>
</head>
<body>
<div id="map"></div>
<!-- external dependencies -->
<script src="http://webapi.amap.com/maps?v=1.3&key=YOUR_AMAP_API_KEY&plugin=AMap.CustomLayer"></script>
<script src="http://cdn.bootcss.com/echarts/3.4.0/echarts.min.js"></script>
<!-- import the extension -->
<script src="node_modules/echarts-amap/dist/echarts-amap.min.js"></script>
<script type="text/javascript">
var echart = echarts.init(document.getElementById('map'))
echart.setOption({
// use amap component
amap: {
center: [116.397475,39.908695],
zoom: 5,
mapStyle: 'blue_night'
},
// demo serie showing the capital BEIJING of our PRC :cn:
series: [{
type: 'effectScatter',
coordinateSystem: 'amap',
rippleEffect: {
brushType: 'stroke'
},
label: {
normal: {
show: true,
position: 'right',
formatter: '{b}'
}
},
symbolSize: 20,
itemStyle: {
normal: {
color: '#f44336'
}
},
data: [{
name: '首都',
value: [116.397475,39.908695]
}]
}]
})
</script>
</body>
</html>
```
**Using Webpack**
```javascript
var echarts = require('echarts')
require('echarts-amap')
var echart = echarts.init(document.getElementById('map'))
echart.setOption({
... // see the example above
})
```
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("echarts")):"function"==typeof define&&define.amd?define(["echarts"],e):"object"==typeof exports?exports.amap=e(require("echarts")):(t.echarts=t.echarts||{},t.echarts.amap=e(t.echarts))}(this,function(t){return function(t){function e(n){if(o[n])return o[n].exports;var a=o[n]={i:n,l:!1,exports:{}};return t[n].call(a.exports,a,a.exports,e),a.l=!0,a.exports}var o={};return e.m=t,e.c=o,e.i=function(t){return t},e.d=function(t,o,n){e.o(t,o)||Object.defineProperty(t,o,{configurable:!1,enumerable:!0,get:n})},e.n=function(t){var o=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(o,"a",o),o},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=4)}([function(e,o){e.exports=t},function(t,e,o){function n(t,e){this._amap=t,this.dimensions=["lng","lat"],this._mapOffset=[0,0],this._api=e}var a=o(0);n.prototype.dimensions=["lng","lat"],n.prototype.setZoom=function(t){this._zoom=t},n.prototype.setCenter=function(t){this._center=this._amap.lnglatToPixel(t)},n.prototype.setMapOffset=function(t){this._mapOffset=t},n.prototype.getAMap=function(){return this._amap},n.prototype.dataToPoint=function(t){var e=new AMap.LngLat(t[0],t[1]),o=this._amap.lngLatToContainer(e),n=this._mapOffset;return[o.x-n[0],o.y-n[1]]},n.prototype.pointToData=function(t){var e=this._mapOffset,t=this._amap.containerToLngLat({x:t[0]+e[0],y:t[1]+e[1]});return[t.lng,t.lat]},n.prototype.getViewRect=function(){var t=this._api;return new a.graphic.BoundingRect(0,0,t.getWidth(),t.getHeight())},n.prototype.getRoamTransform=function(){return a.matrix.create()};n.dimensions=n.prototype.dimensions,n.create=function(t,e){var o,r=e.getDom();t.eachComponent("amap",function(t){var i=e.getZr().painter.getViewportRoot();if("undefined"==typeof AMap)throw new Error("AMap api is not loaded");if(o)throw new Error("Only one amap component can exist");if(!t.__amap){var p=r.querySelector(".ec-extension-amap");p&&(i.style.left="0px",i.style.top="0px",r.removeChild(p)),p=document.createElement("div"),p.style.cssText="width:100%;height:100%",p.classList.add("ec-extension-amap"),r.appendChild(p);var s=t.get()||{};s=t.__options=a.util.clone(s);var c=t.__amap=new AMap.Map(p,s),f=t.__layer=new AMap.CustomLayer(i);f.setMap(c)}var c=t.getAMap(),f=t.getLayer();f.hide();var m=c.getZoom(),u=c.getCenter();o=new n(c,e),o.setMapOffset(t.__mapOffset||[0,0]),o.setZoom(m),o.setCenter([u.lng,u.lat]),t.coordinateSystem=o,f.show()}),t.eachSeries(function(t){"amap"===t.get("coordinateSystem")&&(t.coordinateSystem=o)})},t.exports=n},function(t,e,o){function n(t,e){return t&&e&&t[0]===e[0]&&t[1]===e[1]}t.exports=o(0).extendComponentModel({type:"amap",getAMap:function(){return this.__amap},getLayer:function(){return this.__layer},getMapOptions:function(){return this.__options},setCenterAndZoom:function(t,e){this.option.center=t,this.option.zoom=e},centerOrZoomChanged:function(t,e){var o=this.option;return!(n(t,o.center)&&e===o.zoom)},defaultOption:{center:[116.397475,39.908695],zoom:4}})},function(t,e,o){function n(t,e,o){var n,a,r,i;return i=function(){n=!1,a&&(r.apply(o,a),a=!1)},r=function(){n?a=arguments:(t.apply(o,arguments),setTimeout(i,e),n=!0)}}var a=o(0);t.exports=o(0).extendComponentView({type:"amap",render:function(t,e,o){function r(){p||o.dispatchAction({type:"amapRoam"})}function i(t){a.getInstanceByDom(o.getDom()).resize(),m.call(this,t)}var p=!0,s=t.getAMap(),c=o.getZr().painter.getViewportRoot(),f=t.coordinateSystem,m=function(e){if(!p){var n=c.parentNode.parentNode.parentNode,a=[-parseInt(n.style.left,10)||0,-parseInt(n.style.top,10)||0];c.style.left=a[0]+"px",c.style.top=a[1]+"px",f.setMapOffset(a),t.__mapOffset=a,o.dispatchAction({type:"amapRoam"})}},u=n(i,300,s);s.off("movestart",this._oldMoveHandler),s.off("zoomend",this._oldZoomEndHandler),s.off("moveend",this._oldZoomEndHandler),s.off("complete",this._oldZoomEndHandler),t.get("resizeEnable")&&s.off("resize",this._oldResizeHandler),s.on("movestart",m),s.on("zoomend",r),s.on("moveend",r),s.on("complete",r),t.get("resizeEnable")&&s.on("resize",u),this._oldMoveHandler=m,this._oldZoomEndHandler=r,this._oldResizeHandler=u,p=!1}})},function(t,e,o){o(0).registerCoordinateSystem("amap",o(1)),o(2),o(3),o(0).registerAction({type:"amapRoam",event:"amapRoam",update:"updateLayout"},function(t,e){e.eachComponent("amap",function(t){var e=t.getAMap(),o=e.getCenter();t.setCenterAndZoom([o.lng,o.lat],e.getZoom())})}),t.exports={version:"1.0.0-rc.6"}}])});
//# sourceMappingURL=echarts-amap.min.js.map
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Echarts plugin to support AMap</title>
</head>
<style media="screen">
html,body,#map {
margin:0;
padding: 0;
height: 100%;
}
</style>
<body>
<div id="map"></div>
<!--引入高德地图JSAPI -->
<script src="http://webapi.amap.com/maps?v=1.3&key=ab99f68b8f9eac7a5287f4043493e2db&plugin=AMap.CustomLayer"></script>
<!--引入UI组件库(1.0版本) -->
<script src="//webapi.amap.com/ui/1.0/main.js"></script>
<script src="http://cdn.bootcss.com/echarts/3.4.0/echarts.min.js"></script>
<script src="echarts-amap.js"></script>
<script type="text/javascript">
var echart = echarts.init(document.getElementById('map'))
echart.setOption({
amap: {
center: [116.397475,39.908695],
zoom: 5,
resizeEnable: true,
lang: 'zh_en'
},
series: [{
type: 'effectScatter',
coordinateSystem: 'amap',
rippleEffect: {
brushType: 'stroke'
},
label: {
normal: {
show: true,
position: 'right',
formatter: '{b}'
}
},
symbolSize: 20,
itemStyle: {
normal: {
color: '#f44336'
}
},
data: [{
name: '首都',
value: [116.397475,39.908695]
}]
}]
})
var map = echart.getModel().getComponent('amap').getAMap();
var layer = echart.getModel().getComponent('amap').getLayer();
//加载BasicControl,loadUI的路径参数为模块名中 'ui/' 之后的部分
AMapUI.loadUI(['control/BasicControl'], function(BasicControl) {
//缩放控件
map.addControl(new BasicControl.Zoom({
position: 'lt', //left top,左上角
showZoomNum: false //显示zoom值
}));
});
layer.setzIndex(200)
</script>
</body>
</html>
module.exports = require('./dist/echarts-amap.min.js')
{
"_from": "echarts-amap@1.0.0-rc.6",
"_id": "echarts-amap@1.0.0-rc.6",
"_inBundle": false,
"_integrity": "sha1-V4KnTa7lLtRM4/j2JXdWF4PwnhY=",
"_location": "/echarts-amap",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "echarts-amap@1.0.0-rc.6",
"name": "echarts-amap",
"escapedName": "echarts-amap",
"rawSpec": "1.0.0-rc.6",
"saveSpec": null,
"fetchSpec": "1.0.0-rc.6"
},
"_requiredBy": [
"/v-charts"
],
"_resolved": "https://registry.npmjs.org/echarts-amap/-/echarts-amap-1.0.0-rc.6.tgz",
"_shasum": "5782a74daee52ed44ce3f8f62577561783f09e16",
"_spec": "echarts-amap@1.0.0-rc.6",
"_where": "/Users/zhanghao/brcode/br-client/node_modules/v-charts",
"author": {
"name": "Billy Poon"
},
"bugs": {
"url": "https://github.com/billy-poon/echarts-amap/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "\u0016an echarts extension to support AMap(http://lbs.amap.com/)",
"devDependencies": {
"webpack": "^2.2.1",
"webpack-dev-server": "^2.4.1"
},
"homepage": "https://github.com/billy-poon/echarts-amap#readme",
"keywords": [
"echarts",
"amap",
"alimap",
"autonavi"
],
"license": "MIT",
"main": "index.js",
"name": "echarts-amap",
"repository": {
"type": "git",
"url": "git+https://github.com/billy-poon/echarts-amap.git"
},
"scripts": {
"build": "webpack -p",
"dev": "webpack-dev-server --open --hot",
"test": "echo \"Error: no test specified\" && exit 1"
},
"version": "1.0.0-rc.6"
}
var echarts = require('echarts');
function AMapCoordSys(amap, api) {
this._amap = amap;
this.dimensions = ['lng', 'lat'];
this._mapOffset = [0, 0];
this._api = api;
}
AMapCoordSys.prototype.dimensions = ['lng', 'lat'];
AMapCoordSys.prototype.setZoom = function (zoom) {
this._zoom = zoom;
};
AMapCoordSys.prototype.setCenter = function (center) {
this._center = this._amap.lnglatToPixel(center);//, 10)
};
AMapCoordSys.prototype.setMapOffset = function (mapOffset) {
this._mapOffset = mapOffset;
};
AMapCoordSys.prototype.getAMap = function () {
return this._amap;
};
AMapCoordSys.prototype.dataToPoint = function (data) {
var point = new AMap.LngLat(data[0], data[1]);
var px = this._amap.lngLatToContainer(point);//, this._zoom);
var mapOffset = this._mapOffset;
return [px.x - mapOffset[0], px.y - mapOffset[1]];
};
AMapCoordSys.prototype.pointToData = function (pt) {
var mapOffset = this._mapOffset;
var pt = this._amap.containerToLngLat({
x: pt[0] + mapOffset[0],
y: pt[1] + mapOffset[1]
});
return [pt.lng, pt.lat];
};
AMapCoordSys.prototype.getViewRect = function () {
var api = this._api;
return new echarts.graphic.BoundingRect(0, 0, api.getWidth(), api.getHeight());
};
AMapCoordSys.prototype.getRoamTransform = function () {
return echarts.matrix.create();
};
var Overlay;
// For deciding which dimensions to use when creating list data
AMapCoordSys.dimensions = AMapCoordSys.prototype.dimensions;
AMapCoordSys.create = function (ecModel, api) {
var amapCoordSys;
var root = api.getDom();
// TODO Dispose
ecModel.eachComponent('amap', function (amapModel) {
var viewportRoot = api.getZr().painter.getViewportRoot();
if (typeof AMap === 'undefined') {
throw new Error('AMap api is not loaded');
}
if (amapCoordSys) {
throw new Error('Only one amap component can exist');
}
if (!amapModel.__amap) {
// Not support IE8
var amapRoot = root.querySelector('.ec-extension-amap');
if (amapRoot) {
// Reset viewport left and top, which will be changed
// in moving handler in AMapView
viewportRoot.style.left = '0px';
viewportRoot.style.top = '0px';
root.removeChild(amapRoot);
}
amapRoot = document.createElement('div');
amapRoot.style.cssText = 'width:100%;height:100%';
// Not support IE8
amapRoot.classList.add('ec-extension-amap');
root.appendChild(amapRoot);
var options = amapModel.get() || {};
options = amapModel.__options = echarts.util.clone(options);
var amap = amapModel.__amap = new AMap.Map(amapRoot, options);
var layer = amapModel.__layer = new AMap.CustomLayer(viewportRoot);
layer.setMap(amap);
}
var amap = amapModel.getAMap();
var layer = amapModel.getLayer();
layer.hide();
var zoom = amap.getZoom();
var center = amap.getCenter();
amapCoordSys = new AMapCoordSys(amap, api);
amapCoordSys.setMapOffset(amapModel.__mapOffset || [0, 0]);
amapCoordSys.setZoom(zoom);
amapCoordSys.setCenter([center.lng, center.lat]);
amapModel.coordinateSystem = amapCoordSys;
layer.show();
});
ecModel.eachSeries(function (seriesModel) {
if (seriesModel.get('coordinateSystem') === 'amap') {
seriesModel.coordinateSystem = amapCoordSys;
}
});
};
module.exports = AMapCoordSys;
function v2Equal(a, b) {
return a && b && a[0] === b[0] && a[1] === b[1];
}
module.exports = require('echarts').extendComponentModel({
type: 'amap',
getAMap: function () {
// __amap is injected when creating AMapCoordSys
return this.__amap;
},
getLayer: function() {
// __layer is injected when creating AMapCoordSys
return this.__layer;
},
getMapOptions: function() {
return this.__options;
},
setCenterAndZoom: function (center, zoom) {
this.option.center = center;
this.option.zoom = zoom;
},
centerOrZoomChanged: function (center, zoom) {
var option = this.option;
return !(v2Equal(center, option.center) && zoom === option.zoom);
},
defaultOption: {
center: [116.397475,39.908695],
zoom: 4,
}
});
/*
* this function bollowed from:
* https://github.com/Leaflet/Leaflet/blob/master/src/core/Util.js
*/
function throttle(fn, time, context) {
var lock, args, wrapperFn, later;
later = function () {
// reset lock and call if queued
lock = false;
if (args) {
wrapperFn.apply(context, args);
args = false;
}
};
wrapperFn = function () {
if (lock) {
// called too soon, queue to call later
args = arguments;
} else {
// call and lock until later
fn.apply(context, arguments);
setTimeout(later, time);
lock = true;
}
};
return wrapperFn;
}
var echarts = require('echarts');
module.exports = require('echarts').extendComponentView({
type: 'amap',
render: function (aMapModel, ecModel, api) {
var rendering = true;
var amap = aMapModel.getAMap();
var viewportRoot = api.getZr().painter.getViewportRoot();
var coordSys = aMapModel.coordinateSystem;
var moveHandler = function (e) {
if (rendering) {
return;
}
var offsetEl = viewportRoot.parentNode.parentNode.parentNode;
var mapOffset = [
-parseInt(offsetEl.style.left, 10) || 0,
-parseInt(offsetEl.style.top, 10) || 0
];
viewportRoot.style.left = mapOffset[0] + 'px';
viewportRoot.style.top = mapOffset[1] + 'px';
coordSys.setMapOffset(mapOffset);
aMapModel.__mapOffset = mapOffset;
api.dispatchAction({
type: 'amapRoam'
});
};
function zoomEndHandler() {
if (rendering) {
return;
}
api.dispatchAction({
type: 'amapRoam'
});
}
function resizeHandler(e) {
echarts.getInstanceByDom(api.getDom()).resize();
moveHandler.call(this, e)
}
var throttledResizeHandler = throttle(resizeHandler, 300, amap);
amap.off('movestart', this._oldMoveHandler);
amap.off('zoomend', this._oldZoomEndHandler);
amap.off('moveend', this._oldZoomEndHandler);
amap.off('complete', this._oldZoomEndHandler);
aMapModel.get('resizeEnable') && amap.off('resize', this._oldResizeHandler);
amap.on('movestart', moveHandler);
amap.on('zoomend', zoomEndHandler);
amap.on('moveend', zoomEndHandler);
amap.on('complete', zoomEndHandler);
aMapModel.get('resizeEnable') && amap.on('resize', throttledResizeHandler);
this._oldMoveHandler = moveHandler;
this._oldZoomEndHandler = zoomEndHandler;
this._oldResizeHandler = throttledResizeHandler;
// var roam = aMapModel.get('roam');
// if (roam && roam !== 'scale') {
// amap.enableDragging();
// }
// else {
// amap.disableDragging();
// }
// if (roam && roam !== 'move') {
// amap.enableScrollWheelZoom();
// amap.enableDoubleClickZoom();
// amap.enablePinchToZoom();
// }
// else {
// amap.disableScrollWheelZoom();
// amap.disableDoubleClickZoom();
// amap.disablePinchToZoom();
// }
rendering = false;
}
});
/**
* BMap component extension
*/
require('echarts').registerCoordinateSystem(
'amap', require('./AMapCoordSys')
);
require('./AMapModel');
require('./AMapView');
// Action
require('echarts').registerAction({
type: 'amapRoam',
event: 'amapRoam',
update: 'updateLayout'
}, function (payload, ecModel) {
ecModel.eachComponent('amap', function (aMapModel) {
var amap = aMapModel.getAMap();
var center = amap.getCenter();
aMapModel.setCenterAndZoom([center.lng, center.lat], amap.getZoom());
});
});
module.exports = {
version: process.env.VERSION
};
var webpack = require('webpack');
var packagejson = require('./package.json');
var PROD = process.argv.indexOf('-p') >= 0;
console.log('building package version ' + packagejson.version)
module.exports = {
entry: {
'amap': __dirname + '/src/amap.js',
},
output: {
libraryTarget: 'umd',
library: ['echarts', '[name]'],
path: __dirname + '/dist',
filename: PROD ? 'echarts-[name].min.js' : 'echarts-[name].js'
},
externals: {
'echarts': 'echarts'
},
devtool: PROD ? '#source-map' : '#eval-source-map',
plugins: [
new webpack.DefinePlugin({
'process.env.VERSION': JSON.stringify(packagejson.version)
})
]
};
<!--
Paste your code here if you have a specific question.
-->
```js
var option = {
series: [{
type: 'liquidFill',
data: [0.6]
}]
};
```
<!--
Fork http://gallery.echartsjs.com/editor.html?c=xr1XplzB4e and reproduce your
problem, and paste the URL here to help us understand your question.
-->
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
<html>
<head>
<meta charset="utf-8">
<link href="https://fonts.googleapis.com/css?family=Lobster+Two:700i" rel="stylesheet">
<script src='../dist/echarts.js'></script>
<script src='../dist/echarts-liquidfill.js'></script>
</head>
<body>
<style>
html, body {
width: 100%;
height: 100%;
margin: 0;
background: #F1F7FF;
}
#main {
padding: 20px;
}
h1 {
margin: 20px;
font-size: 20px;
font-weight: bold;
text-align: center;
color: #D94854;
}
.chart {
width: 80%;
margin: 20px auto;
height: 300px;
border: 1px solid #D94854;
}
p {
text-align: center;
}
</style>
<h1>ECharts LiquidFill Example</h1>
<p>This is an example showing liquidFill chart that fills the container.</p>
<div id='main'>
<div class="chart"></div>
<div class="chart"></div>
</div>
<script>
var bgColor = '#E3F7FF';
var containers = document.getElementsByClassName('chart');
var options = [{
series: [{
type: 'liquidFill',
data: [0.6, 0.5, 0.4, 0.3],
outline: {
show: false
},
shape: 'container'
}]
}, {
series: [{
type: 'liquidFill',
data: [0.6, 0.5, 0.4, 0.3],
amplitude: '10%',
waveLength: '200%',
shape: 'container'
}]
}];
var charts = [];
for (var i = 0; i < options.length; ++i) {
var chart = echarts.init(containers[i]);
chart.setOption(options[i]);
charts.push(chart);
}
window.onresize = function () {
for (var i = 0; i < charts.length; ++i) {
charts[i].resize();
}
};
</script>
<script>
var _hmt = _hmt || [];
(function() {
var hm = document.createElement('script');
hm.src = '//hm.baidu.com/hm.js?4bad1df23f079e0d12bdbef5e65b072f';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<link href="https://fonts.googleapis.com/css?family=Lobster+Two:700i" rel="stylesheet">
<script src='../dist/echarts.js'></script>
<script src='../dist/echarts-liquidfill.js'></script>
</head>
<body>
<style>
html, body {
width: 100%;
height: 100%;
margin: 0;
background: #F1F7FF;
}
#main {
padding: 20px;
}
h1 {
margin: 20px;
font-size: 20px;
font-weight: bold;
text-align: center;
color: #D94854;
}
.chart {
width: 30%;
margin: 20px auto;
height: 300px;
border: 1px solid #D94854;
}
p {
text-align: center;
}
</style>
<h1>ECharts LiquidFill Example</h1>
<p>This is an example showing liquidFill chart that fills the container.</p>
<div id='main'>
<div class="chart" id="chart"></div>
</div>
<script>
var options = {
series: [{
type: 'liquidFill',
waveAnimation: false,
animation: false,
data: [{
value: 0.7
}]
}]
};
var chart = echarts.init(document.getElementById('chart'));
chart.setOption(options);
window.onresize = function () {
chart.resize();
};
</script>
<script>
var _hmt = _hmt || [];
(function() {
var hm = document.createElement('script');
hm.src = '//hm.baidu.com/hm.js?4bad1df23f079e0d12bdbef5e65b072f';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
</body>
</html>
module.exports = require('./src/liquidFill');
BSD 3-Clause License
Copyright (c) 2020, Baidu Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
{
"_from": "echarts-liquidfill@^2.0.2",
"_id": "echarts-liquidfill@2.0.6",
"_inBundle": false,
"_integrity": "sha512-p+AH0O9/BtwXMQQyhjJbMZo+GwRAgWG/DCyK5r27PQzpS0UWrgXu57MyEFc0A8Ub3sRuqEu08BuxwHICBkSWSQ==",
"_location": "/echarts-liquidfill",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "echarts-liquidfill@^2.0.2",
"name": "echarts-liquidfill",
"escapedName": "echarts-liquidfill",
"rawSpec": "^2.0.2",
"saveSpec": null,
"fetchSpec": "^2.0.2"
},
"_requiredBy": [
"/v-charts"
],
"_resolved": "https://registry.npmjs.org/echarts-liquidfill/-/echarts-liquidfill-2.0.6.tgz",
"_shasum": "0668dc61d87a6262003090bd32c55aa8108c252e",
"_spec": "echarts-liquidfill@^2.0.2",
"_where": "/Users/zhanghao/brcode/br-client/node_modules/v-charts",
"author": {
"name": "Ovilia",
"email": "me@zhangwenli.com",
"url": "http://zhangwenli.com"
},
"bugs": {
"url": "https://github.com/ecomfe/echarts-liquidfill/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "ECharts liquid fill extension",
"devDependencies": {
"webpack": "^4.43.0",
"webpack-cli": "^3.3.11",
"webpack-link": "^0.2.0"
},
"homepage": "https://github.com/ecomfe/echarts-liquidfill#readme",
"license": "MIT",
"main": "index.js",
"name": "echarts-liquidfill",
"peerDependencies": {
"echarts": "^4.8.0",
"zrender": "^4.3.1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/ecomfe/echarts-liquidfill.git"
},
"scripts": {
"build": "webpack --env.development",
"dev": "webpack --env.development --watch",
"release": "webpack --env.production"
},
"version": "2.0.6"
}
var echarts = require('echarts/lib/echarts');
require('./liquidFillSeries');
require('./liquidFillView');
echarts.registerVisual(
echarts.util.curry(
require('echarts/lib/visual/dataColor'), 'liquidFill'
)
);
var echarts = require('echarts/lib/echarts');
module.exports = echarts.graphic.extendShape({
type: 'ec-liquid-fill',
shape: {
waveLength: 0,
radius: 0,
radiusY: 0,
cx: 0,
cy: 0,
waterLevel: 0,
amplitude: 0,
phase: 0,
inverse: false
},
buildPath: function (ctx, shape) {
if (shape.radiusY == null) {
shape.radiusY = shape.radius;
}
/**
* We define a sine wave having 4 waves, and make sure at least 8 curves
* is drawn. Otherwise, it may cause blank area for some waves when
* wave length is large enough.
*/
var curves = Math.max(
Math.ceil(2 * shape.radius / shape.waveLength * 4) * 2,
8
);
// map phase to [-Math.PI * 2, 0]
while (shape.phase < -Math.PI * 2) {
shape.phase += Math.PI * 2;
}
while (shape.phase > 0) {
shape.phase -= Math.PI * 2;
}
var phase = shape.phase / Math.PI / 2 * shape.waveLength;
var left = shape.cx - shape.radius + phase - shape.radius * 2;
/**
* top-left corner as start point
*
* draws this point
* |
* \|/
* ~~~~~~~~
* | |
* +------+
*/
ctx.moveTo(left, shape.waterLevel);
/**
* top wave
*
* ~~~~~~~~ <- draws this sine wave
* | |
* +------+
*/
var waveRight = 0;
for (var c = 0; c < curves; ++c) {
var stage = c % 4;
var pos = getWaterPositions(c * shape.waveLength / 4, stage,
shape.waveLength, shape.amplitude);
ctx.bezierCurveTo(pos[0][0] + left, -pos[0][1] + shape.waterLevel,
pos[1][0] + left, -pos[1][1] + shape.waterLevel,
pos[2][0] + left, -pos[2][1] + shape.waterLevel);
if (c === curves - 1) {
waveRight = pos[2][0];
}
}
if (shape.inverse) {
/**
* top-right corner
* 2. draws this line
* |
* +------+
* 3. draws this line -> | | <- 1. draws this line
* ~~~~~~~~
*/
ctx.lineTo(waveRight + left, shape.cy - shape.radiusY);
ctx.lineTo(left, shape.cy - shape.radiusY);
ctx.lineTo(left, shape.waterLevel);
}
else {
/**
* top-right corner
*
* ~~~~~~~~
* 3. draws this line -> | | <- 1. draws this line
* +------+
* ^
* |
* 2. draws this line
*/
ctx.lineTo(waveRight + left, shape.cy + shape.radiusY);
ctx.lineTo(left, shape.cy + shape.radiusY);
ctx.lineTo(left, shape.waterLevel);
}
ctx.closePath();
}
});
/**
* Using Bezier curves to fit sine wave.
* There is 4 control points for each curve of wave,
* which is at 1/4 wave length of the sine wave.
*
* The control points for a wave from (a) to (d) are a-b-c-d:
* c *----* d
* b *
* |
* ... a * ..................
*
* whose positions are a: (0, 0), b: (0.5, 0.5), c: (1, 1), d: (PI / 2, 1)
*
* @param {number} x x position of the left-most point (a)
* @param {number} stage 0-3, stating which part of the wave it is
* @param {number} waveLength wave length of the sine wave
* @param {number} amplitude wave amplitude
*/
function getWaterPositions(x, stage, waveLength, amplitude) {
if (stage === 0) {
return [
[x + 1 / 2 * waveLength / Math.PI / 2, amplitude / 2],
[x + 1 / 2 * waveLength / Math.PI, amplitude],
[x + waveLength / 4, amplitude]
];
}
else if (stage === 1) {
return [
[x + 1 / 2 * waveLength / Math.PI / 2 * (Math.PI - 2),
amplitude],
[x + 1 / 2 * waveLength / Math.PI / 2 * (Math.PI - 1),
amplitude / 2],
[x + waveLength / 4, 0]
]
}
else if (stage === 2) {
return [
[x + 1 / 2 * waveLength / Math.PI / 2, -amplitude / 2],
[x + 1 / 2 * waveLength / Math.PI, -amplitude],
[x + waveLength / 4, -amplitude]
]
}
else {
return [
[x + 1 / 2 * waveLength / Math.PI / 2 * (Math.PI - 2),
-amplitude],
[x + 1 / 2 * waveLength / Math.PI / 2 * (Math.PI - 1),
-amplitude / 2],
[x + waveLength / 4, 0]
]
}
}
var completeDimensions = require('echarts/lib/data/helper/completeDimensions');
var echarts = require('echarts/lib/echarts');
echarts.extendSeriesModel({
type: 'series.liquidFill',
visualColorAccessPath: 'textStyle.normal.color',
optionUpdated: function () {
var option = this.option;
option.gridSize = Math.max(Math.floor(option.gridSize), 4);
},
getInitialData: function (option, ecModel) {
var dimensions = completeDimensions(['value'], option.data);
var list = new echarts.List(dimensions, this);
list.initData(option.data);
return list;
},
defaultOption: {
color: ['#294D99', '#156ACF', '#1598ED', '#45BDFF'],
center: ['50%', '50%'],
radius: '50%',
amplitude: '8%',
waveLength: '80%',
phase: 'auto',
period: 'auto',
direction: 'right',
shape: 'circle',
waveAnimation: true,
animationEasing: 'linear',
animationEasingUpdate: 'linear',
animationDuration: 2000,
animationDurationUpdate: 1000,
outline: {
show: true,
borderDistance: 8,
itemStyle: {
color: 'none',
borderColor: '#294D99',
borderWidth: 8,
shadowBlur: 20,
shadowColor: 'rgba(0, 0, 0, 0.25)'
}
},
backgroundStyle: {
color: '#E3F7FF'
},
itemStyle: {
opacity: 0.95,
shadowBlur: 50,
shadowColor: 'rgba(0, 0, 0, 0.4)'
},
label: {
show: true,
color: '#294D99',
insideColor: '#fff',
fontSize: 50,
fontWeight: 'bold',
align: 'center',
baseline: 'middle',
position: 'inside'
},
emphasis: {
itemStyle: {
opacity: 0.8
}
}
}
});
module.exports = env => {
return {
mode: env.production ? 'production' : 'development',
entry: {
'echarts-liquidfill': __dirname + '/index.js'
},
output: {
libraryTarget: 'umd',
library: ['echarts-liquidfill'],
path: __dirname + '/dist',
filename: env.production ? '[name].min.js' : '[name].js'
},
externals: {
'echarts/lib/echarts': 'echarts'
},
devtool: 'source-map',
resolve: {
alias: {
'echarts/lib/echarts': 'echarts'
}
},
optimization: {
minimize: env.production
}
}
};
# [ECharts](https://github.com/ecomfe/echarts) wordcloud extension based on [wordcloud2.js](https://github.com/timdream/wordcloud2.js)
<a href="http://echarts.baidu.com">
<img style="vertical-align: top;" src="https://github.com/ecomfe/echarts/raw/master/asset/logo.png?raw=true" alt="logo" height="50px">
</a>
![](./example/word-cloud.png)
## Examples
[Google Trends](https://ecomfe.github.io/echarts-wordcloud/example/wordCloud.html)
[ECharts Option Keywords](https://ecomfe.github.io/echarts-wordcloud/example/optionKeywords.html)
## Install
```html
<script src="echarts.min.js"></script>
<script src="echarts-wordcloud.min.js"></script>
```
Or
```shell
npm install echarts
npm install echarts-wordcloud
```
```js
var echarts = require('echarts');
require('echarts-wordcloud');
```
## Usage
```js
var chart = echarts.init(document.getElementById('main'));
chart.setOption({
...
series: [{
type: 'wordCloud',
// The shape of the "cloud" to draw. Can be any polar equation represented as a
// callback function, or a keyword present. Available presents are circle (default),
// cardioid (apple or heart shape curve, the most known polar equation), diamond (
// alias of square), triangle-forward, triangle, (alias of triangle-upright, pentagon, and star.
shape: 'circle',
// A silhouette image which the white area will be excluded from drawing texts.
// The shape option will continue to apply as the shape of the cloud to grow.
maskImage: maskImage,
// Folllowing left/top/width/height/right/bottom are used for positioning the word cloud
// Default to be put in the center and has 75% x 80% size.
left: 'center',
top: 'center',
width: '70%',
height: '80%',
right: null,
bottom: null,
// Text size range which the value in data will be mapped to.
// Default to have minimum 12px and maximum 60px size.
sizeRange: [12, 60],
// Text rotation range and step in degree. Text will be rotated randomly in range [-90, 90] by rotationStep 45
rotationRange: [-90, 90],
rotationStep: 45,
// size of the grid in pixels for marking the availability of the canvas
// the larger the grid size, the bigger the gap between words.
gridSize: 8,
// set to true to allow word being draw partly outside of the canvas.
// Allow word bigger than the size of the canvas to be drawn
drawOutOfBound: false,
// Global text style
textStyle: {
normal: {
fontFamily: 'sans-serif',
fontWeight: 'bold',
// Color can be a callback function or a color string
color: function () {
// Random color
return 'rgb(' + [
Math.round(Math.random() * 160),
Math.round(Math.random() * 160),
Math.round(Math.random() * 160)
].join(',') + ')';
}
},
emphasis: {
shadowBlur: 10,
shadowColor: '#333'
}
},
// Data is an array. Each array item must have name and value property.
data: [{
name: 'Farrah Abraham',
value: 366,
// Style of single text
textStyle: {
normal: {},
emphasis: {}
}
}]
}]
});
```
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
module.exports = require('./src/wordCloud');
\ No newline at end of file
{
"_from": "echarts-wordcloud@^1.1.3",
"_id": "echarts-wordcloud@1.1.3",
"_inBundle": false,
"_integrity": "sha512-Et8D5xEAoYkidmHun+hEH+2lF9dhCt6D0JJ390vlr2r/1zwhhZAbcL01CEvG93QcMcJpSvSPK8vRiGkTbMHRxg==",
"_location": "/echarts-wordcloud",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "echarts-wordcloud@^1.1.3",
"name": "echarts-wordcloud",
"escapedName": "echarts-wordcloud",
"rawSpec": "^1.1.3",
"saveSpec": null,
"fetchSpec": "^1.1.3"
},
"_requiredBy": [
"/v-charts"
],
"_resolved": "https://registry.npmjs.org/echarts-wordcloud/-/echarts-wordcloud-1.1.3.tgz",
"_shasum": "07b140c8ba76b19c317b43c310f3d5dc99289ff2",
"_spec": "echarts-wordcloud@^1.1.3",
"_where": "/Users/zhanghao/brcode/br-client/node_modules/v-charts",
"author": "",
"bugs": {
"url": "https://github.com/ecomfe/echarts-wordcloud/issues"
},
"bundleDependencies": false,
"dependencies": {},
"deprecated": false,
"description": "ECharts wordcloud extension based on wordcloud2.js",
"devDependencies": {
"esprima": "^2.7.2",
"fs-extra": "^0.30.0",
"glob": "^7.0.3"
},
"homepage": "https://github.com/ecomfe/echarts-wordcloud#readme",
"license": "ISC",
"main": "index.js",
"name": "echarts-wordcloud",
"repository": {
"type": "git",
"url": "git+https://github.com/ecomfe/echarts-wordcloud.git"
},
"version": "1.1.3"
}
var completeDimensions = require('echarts/lib/data/helper/completeDimensions');
var echarts = require('echarts/lib/echarts');
echarts.extendSeriesModel({
type: 'series.wordCloud',
visualColorAccessPath: 'textStyle.normal.color',
optionUpdated: function () {
var option = this.option;
option.gridSize = Math.max(Math.floor(option.gridSize), 4);
},
getInitialData: function (option, ecModel) {
var dimensions = completeDimensions(['value'], option.data);
var list = new echarts.List(dimensions, this);
list.initData(option.data);
return list;
},
// Most of options are from https://github.com/timdream/wordcloud2.js/blob/gh-pages/API.md
defaultOption: {
maskImage: null,
// Shape can be 'circle', 'cardioid', 'diamond', 'triangle-forward', 'triangle', 'pentagon', 'star'
shape: 'circle',
left: 'center',
top: 'center',
width: '70%',
height: '80%',
sizeRange: [12, 60],
rotationRange: [-90, 90],
rotationStep: 45,
gridSize: 8,
drawOutOfBound: false,
textStyle: {
normal: {
fontWeight: 'normal'
}
}
}
});
var echarts = require('echarts/lib/echarts');
function getShallow(model, path) {
return model && model.getShallow(path);
}
echarts.extendChartView({
type: 'wordCloud',
render: function (seriesModel, ecModel, api) {
var group = this.group;
group.removeAll();
var data = seriesModel.getData();
var gridSize = seriesModel.get('gridSize');
seriesModel.layoutInstance.ondraw = function (text, size, dataIdx, drawn) {
var itemModel = data.getItemModel(dataIdx);
var textStyleModel = itemModel.getModel('textStyle.normal');
var emphasisTextStyleModel = itemModel.getModel('textStyle.emphasis');
var textEl = new echarts.graphic.Text({
style: echarts.graphic.setTextStyle({}, textStyleModel, {
x: drawn.info.fillTextOffsetX,
y: drawn.info.fillTextOffsetY + size * 0.5,
text: text,
textBaseline: 'middle',
textFill: data.getItemVisual(dataIdx, 'color'),
fontSize: size
}),
scale: [1 / drawn.info.mu, 1 / drawn.info.mu],
position: [
(drawn.gx + drawn.info.gw / 2) * gridSize,
(drawn.gy + drawn.info.gh / 2) * gridSize
],
rotation: drawn.rot
});
group.add(textEl);
data.setItemGraphicEl(dataIdx, textEl);
echarts.graphic.setHoverStyle(
textEl,
echarts.graphic.setTextStyle({}, emphasisTextStyleModel, null, {forMerge: true}, true)
);
};
this._model = seriesModel;
},
remove: function () {
this.group.removeAll();
this._model.layoutInstance.dispose();
},
dispose: function () {
this._model.layoutInstance.dispose();
}
});
var echarts = require('echarts/lib/echarts');
var layoutUtil = require('echarts/lib/util/layout');
require('./WordCloudSeries');
require('./WordCloudView');
var wordCloudLayoutHelper = require('./layout');
if (!wordCloudLayoutHelper.isSupported) {
throw new Error('Sorry your browser not support wordCloud');
}
// https://github.com/timdream/wordcloud2.js/blob/c236bee60436e048949f9becc4f0f67bd832dc5c/index.js#L233
function updateCanvasMask(maskCanvas) {
var ctx = maskCanvas.getContext('2d');
var imageData = ctx.getImageData(
0, 0, maskCanvas.width, maskCanvas.height);
var newImageData = ctx.createImageData(imageData);
var toneSum = 0;
var toneCnt = 0;
for (var i = 0; i < imageData.data.length; i += 4) {
var alpha = imageData.data[i + 3];
if (alpha > 128) {
var tone = imageData.data[i]
+ imageData.data[i + 1]
+ imageData.data[i + 2];
toneSum += tone;
++toneCnt;
}
}
var threshold = toneSum / toneCnt;
for (var i = 0; i < imageData.data.length; i += 4) {
var tone = imageData.data[i]
+ imageData.data[i + 1]
+ imageData.data[i + 2];
var alpha = imageData.data[i + 3];
if (alpha < 128 || tone > threshold) {
// Area not to draw
newImageData.data[i] = 0;
newImageData.data[i + 1] = 0;
newImageData.data[i + 2] = 0;
newImageData.data[i + 3] = 0;
}
else {
// Area to draw
// The color must be same with backgroundColor
newImageData.data[i] = 255;
newImageData.data[i + 1] = 255;
newImageData.data[i + 2] = 255;
newImageData.data[i + 3] = 255;
}
}
ctx.putImageData(newImageData, 0, 0);
}
echarts.registerLayout(function (ecModel, api) {
ecModel.eachSeriesByType('wordCloud', function (seriesModel) {
var gridRect = layoutUtil.getLayoutRect(
seriesModel.getBoxLayoutParams(), {
width: api.getWidth(),
height: api.getHeight()
}
);
var data = seriesModel.getData();
var canvas = document.createElement('canvas');
canvas.width = gridRect.width;
canvas.height = gridRect.height;
var ctx = canvas.getContext('2d');
var maskImage = seriesModel.get('maskImage');
if (maskImage) {
try {
ctx.drawImage(maskImage, 0, 0, canvas.width, canvas.height);
updateCanvasMask(canvas);
}
catch (e) {
console.error('Invalid mask image');
console.error(e.toString());
}
}
var sizeRange = seriesModel.get('sizeRange');
var rotationRange = seriesModel.get('rotationRange');
var valueExtent = data.getDataExtent('value');
var DEGREE_TO_RAD = Math.PI / 180;
var gridSize = seriesModel.get('gridSize');
wordCloudLayoutHelper(canvas, {
list: data.mapArray('value', function (value, idx) {
var itemModel = data.getItemModel(idx);
return [
data.getName(idx),
itemModel.get('textStyle.normal.textSize', true)
|| echarts.number.linearMap(value, valueExtent, sizeRange),
idx
];
}).sort(function (a, b) {
// Sort from large to small in case there is no more room for more words
return b[1] - a[1];
}),
fontFamily: seriesModel.get('textStyle.normal.fontFamily')
|| seriesModel.get('textStyle.emphasis.fontFamily')
|| ecModel.get('textStyle.fontFamily'),
fontWeight: seriesModel.get('textStyle.normal.fontWeight')
|| seriesModel.get('textStyle.emphasis.fontWeight')
|| ecModel.get('textStyle.fontWeight'),
gridSize: gridSize,
ellipticity: gridRect.height / gridRect.width,
minRotation: rotationRange[0] * DEGREE_TO_RAD,
maxRotation: rotationRange[1] * DEGREE_TO_RAD,
clearCanvas: !maskImage,
rotateRatio: 1,
rotationStep: seriesModel.get('rotationStep') * DEGREE_TO_RAD,
drawOutOfBound: seriesModel.get('drawOutOfBound'),
shuffle: false,
shape: seriesModel.get('shape')
});
function onWordCloudDrawn(e) {
var item = e.detail.item;
if (e.detail.drawn && seriesModel.layoutInstance.ondraw) {
e.detail.drawn.gx += gridRect.x / gridSize;
e.detail.drawn.gy += gridRect.y / gridSize;
seriesModel.layoutInstance.ondraw(
item[0], item[1], item[2], e.detail.drawn
);
}
}
canvas.addEventListener('wordclouddrawn', onWordCloudDrawn);
if (seriesModel.layoutInstance) {
// Dispose previous
seriesModel.layoutInstance.dispose();
}
seriesModel.layoutInstance = {
ondraw: null,
dispose: function () {
canvas.removeEventListener('wordclouddrawn', onWordCloudDrawn);
// Abort
canvas.addEventListener('wordclouddrawn', function (e) {
// Prevent default to cancle the event and stop the loop
e.preventDefault();
});
}
};
});
});
echarts.registerPreprocessor(function (option) {
var series = (option || {}).series;
!echarts.util.isArray(series) && (series = series ? [series] : []);
var compats = ['shadowColor', 'shadowBlur', 'shadowOffsetX', 'shadowOffsetY'];
echarts.util.each(series, function (seriesItem) {
if (seriesItem && seriesItem.type === 'wordCloud') {
var textStyle = seriesItem.textStyle || {};
compatTextStyle(textStyle.normal);
compatTextStyle(textStyle.emphasis);
}
});
function compatTextStyle(textStyle) {
textStyle && echarts.util.each(compats, function (key) {
if (textStyle.hasOwnProperty(key)) {
textStyle['text' + echarts.format.capitalFirst(key)] = textStyle[key];
}
});
}
});
var PROD = process.argv.indexOf('-p') >= 0;
module.exports = {
entry: {
'echarts-wordcloud': __dirname + '/index.js'
},
output: {
libraryTarget: 'umd',
library: ['echarts-wordcloud'],
path: __dirname + '/dist',
filename: PROD ? '[name].min.js' : '[name].js'
},
externals: {
'echarts/lib/echarts': 'echarts'
}
};
\ No newline at end of file
root = true
[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[**.js]
indent_style = space
indent_size = 4
[**.css]
indent_style = space
indent_size = 4
[**.less]
indent_style = space
indent_size = 4
[**.styl]
indent_style = space
indent_size = 4
[**.html]
indent_style = space
indent_size = 4
[**.tpl]
indent_style = space
indent_size = 4
[**.json]
indent_style = space
indent_size = 4
[*.md]
trim_trailing_whitespace = false
/dist
/node_modules
\ No newline at end of file
# for pull request size bot
# excludes all files from test directory
test/** linguist-generated=true
<!--
Please Use https://ecomfe.github.io/echarts-issue-helper to create the issue.
Otherwise, it will be closed immediately.
Questions in the form of *How to use ...* should be at Stack Overflow rather than GitHub issue list.
请注意,所有 issue 必须由 https://ecomfe.github.io/echarts-issue-helper/ 创建,不然将会被直接关闭。建议使用英文提问。
Issues 中不要问「如何使用 ECharts 实现……功能」的问题,相关问题请到 SegmentFault 或 Stack Overflow 提问,详见上面的链接。
-->
This issue is not created by [echarts-issue-helper](https://ecomfe.github.io/echarts-issue-helper) and will be soon closed.
<!-- Please fill in the following information to help us review your PR more efficiently. -->
## Brief Information
This pull request is in the type of:
- [ ] bug fixing
- [ ] new feature
- [ ] others
### What does this PR do?
<!-- USE ONCE SENTENCE TO DESCRIBE WHAT THIS PR DOES. -->
### Fixed issues
<!--
- #xxxx: ...
-->
## Details
### Before: What was the problem?
<!-- DESCRIBE THE BUG OR REQUIREMENT HERE. -->
<!-- ADD SCREENSHOT HERE IF APPLICABLE. -->
### After: How is it fixed in this PR?
<!-- THE RESULT AFTER FIXING AND A SIMPLE EXPLANATION ABOUT HOW IT IS FIXED. -->
<!-- ADD SCREENSHOT HERE IF APPLICABLE. -->
## Usage
### Are there any API changes?
- [ ] The API has been changed.
<!-- LIST THE API CHANGES HERE -->
### Related test cases or examples to use the new APIs
NA.
## Others
### Merging options
- [ ] Please squash the commits into a single one when merge.
### Other information
# Configuration for probot-stale - https://github.com/probot/stale
# Number of days of inactivity before an Issue or Pull Request becomes stale
daysUntilStale: 730 # two years
# Number of days of inactivity before an Issue or Pull Request with the stale label is closed.
# Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale.
daysUntilClose: 7
# Only issues or pull requests with all of these labels are check if stale. Defaults to `[]` (disabled)
onlyLabels: []
# Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable
exemptLabels:
- "maybe-later"
- "priority: high"
# Set to true to ignore issues in a project (defaults to false)
exemptProjects: true
# Set to true to ignore issues in a milestone (defaults to false)
exemptMilestones: false
# Set to true to ignore issues with an assignee (defaults to false)
exemptAssignees: false
# Label to use when marking as stale
staleLabel: stale
# Comment to post when marking as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
# Comment to post when removing the stale label.
unmarkComment: >
This issue is marked to be `stale` and is going to be closed within a week. If you think it shouldn't be closed, please leave a comment.
# Comment to post when closing a stale Issue or Pull Request.
# closeComment: >
# Your comment here.
# Limit the number of actions per hour, from 1-30. Default is 30
limitPerRun: 30
# Limit to only `issues` or `pulls`
# only: issues
# Optionally, specify configuration settings that are specific to just 'issues' or 'pulls':
# pulls:
# daysUntilStale: 30
# markComment: >
# This pull request has been automatically marked as stale because it has not had
# recent activity. It will be closed if no further activity occurs. Thank you
# for your contributions.
# issues:
# exemptLabels:
# - confirmed
name: Node CI
on:
pull_request:
types: [opened, synchronize]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: npm install
run: |
npm install
npm install -g jshint
npm install git+https://github.com/ecomfe/zrender.git
- name: build zrender
run: |
cd node_modules/zrender
npm install
npm run prepublish
cd ../..
- name: jshint
run: |
jshint
- name: build release
run: |
npm run release
env:
CI: true
- name: unit test
run: |
npm run test
# Only support regexp, testing against each relative file path
# based on the echart base directory. And the pattern should
# match the relative path completely.
node_modules
.*\.git
.*\.github
.*\.editorconfig
.*\.gitignore
.*\.jshintrc
.*\.jshintrc-dist
.*\.npmignore
.*\.ratignore
.*\.headerignore
.*\.DS_Store
.*\.idea
.*rat\.iml
__MAC_OS
.*README.md
.*MANIFEST\.txt
DISCLAIMER
NOTICE
KEYS
LICENSE
LICENSE-.+
licenses
map/js
map/json
benchmark/dep/*
test/ut/lib
test/data$
test/lib/esl\.js
test/lib/perlin\.js
test/lib/countup\.js
.*jquery\.min\.js
.*rollup\.browser\.js
.*configure
.+\.json
.+\.map
.+\.gexf
.+\.jar
.+\.bin
.+\.csv
.+\.png
.+\.PNG
.+\.jpg
.+\.JPG
.+\.jpeg
.+\.JPEG
.+\.gif
.+\.GIF
.+\.class
{
"hooks": {
"pre-commit": "npm run lint",
}
}
{
"bitwise": false,
"camelcase": true,
"curly": true,
"eqeqeq": false,
"forin": false,
"immed": true,
"latedef": false,
"newcap": true,
"noarg": false,
"noempty": true,
"nonew": true,
"plusplus": false,
"quotmark": "single",
"regexp": false,
"undef": true,
"unused": "vars",
"strict": false,
"trailing": false,
"maxparams": 20,
"maxdepth": 6,
"maxlen": 200,
"asi": false,
"boss": false,
"debug": false,
"eqnull": true,
"esversion": 6,
"module": true,
"evil": true,
"expr": true,
"funcscope": false,
"globalstrict": false,
"iterator": false,
"lastsemic": false,
"laxbreak": true,
"laxcomma": false,
"loopfunc": false,
"multistr": false,
"onecase": false,
"proto": false,
"regexdash": false,
"scripturl": false,
"smarttabs": false,
"shadow": true,
"sub": true,
"supernew": false,
"validthis": true,
"browser": true,
"couch": false,
"devel": true,
"dojo": false,
"jquery": true,
"mootools": false,
"node": false,
"nonstandard": false,
"prototypejs": false,
"rhino": false,
"wsh": false,
"nomen": false,
"onevar": false,
"passfail": false,
"white": false,
"predef": [
"global"
]
}
\ No newline at end of file
{
"bitwise": false,
"camelcase": false,
"curly": true,
"eqeqeq": false,
"forin": false,
"immed": true,
"latedef": false,
"newcap": true,
"noarg": false,
"noempty": true,
"nonew": true,
"plusplus": false,
"quotmark": "single",
"regexp": false,
"undef": true,
"unused": "vars",
"strict": false,
"trailing": false,
"maxparams": 20,
"maxdepth": 6,
"maxlen": 200,
"asi": false,
"boss": false,
"debug": false,
"eqnull": true,
"esversion": 3,
"module": false,
"evil": true,
"expr": true,
"funcscope": false,
"globalstrict": false,
"iterator": false,
"lastsemic": false,
"laxbreak": true,
"laxcomma": false,
"loopfunc": false,
"multistr": false,
"onecase": false,
"proto": false,
"regexdash": false,
"scripturl": false,
"smarttabs": false,
"shadow": true,
"sub": true,
"supernew": false,
"validthis": true,
"browser": true,
"couch": false,
"devel": true,
"dojo": false,
"jquery": true,
"mootools": false,
"node": false,
"nonstandard": false,
"prototypejs": false,
"rhino": false,
"wsh": false,
"nomen": false,
"onevar": false,
"passfail": false,
"white": false,
"predef": [
"global"
]
}
\ No newline at end of file
# Contributing
👍🎉 First off, thanks for taking the time to contribute! 🎉👍
Please check out the [Apache Code of Conduct](https://www.apache.org/foundation/policies/conduct.html) first.
## What can you do for the ECharts community?
Contributions can be made in varied ways:
- Help others in the issues
- Help solve problems with the issues
- Remind the authors to provide a demo if they are reporting for a bug
- Try to reproduce the problem as describe in the issues
- Make pull requests to fix bugs or implement new features
- Mend or translate the documents
- Discuss in the [mailing list](https://echarts.apache.org/en/maillist.html)
- ...
## Issues
When opening new issues, please use the [echarts issue helper](https://ecomfe.github.io/echarts-issue-helper/), opening issues in any other way will cause our bot to close them automatically.
And before doing so, please search for similar questions in our [issues list](https://github.com/apache/incubator-echarts/issues?utf8=%E2%9C%93&q=is%3Aissue). If you are able to reproduce an issue found in a closed issue, please create a new issue and reference the closed one.
Please read the [documentation](http://echarts.apache.org/option.html) carefully before asking any questions.
Any questions in the form of *how can I use echarts to* or *how to use echarts x feature to* belong in [Stack Overflow](http://stackoverflow.com), issues with questions like that in the issue tracker will be closed.
## Release Milestone Discussion
We will start the discussion about the bugs to fix and features of each release in the [mailing list](https://echarts.apache.org/en/maillist.html). You may subscribe our [mailing list](https://echarts.apache.org/en/maillist.html) to give your valuable advice in the milestone dicussion.
About our release plan, we will release a mior version at the end of every month. Here is some detail.
1. Assume our current stable release is 4.3.0. We will start the discussion of milestone of the release two versions ahead, which is 4.5.0 at the beginning of each month. At this time we should also kickoff the developing of the next release, which is 4.4.0.
2. Finish 4.4.0 developing at about 22th of this month and start the testing. And the 4.5.0 milestone discussion is frozen and published on the [GitHub](https://github.com/apache/incubator-echarts/milestone/14)
3. Vote in the mailing list for the 4.4.0 release at the end of this month.
## Pull Requests
Wiki: [How to make a pull request](https://github.com/apache/incubator-echarts/wiki/How-to-make-a-pull-request)
## How to Debug ECharts
Wiki: [How to setup the dev environment](https://github.com/apache/incubator-echarts/wiki/How-to-setup-the-dev-environment)
## Some hints about using code from other authors
+ About using some algorithms/formulas or inspired by other's work:
+ We can be inspired from other people’s work. There is no problem with copying ideas and no problems associated with that so long as the code is entirely yours and you aren’t violating the license of the inspirational work. You can just follow "normal" source code rules.
+ But when you copy the code, even parts of files, it must remain under the copyright of the original authors.
+ What's the right thing to do for the public good here? I'll go with:
+ Be transparent when implementing an existing idea/algorithm.
+ Reference where that idea/algorithm came from.
+ Use standard language when doing so (we need to define standard language).
+ "inspired by", "learned from" and "references to" are vague concepts in copyright.
+ If any copyrightable expression is copied from the existing idea/algorithm, compare its licensing to our licensing policies and include licensing accordingly.
+ Check the original discussion about it in: https://lists.apache.org/list.html?legal-discuss@apache.org:lte=36M:echarts
+ About adding the license/header of 3rd-party work:
+ https://www.apache.org/legal/src-headers.html#3party
+ Licenses that are compatible with the Apache license:
+ BSD and MIT are compatible with the Apache license but CC_BY_SA is not (https://apache.org/legal/resolved.html#cc-sa).
+ Stack overflow:
+ before intending to copy code from Stack overlow, we must check:
+ https://apache.org/legal/resolved.html#stackoverflow
+ https://issues.apache.org/jira/browse/LEGAL-471
+ Wikipedia:
+ Wikipedia is licensed CC 4.0 BY_SA and is incompatible with the Apache license. So we should not copy code from Wikipedia.
+ Working in progress disclaimer:
+ In some cases we might use the work in progress disclaimer and document the issues in that until they are fixed.
+ https://incubator.apache.org/policy/incubation.html#disclaimers
Apache ECharts (incubating) is an effort undergoing incubation at The
Apache Software Foundation (ASF), sponsored by the Apache Incubator PMC.
Incubation is required of all newly accepted
projects until a further review indicates that the
infrastructure, communications, and decision making process have
stabilized in a manner consistent with other successful ASF
projects.
While incubation status is not necessarily a reflection
of the completeness or stability of the code, it does indicate
that the project has yet to be fully endorsed by the ASF.
This file contains the PGP keys of various developers.
Please don't use them for email unless you have to. Their main
purpose is code signing.
Examples of importing this file in your keystore:
gpg --import KEYS.txt
(need pgp and other examples here)
Examples of adding your key to this file:
pgp -kxa <your name> and append it to this file.
(pgpk -ll <your name> && pgpk -xa <your name>) >> this file.
(gpg --list-sigs <your name>
&& gpg --armor --export <your name>) >> this file.
---------------------------------------
pub rsa4096 2018-04-23 [SC]
9B06D9B4FA37C4DD52725742747985D7E3CEB635
uid [ultimate] Su Shuang (CODE SIGNING KEY) <sushuang@apache.org>
sig 3 747985D7E3CEB635 2018-04-23 Su Shuang (CODE SIGNING KEY) <sushuang@apache.org>
sub rsa4096 2018-04-23 [E]
sig 747985D7E3CEB635 2018-04-23 Su Shuang (CODE SIGNING KEY) <sushuang@apache.org>
-----BEGIN PGP PUBLIC KEY BLOCK-----
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
oQH7TsthVKvdZyjtZQg=
=Uv8d
-----END PGP PUBLIC KEY BLOCK-----
pub rsa4096 2019-01-24 [SC]
1683FBD23F6DD36C0E52223507D78F777D2C0C27
uid [ultimate] Ovilia (CODE SIGNING KEY) <oviliazhang@gmail.com>
sig 3 07D78F777D2C0C27 2019-01-24 Ovilia (CODE SIGNING KEY) <oviliazhang@gmail.com>
sub rsa4096 2019-01-24 [E]
sig 07D78F777D2C0C27 2019-01-24 Ovilia (CODE SIGNING KEY) <oviliazhang@gmail.com>
-----BEGIN PGP PUBLIC KEY BLOCK-----
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
B4WM8AJSCwl8WlZrRA==
=wft0
-----END PGP PUBLIC KEY BLOCK-----
Apache ECharts (incubating)
Copyright 2017-2020 The Apache Software Foundation
This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).
# ECharts
<a href="https://echarts.apache.org/">
<img style="vertical-align: top;" src="./asset/logo.png?raw=true" alt="logo" height="50px">
</a>
ECharts is a free, powerful charting and visualization library offering an easy way of adding intuitive, interactive, and highly customizable charts to your commercial products. It is written in pure JavaScript and based on <a href="https://github.com/ecomfe/zrender">zrender</a>, which is a whole new lightweight canvas library.
Now ECharts is an incubator project of Apache Software Foundation.
Please check its incubator status [here](http://incubator.apache.org/projects/echarts.html)
**[中文官网](https://echarts.apache.org/zh/index.html)** | **[ENGLISH HOMEPAGE](https://echarts.apache.org/en/index.html)**
[![Build Status](https://travis-ci.org/apache/incubator-echarts.svg?branch=master)](https://travis-ci.org/apache/incubator-echarts) [![](https://img.shields.io/npm/dw/echarts.svg?label=npm%20downloads&style=flat)](https://www.npmjs.com/package/echarts) [![Last npm release](https://img.shields.io/npm/v/echarts)](https://www.npmjs.com/package/echarts)
## Get ECharts
You may choose one of the following methods:
+ Download from Official Website in [中文下载页](https://echarts.apache.org/zh/download.html)
+ Download from Official Website in [English](https://echarts.apache.org/en/download.html)
+ `npm install echarts --save`
+ CDN: [jsDelivr CDN](https://www.jsdelivr.com/package/npm/echarts?path=dist)
## Docs
+ Tutorial
+ [中文](https://echarts.apache.org/zh/tutorial.html)
+ [English](https://echarts.apache.org/en/tutorial.html)
+ API
+ [中文](https://echarts.apache.org/zh/api.html)
+ [English](https://echarts.apache.org/en/api.html)
+ Option Manual
+ [中文](https://echarts.apache.org/zh/option.html)
+ [English](https://echarts.apache.org/en/option.html)
## Get Help
+ [GitHub Issues](https://github.com/apache/incubator-echarts/issues) for bug report and feature requests
+ Email [dev@echarts.apache.org](mailto:dev@echarts.apache.org) for general questions
+ Subscribe [mailing list](https://echarts.apache.org/en/maillist.html) to get updated with the project
## Build
Build echarts source code:
Execute the instructions in the root directory of the echarts:
([Node.js](https://nodejs.org) is required)
```shell
# Install the dependencies from NPM:
npm install
# If intending to build and get all types of the "production" files:
npm run release
# The same as `node build/build.js --release`
# If only intending to get `dist/echarts.js`, which is usually
# enough in dev or running the tests:
npm run build
# The same as `node build/build.js`
# Get the same "production" files as `node build/build.js`, while
# watching the editing of the source code. Usually used in dev.
npm run watch
# The same as `node build/build.js -w`
# Check the manual:
npm run help
# The same as `node build/build.js --help`
```
Then the "production" files are generated in the `dist` directory.
More custom build approaches can be checked in this tutorial: [Create Custom Build of ECharts](https://echarts.apache.org/en/tutorial.html#Create%20Custom%20Build%20of%20ECharts) please.
## Contribution
If you wish to debug locally or make pull requests, please refer to [contributing](https://github.com/apache/incubator-echarts/blob/master/CONTRIBUTING.md) document.
## Resources
### Awesome ECharts
[https://github.com/ecomfe/awesome-echarts](https://github.com/ecomfe/awesome-echarts)
### Extensions
+ [ECharts GL](https://github.com/ecomfe/echarts-gl) An extension pack of ECharts, which provides 3D plots, globe visualization, and WebGL acceleration.
+ [Liquidfill 水球图](https://github.com/ecomfe/echarts-liquidfill)
+ [Wordcloud 字符云](https://github.com/ecomfe/echarts-wordcloud)
+ [Extension for Baidu Map 百度地图扩展](https://github.com/apache/incubator-echarts/tree/master/extension/bmap) An extension provides a wrapper of Baidu Map Service SDK.
+ [vue-echarts](https://github.com/ecomfe/vue-echarts) ECharts component for Vue.js
+ [echarts-stat](https://github.com/ecomfe/echarts-stat) Statistics tool for ECharts
## License
ECharts is available under the Apache License V2.
## Code of Conduct
Please refer to [Apache Code of Conduct](https://www.apache.org/foundation/policies/conduct.html).
## Paper
Deqing Li, Honghui Mei, Yi Shen, Shuang Su, Wenli Zhang, Junting Wang, Ming Zu, Wei Chen.
[ECharts: A Declarative Framework for Rapid Construction of Web-based Visualization](https://www.sciencedirect.com/science/article/pii/S2468502X18300068).
Visual Informatics, 2018.
{
"bitwise": false,
"camelcase": true,
"curly": true,
"eqeqeq": false,
"forin": false,
"immed": true,
"latedef": false,
"newcap": true,
"noarg": false,
"noempty": true,
"nonew": true,
"plusplus": false,
"quotmark": "single",
"regexp": false,
"undef": true,
"unused": "vars",
"strict": false,
"trailing": false,
"maxparams": 20,
"maxdepth": 6,
"maxlen": 200,
"asi": false,
"boss": false,
"debug": false,
"eqnull": true,
"esversion": 6,
"evil": true,
"expr": true,
"funcscope": false,
"globalstrict": false,
"iterator": false,
"lastsemic": false,
"laxbreak": true,
"laxcomma": false,
"loopfunc": false,
"multistr": false,
"onecase": false,
"proto": false,
"regexdash": false,
"scripturl": false,
"smarttabs": false,
"shadow": true,
"sub": true,
"supernew": false,
"validthis": true,
"browser": true,
"couch": false,
"devel": true,
"dojo": false,
"jquery": true,
"mootools": false,
"node": false,
"nonstandard": false,
"prototypejs": false,
"rhino": false,
"wsh": false,
"nomen": false,
"onevar": false,
"passfail": false,
"white": false,
"varstmt": true,
"predef": [
"__DEV__",
"global",
"require",
"exports",
"Buffer",
"module",
"__dirname"
]
}
\ No newline at end of file
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
const fs = require('fs');
const preamble = require('./preamble');
const pathTool = require('path');
const {color} = require('zrender/build/helper');
// In the `.headerignore`, each line is a pattern in RegExp.
// all relative path (based on the echarts base directory) is tested.
// The pattern should match the relative path completely.
const excludesPath = pathTool.join(__dirname, '../.headerignore');
const ecBasePath = pathTool.join(__dirname, '../');
const isVerbose = process.argv[2] === '--verbose';
// const lists = [
// '../src/**/*.js',
// '../build/*.js',
// '../benchmark/src/*.js',
// '../benchmark/src/gulpfile.js',
// '../extension-src/**/*.js',
// '../extension/**/*.js',
// '../map/js/**/*.js',
// '../test/build/**/*.js',
// '../test/node/**/*.js',
// '../test/ut/core/*.js',
// '../test/ut/spe/*.js',
// '../test/ut/ut.js',
// '../test/*.js',
// '../theme/*.js',
// '../theme/tool/**/*.js',
// '../echarts.all.js',
// '../echarts.blank.js',
// '../echarts.common.js',
// '../echarts.simple.js',
// '../index.js',
// '../index.common.js',
// '../index.simple.js'
// ];
function run() {
const updatedFiles = [];
const passFiles = [];
const pendingFiles = [];
eachFile(function (absolutePath, fileExt) {
const fileStr = fs.readFileSync(absolutePath, 'utf-8');
const existLicense = preamble.extractLicense(fileStr, fileExt);
if (existLicense) {
passFiles.push(absolutePath);
return;
}
// Conside binary files, only add for files with known ext.
if (!preamble.hasPreamble(fileExt)) {
pendingFiles.push(absolutePath);
return;
}
fs.writeFileSync(absolutePath, preamble.addPreamble(fileStr, fileExt), 'utf-8');
updatedFiles.push(absolutePath);
});
console.log('\n');
console.log('----------------------------');
console.log(' Files that exists license: ');
console.log('----------------------------');
if (passFiles.length) {
if (isVerbose) {
passFiles.forEach(function (path) {
console.log(color('fgGreen', 'dim')(path));
});
}
else {
console.log(color('fgGreen', 'dim')(passFiles.length + ' files. (use argument "--verbose" see details)'));
}
}
else {
console.log('Nothing.');
}
console.log('\n');
console.log('--------------------');
console.log(' License added for: ');
console.log('--------------------');
if (updatedFiles.length) {
updatedFiles.forEach(function (path) {
console.log(color('fgGreen', 'bright')(path));
});
}
else {
console.log('Nothing.');
}
console.log('\n');
console.log('----------------');
console.log(' Pending files: ');
console.log('----------------');
if (pendingFiles.length) {
pendingFiles.forEach(function (path) {
console.log(color('fgRed', 'dim')(path));
});
}
else {
console.log('Nothing.');
}
console.log('\nDone.');
}
function eachFile(visit) {
const excludePatterns = [];
const extReg = /\.([a-zA-Z0-9_-]+)$/;
prepareExcludePatterns();
travel('./');
function travel(relativePath) {
if (isExclude(relativePath)) {
return;
}
const absolutePath = pathTool.join(ecBasePath, relativePath);
const stat = fs.statSync(absolutePath);
if (stat.isFile()) {
visit(absolutePath, getExt(absolutePath));
}
else if (stat.isDirectory()) {
fs.readdirSync(relativePath).forEach(function (file) {
travel(pathTool.join(relativePath, file));
});
}
}
function prepareExcludePatterns() {
const content = fs.readFileSync(excludesPath, {encoding: 'utf-8'});
content.replace(/\r/g, '\n').split('\n').forEach(function (line) {
line = line.trim();
if (line && line.charAt(0) !== '#') {
excludePatterns.push(new RegExp(line));
}
});
}
function isExclude(relativePath) {
for (let i = 0; i < excludePatterns.length; i++) {
if (excludePatterns[i].test(relativePath)) {
return true;
}
}
}
function getExt(path) {
if (path) {
const mathResult = path.match(extReg);
return mathResult && mathResult[1];
}
}
}
run();
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var glob = require('glob');
var fsExtra = require('fs-extra');
var esprima = require('esprima');
function run(cb) {
glob('**/*.js', {
cwd: __dirname + '/../src/'
}, function (err, files) {
files.forEach(function (filePath) {
var code = parse(fsExtra.readFileSync(
__dirname + '/../src/' + filePath, 'utf-8'));
code = code.replace(/require\(([\'"])zrender\//g, 'require($1zrender/lib/');
fsExtra.outputFileSync(
__dirname + '/../lib/' + filePath,
code, 'utf-8');
});
cb && cb();
});
}
if (require.main === module) {
run();
}
else {
module.exports = run;
}
var MAGIC_DEPS = {
'exports': true,
'module': true,
'require': true
};
var SIMPLIFIED_CJS = ['require', 'exports', 'module'];
// Convert AMD-style JavaScript string into node.js compatible module
function parse(raw) {
var output = '';
var ast = esprima.parse(raw, {
range: true,
raw: true
});
var defines = ast.body.filter(isDefine);
if (defines.length > 1) {
throw new Error('Each file can have only a single define call. Found "' + defines.length + '"');
}
else if (!defines.length) {
return raw;
}
var def = defines[0];
var args = def.expression['arguments'];
var factory = getFactory(args);
var useStrict = getUseStrict(factory);
// do replacements in-place to avoid modifying the code more than needed
if (useStrict) {
output += useStrict.expression.raw + ';\n';
}
output += raw.substring(0, def.range[0]); // anything before define
output += getRequires(args, factory); // add requires
output += getBody(raw, factory.body, useStrict); // module body
output += raw.substring(def.range[1], raw.length); // anything after define
return output;
}
function getRequires(args, factory) {
var requires = [];
var deps = getDependenciesNames(args);
var params = factory.params.map(function (param, i) {
return {
name: param.name,
// simplified cjs doesn't have deps
dep: (deps.length) ? deps[i] : SIMPLIFIED_CJS[i]
};
});
params.forEach(function (param) {
if (MAGIC_DEPS[param.dep] && !MAGIC_DEPS[param.name]) {
// if user remaped magic dependency we declare a var
requires.push('var ' + param.name + ' = ' + param.dep + ';');
}
else if (param.dep && !MAGIC_DEPS[param.dep]) {
// only do require for params that have a matching dependency also
// skip "magic" dependencies
requires.push('var ' + param.name + ' = require(\'' + param.dep + '\');');
}
});
return requires.join('\n');
}
function getDependenciesNames(args) {
var deps = [];
var arr = args.filter(function (arg) {
return arg.type === 'ArrayExpression';
})[0];
if (arr) {
deps = arr.elements.map(function (el) {
return el.value;
});
}
return deps;
}
function isDefine(node) {
return node.type === 'ExpressionStatement'
&& node.expression.type === 'CallExpression'
&& node.expression.callee.type === 'Identifier'
&& node.expression.callee.name === 'define';
}
function getFactory(args) {
return args.filter(function (arg) {
return arg.type === 'FunctionExpression';
})[0];
}
function getBody(raw, factoryBody, useStrict) {
var returnStatement = factoryBody.body.filter(function (node) {
return node.type === 'ReturnStatement';
})[0];
var body = '';
var bodyStart = useStrict ? useStrict.expression.range[1] + 1 : factoryBody.range[0] + 1;
if (returnStatement) {
body += raw.substring(bodyStart, returnStatement.range[0]);
// "return ".length === 7 so we add "6" to returnStatement start
body += 'module.exports =' + raw.substring(returnStatement.range[0] + 6, factoryBody.range[1] - 1);
}
else {
// if using exports or module.exports or just a private module we
// simply return the factoryBody content
body = raw.substring(bodyStart, factoryBody.range[1] - 1);
}
return body;
}
function getUseStrict(factory) {
return factory.body.body.filter(isUseStrict)[0];
}
function isUseStrict(node) {
return node.type === 'ExpressionStatement'
&& node.expression.type === 'Literal'
&& node.expression.value === 'use strict';
}
#!/usr/bin/env node
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
const fsExtra = require('fs-extra');
const fs = require('fs');
const {resolve} = require('path');
const config = require('./config.js');
const commander = require('commander');
const {build, watch, color} = require('zrender/build/helper');
const ecLangPlugin = require('./rollup-plugin-ec-lang');
const prePublish = require('./pre-publish');
const recheckDEV = require('zrender/build/babel-plugin-transform-remove-dev').recheckDEV;
function run() {
/**
* Tips for `commander`:
* (1) If arg xxx not specified, `commander.xxx` is undefined.
* Otherwise:
* If '-x, --xxx', `commander.xxx` can only be true/false, even if '--xxx yyy' input.
* If '-x, --xxx <some>', the 'some' string is required, or otherwise error will be thrown.
* If '-x, --xxx [some]', the 'some' string is optional, that is, `commander.xxx` can be boolean or string.
* (2) `node ./build/build.js --help` will print helper info and exit.
*/
let descIndent = ' ';
let egIndent = ' ';
commander
.usage('[options]')
.description([
'Build echarts and generate result files in directory `echarts/dist`.',
'',
' For example:',
'',
egIndent + 'node build/build.js --release'
+ '\n' + descIndent + '# Build all to `dist` folder.',
egIndent + 'node build/build.js --prepublish'
+ '\n' + descIndent + '# Only prepublish.',
egIndent + 'node build/build.js --removedev'
+ '\n' + descIndent + '# Remove __DEV__ code. If --min, __DEV__ always be removed.',
egIndent + 'node build/build.js --type ""'
+ '\n' + descIndent + '# Only generate `dist/echarts.js`.',
egIndent + 'node build/build.js --type common --min'
+ '\n' + descIndent + '# Only generate `dist/echarts.common.min.js`.',
egIndent + 'node build/build.js --type simple --min --lang en'
+ '\n' + descIndent + '# Only generate `dist/echarts-en.simple.min.js`.',
egIndent + 'node build/build.js --lang "my/lang.js" -i "my/index.js" -o "my/bundle.js"'
+ '\n' + descIndent + '# Take `<cwd>/my/index.js` as input and generate `<cwd>/my/bundle.js`,'
+ '\n' + descIndent + 'where `<cwd>/my/lang.js` is used as language file.',
].join('\n'))
.option(
'-w, --watch', [
'Watch modifications of files and auto-compile to dist file. For example,',
descIndent + '`echarts/dist/echarts.js`.'
].join('\n'))
.option(
'--lang <language file path or shortcut>', [
'Use the specified file instead of `echarts/src/lang.js`. For example:',
descIndent + '`--lang en` will use `echarts/src/langEN.js`.',
descIndent + '`--lang my/langDE.js` will use `<cwd>/my/langDE.js`. -o must be specified in this case.',
descIndent + '`--lang /my/indexSW.js` will use `/my/indexSW.js`. -o must be specified in this case.'
].join('\n'))
.option(
'--release',
'Build all for release'
)
.option(
'--prepublish',
'Build all for release'
)
.option(
'--removedev',
'Remove __DEV__ code. If --min, __DEV__ always be removed.'
)
.option(
'--min',
'Whether to compress the output file, and remove error-log-print code.'
)
.option(
'--type <type name>', [
'Can be "simple" or "common" or "" (default). For example,',
descIndent + '`--type ""` or `--type "common"`.'
].join('\n'))
.option(
'--sourcemap',
'Whether output sourcemap.'
)
.option(
'--format <format>',
'The format of output bundle. Can be "umd", "amd", "iife", "cjs", "es".'
)
.option(
'-i, --input <input file path>',
'If input file path is specified, output file path must be specified too.'
)
.option(
'-o, --output <output file path>',
'If output file path is specified, input file path must be specified too.'
)
.parse(process.argv);
let isWatch = !!commander.watch;
let isRelease = !!commander.release;
let isPrePublish = !!commander.prepublish;
let opt = {
lang: commander.lang,
min: commander.min,
type: commander.type || '',
input: commander.input,
output: commander.output,
format: commander.format,
sourcemap: commander.sourcemap,
removeDev: commander.removedev,
addBundleVersion: isWatch
};
validateIO(opt.input, opt.output);
validateLang(opt.lang, opt.output);
normalizeParams(opt);
// Clear `echarts/dist`
if (isRelease) {
fsExtra.removeSync(getPath('./dist'));
}
if (isWatch) {
watch(config.createECharts(opt));
}
else if (isPrePublish) {
prePublish();
}
else if (isRelease) {
let configs = [];
let configForCheck;
[
{min: false},
{min: true},
{min: false, lang: 'en'},
{min: true, lang: 'en'}
].forEach(function (opt) {
['', 'simple', 'common'].forEach(function (type) {
let singleOpt = Object.assign({type}, opt);
normalizeParams(singleOpt);
let singleConfig = config.createECharts(singleOpt);
configs.push(singleConfig);
if (singleOpt.min && singleOpt.type === '') {
configForCheck = singleConfig;
}
});
});
configs.push(
config.createBMap(false),
config.createBMap(true),
config.createDataTool(false),
config.createDataTool(true)
);
build(configs)
.then(function () {
checkCode(configForCheck);
prePublish();
}).catch(handleBuildError);
}
else {
let cfg = config.createECharts(opt);
build([cfg])
.then(function () {
if (opt.removeDev) {
checkCode(cfg);
}
})
.catch(handleBuildError);
}
}
function normalizeParams(opt) {
if (opt.sourcemap == null) {
opt.sourcemap = !(opt.min || opt.type);
}
if (opt.removeDev == null) {
opt.removeDev = !!opt.min;
}
}
function handleBuildError(err) {
console.log(err);
}
function checkCode(singleConfig) {
// Make sure __DEV__ is eliminated.
let code = fs.readFileSync(singleConfig.output.file, {encoding: 'utf-8'});
if (!code) {
throw new Error(`${singleConfig.output.file} is empty`);
}
recheckDEV(code);
console.log(color('fgGreen', 'dim')('Check code: correct.'));
}
function validateIO(input, output) {
if ((input != null && output == null)
|| (input == null && output != null)
) {
throw new Error('`input` and `output` must be both set.');
}
}
function validateLang(lang, output) {
if (!lang) {
return;
}
let langInfo = ecLangPlugin.getLangFileInfo(lang);
if (langInfo.isOuter && !output) {
throw new Error('`-o` or `--output` must be specified if using a file path in `--lang`.');
}
if (!langInfo.absolutePath || !fs.statSync(langInfo.absolutePath).isFile()) {
throw new Error(`File ${langInfo.absolutePath} does not exist yet. Contribution is welcome!`);
}
}
/**
* @param {string} relativePath Based on echarts directory.
* @return {string} Absolute path.
*/
function getPath(relativePath) {
return resolve(__dirname, '../', relativePath);
}
run();
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
const nodeResolvePlugin = require('rollup-plugin-node-resolve');
const uglifyPlugin = require('rollup-plugin-uglify');
const ecRemoveDevPlugin = require('./rollup-plugin-ec-remove-dev');
const ecLangPlugin = require('./rollup-plugin-ec-lang');
const {resolve} = require('path');
const preamble = require('./preamble');
function getPathBasedOnECharts(path) {
return resolve(__dirname, '../', path);
}
function getPlugins({min, lang, sourcemap, removeDev, addBundleVersion}) {
let plugins = [];
removeDev && plugins.push(
ecRemoveDevPlugin({sourcemap})
);
lang && plugins.push(
ecLangPlugin({lang})
);
plugins.push(
nodeResolvePlugin()
);
addBundleVersion && plugins.push({
outro: function () {
return 'exports.bundleVersion = \'' + (+new Date()) + '\';';
}
});
min && plugins.push(uglifyPlugin({
compress: {
// Eliminate __DEV__ code.
// Currently, in uglify:
// `var vx; if(vx) {...}` can not be removed.
// `if (__DEV__) {...}` can be removed if `__DEV__` is defined as `false` in `global_defs`.
// 'global_defs': {
// __DEV__: false
// },
'dead_code': true
},
output: {
preamble: preamble.js
}
}));
return plugins;
}
/**
* @param {Object} [opt]
* @param {string} [opt.type=''] '' or 'simple' or 'common'
* @param {boolean} [opt.min=false]
* @param {string} [opt.lang=undefined] null/undefined/'' or 'en' or 'fi' or a file path.
* @param {string} [opt.input=undefined] If set, `opt.output` is required too, and `opt.type` is ignored.
* @param {string} [opt.output=undefined] If set, `opt.input` is required too, and `opt.type` is ignored.
* @param {boolean} [opt.sourcemap] If set, `opt.input` is required too, and `opt.type` is ignored.
* @param {boolean} [opt.removeDev]
* @param {string} [opt.format='umd'] If set, `opt.input` is required too, and `opt.type` is ignored.
* @param {boolean} [opt.addBundleVersion=false] Only for debug in watch, prompt that the two build is different.
*/
exports.createECharts = function (opt = {}) {
let min = opt.min;
let srcType = opt.type ? '.' + opt.type : '.all';
let postfixType = opt.type ? '.' + opt.type : '';
let postfixMin = min ? '.min' : '';
let postfixLang = opt.lang ? '-' + opt.lang.toLowerCase() : '';
let input = opt.input;
let output = opt.output;
let sourcemap = opt.sourcemap;
let format = opt.format || 'umd';
if (input != null || output != null) {
// Based on process.cwd();
input = resolve(input);
output = resolve(output);
}
else {
input = getPathBasedOnECharts(`./echarts${srcType}.js`);
output = getPathBasedOnECharts(`dist/echarts${postfixLang}${postfixType}${postfixMin}.js`);
}
return {
plugins: getPlugins(opt),
input: input,
legacy: true, // Support IE8-
output: {
name: 'echarts',
format: format,
sourcemap: sourcemap,
legacy: true, // Must be declared both in inputOptions and outputOptions.
file: output
},
watch: {
include: [
getPathBasedOnECharts('./src/**'),
getPathBasedOnECharts('./echarts*.js'),
getPathBasedOnECharts('../zrender/src/**')
]
}
};
};
/**
* @param {boolean} [min=false]
*/
exports.createBMap = function (min) {
let postfix = min ? '.min' : '';
return {
plugins: getPlugins({min}),
input: getPathBasedOnECharts(`./extension-src/bmap/bmap.js`),
legacy: true, // Support IE8-
external: ['echarts'],
output: {
name: 'bmap',
format: 'umd',
sourcemap: !min,
legacy: true, // Must be declared both in inputOptions and outputOptions.
globals: {
// For UMD `global.echarts`
echarts: 'echarts'
},
file: getPathBasedOnECharts(`dist/extension/bmap${postfix}.js`)
},
watch: {
include: [getPathBasedOnECharts('./extension-src/bmap/**')]
}
};
};
/**
* @param {boolean} [min=false]
*/
exports.createDataTool = function (min) {
let postfix = min ? '.min' : '';
return {
plugins: getPlugins({min}),
input: getPathBasedOnECharts(`./extension-src/dataTool/index.js`),
legacy: true, // Support IE8-
external: ['echarts'],
output: {
name: 'dataTool',
format: 'umd',
sourcemap: !min,
legacy: true, // Must be declared both in inputOptions and outputOptions.
globals: {
// For UMD `global.echarts`
echarts: 'echarts'
},
file: getPathBasedOnECharts(`dist/extension/dataTool${postfix}.js`)
},
watch: {
include: [getPathBasedOnECharts('./extension-src/dataTool/**')]
}
};
};
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var esprima = require('esprima');
var escodegen = require('escodegen');
var estraverse = require('estraverse');
var SYNTAX = estraverse.Syntax;
var STR_MIN_LENGTH = 5;
var STR_MIN_DIST = 1000;
var STR_MIN_COUNT = 2;
function createDeclaration(declarations) {
return {
type: SYNTAX.VariableDeclaration,
declarations: declarations,
kind: 'var'
};
}
function createDeclarator(id, init) {
return {
type: SYNTAX.VariableDeclarator,
id: {
type: SYNTAX.Identifier,
name: id
},
init: {
type: SYNTAX.Literal,
value: init
}
};
}
function base54Digits() {
return 'etnrisouaflchpdvmgybwESxTNCkLAOM_DPHBjFIqRUzWXV$JKQGYZ0516372984';
}
var base54 = (function(){
var DIGITS = base54Digits();
return function(num) {
var ret = '';
var base = 54;
do {
ret += DIGITS.charAt(num % base);
num = Math.floor(num / base);
base = 64;
} while (num > 0);
return ret;
};
})();
function mangleString(source) {
var ast = esprima.parse(source, {
loc: true
});
var stringVariables = {};
var stringRelaceCount = 0;
estraverse.traverse(ast, {
enter: function (node, parent) {
if (node.type === SYNTAX.Literal
&& typeof node.value === 'string'
) {
// Ignore if string is the key of property
if (parent.type === SYNTAX.Property) {
return;
}
var value = node.value;
if (value.length > STR_MIN_LENGTH) {
if (!stringVariables[value]) {
stringVariables[value] = {
count: 0,
lastLoc: node.loc.start.line,
name: '__echartsString__' + base54(stringRelaceCount++)
};
}
var diff = node.loc.start.line - stringVariables[value].lastLoc;
// GZIP ?
if (diff >= STR_MIN_DIST) {
stringVariables[value].lastLoc = node.loc.start.line;
stringVariables[value].count++;
}
}
}
if (node.type === SYNTAX.MemberExpression && !node.computed) {
if (node.property.type === SYNTAX.Identifier) {
var value = node.property.name;
if (value.length > STR_MIN_LENGTH) {
if (!stringVariables[value]) {
stringVariables[value] = {
count: 0,
lastLoc: node.loc.start.line,
name: '__echartsString__' + base54(stringRelaceCount++)
};
}
var diff = node.loc.start.line - stringVariables[value].lastLoc;
if (diff >= STR_MIN_DIST) {
stringVariables[value].lastLoc = node.loc.start.line;
stringVariables[value].count++;
}
}
}
}
}
});
estraverse.replace(ast, {
enter: function (node, parent) {
if ((node.type === SYNTAX.Literal
&& typeof node.value === 'string')
) {
// Ignore if string is the key of property
if (parent.type === SYNTAX.Property) {
return;
}
var str = node.value;
if (stringVariables[str] && stringVariables[str].count > STR_MIN_COUNT) {
return {
type: SYNTAX.Identifier,
name: stringVariables[str].name
};
}
}
if (node.type === SYNTAX.MemberExpression && !node.computed) {
if (node.property.type === SYNTAX.Identifier) {
var str = node.property.name;
if (stringVariables[str] && stringVariables[str].count > STR_MIN_COUNT) {
return {
type: SYNTAX.MemberExpression,
object: node.object,
property: {
type: SYNTAX.Identifier,
name: stringVariables[str].name
},
computed: true
};
}
}
}
}
});
// Add variables in the top
for (var str in stringVariables) {
// Used more than once
if (stringVariables[str].count > STR_MIN_COUNT) {
ast.body.unshift(createDeclaration([
createDeclarator(stringVariables[str].name, str)
]));
}
}
return escodegen.generate(
ast,
{
format: {escapeless: true},
comment: true
}
);
}
exports = module.exports = mangleString;
\ No newline at end of file
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var UglifyJS = require('uglify-js');
var fs = require('fs');
var etpl = require('etpl');
var argv = require('optimist').argv;
etpl.config({
commandOpen: '/**',
commandClose: '*/'
});
var mode = argv.m || 'all';
var configPath = mode === 'all' ? 'config/echarts.js' : 'config/echarts.' + mode + '.js';
var outPath = mode === 'all' ? '../dist/echarts.js' : '../dist/echarts.' + mode + '.js';
var config = eval('(' + fs.readFileSync(configPath, 'utf-8') + ')');
var mainCode = fs.readFileSync(outPath, 'utf-8');
var startCode = fs.readFileSync('wrap/start.js', 'utf-8');
var nutCode = fs.readFileSync('wrap/nut.js', 'utf-8');
var endCode = fs.readFileSync('wrap/end.js', 'utf-8');
endCode = etpl.compile(endCode)({
parts: config.include
});
// FIXME
var sourceCode = [startCode, nutCode, require('./mangleString')(mainCode), endCode].join('\n');
var ast = UglifyJS.parse(sourceCode);
/* jshint camelcase: false */
// compressor needs figure_out_scope too
ast.figure_out_scope();
ast = ast.transform(UglifyJS.Compressor( {} ));
// need to figure out scope again so mangler works optimally
ast.figure_out_scope();
ast.compute_char_frequency();
ast.mangle_names();
fs.writeFileSync(outPath, [startCode, nutCode, mainCode, endCode].join('\n'), 'utf-8');
fs.writeFileSync(outPath.replace('.js', '.min.js'), ast.print_to_string(), 'utf-8');
\ No newline at end of file
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* Compatible with prevoius folder structure: `echarts/lib` exists in `node_modules`
* (1) Build all files to CommonJS to `echarts/lib`.
* (2) Remove __DEV__.
* (3) Mount `echarts/src/export.js` to `echarts/lib/echarts.js`.
*/
const path = require('path');
const fsExtra = require('fs-extra');
const {color, travelSrcDir, prePulishSrc} = require('zrender/build/helper');
const ecDir = path.resolve(__dirname, '..');
const srcDir = path.resolve(__dirname, '../src');
const extensionSrcDir = path.resolve(__dirname, '../extension-src');
const extensionDir = path.resolve(__dirname, '../extension');
const libDir = path.resolve(__dirname, '../lib');
const preamble = require('./preamble');
module.exports = function () {
fsExtra.removeSync(libDir);
fsExtra.ensureDirSync(libDir);
travelSrcDir(srcDir, ({fileName, relativePath, absolutePath}) => {
prePulishSrc({
inputPath: absolutePath,
outputPath: path.resolve(libDir, relativePath, fileName),
transform: transform,
preamble: preamble.js
});
});
travelSrcDir(extensionSrcDir, ({fileName, relativePath, absolutePath}) => {
prePulishSrc({
inputPath: absolutePath,
outputPath: path.resolve(extensionDir, relativePath, fileName),
transform: transform,
preamble: preamble.js
});
});
prePulishSrc({
inputPath: path.resolve(ecDir, 'echarts.all.js'),
outputPath: path.resolve(ecDir, 'index.js'),
preamble: preamble.js
});
prePulishSrc({
inputPath: path.resolve(ecDir, 'echarts.common.js'),
outputPath: path.resolve(ecDir, 'index.common.js'),
preamble: preamble.js
});
prePulishSrc({
inputPath: path.resolve(ecDir, 'echarts.simple.js'),
outputPath: path.resolve(ecDir, 'index.simple.js'),
preamble: preamble.js
});
function transform({code, inputPath, outputPath}) {
if (inputPath === path.resolve(ecDir, 'src/echarts.js')) {
// Using `echarts/echarts.blank.js` to overwrite `echarts/lib/echarts.js`
// for including exports API.
code += `
var ___ec_export = require("./export");
(function () {
for (var key in ___ec_export) {
if (___ec_export.hasOwnProperty(key)) {
exports[key] = ___ec_export[key];
}
}
})();`;
}
return code;
}
console.log(color('fgGreen', 'bright')('All done.'));
};
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
const cStyleComment = `
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
`;
const hashComment = `
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
`;
const mlComment = `
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
`;
function hasPreamble(fileExt) {
return fileExt && preambleMap[fileExt];
}
function addPreamble(fileStr, fileExt) {
if (fileStr && fileExt) {
const addFn = addFns[fileExt];
const headStr = preambleMap[fileExt];
return addFn && headStr && addFn(headStr, fileStr);
}
}
const addFns = {
js: function (headStr, fileStr) {
return headStr + fileStr;
},
css: function (headStr, fileStr) {
return headStr + fileStr;
},
java: function (headStr, fileStr) {
return headStr + fileStr;
},
sh: function (headStr, fileStr) {
// Git diff enables manual check.
if (/^#\!/.test(fileStr)) {
const lines = fileStr.split('\n');
lines.splice(1, 0, headStr);
return lines.join('\n');
}
else {
return headStr + fileStr;
}
},
html: function (headStr, fileStr) {
// Git diff enables manual check.
let resultStr = fileStr.replace(/^\s*<!DOCTYPE\s[^<>]+>/i, '$&' + headStr);
// If no doctype
if (resultStr.length === fileStr.length) {
resultStr = headStr + fileStr;
}
return resultStr;
},
xml: xmlAddFn,
xsl: xmlAddFn
};
function xmlAddFn(headStr, fileStr) {
// Git diff enables manual check.
let resultStr = fileStr.replace(/^\s*<\?xml\s[^<>]+\?>/i, '$&' + headStr);
// If no <?xml version='1.0' ?>
if (resultStr.length === fileStr.length) {
resultStr = headStr + fileStr;
}
return resultStr;
}
const preambleMap = {
js: cStyleComment,
css: cStyleComment,
java: cStyleComment,
sh: hashComment,
html: mlComment,
xml: mlComment,
xsl: mlComment
};
const licenseReg = [
{name: 'Apache', reg: /apache (license|commons)/i},
{name: 'BSD', reg: /BSD/},
{name: 'LGPL', reg: /LGPL/},
{name: 'GPL', reg: /GPL/},
{name: 'Mozilla', reg: /mozilla public/i},
{name: 'MIT', reg: /mit license/i},
{name: 'BSD-d3', reg: /Copyright\s+\(c\)\s+2010-2015,\s+Michael\s+Bostock/i}
];
function extractLicense(fileStr, fileExt) {
let commentText = extractComment(fileStr.trim(), fileExt);
if (!commentText) {
return;
}
for (let i = 0; i < licenseReg.length; i++) {
if (licenseReg[i].reg.test(commentText)) {
return licenseReg[i].name;
}
}
}
const cStyleCommentReg = /\/\*[\S\s]*?\*\//;
const hashCommentReg = /^\s*#.*$/gm;
const mlCommentReg = /<\!\-\-[\S\s]*?\-\->/;
const commentReg = {
js: cStyleCommentReg,
css: cStyleCommentReg,
java: cStyleCommentReg,
sh: hashCommentReg,
html: mlCommentReg,
xml: mlCommentReg,
xsl: mlCommentReg
};
function extractComment(str, fileExt) {
const reg = commentReg[fileExt];
if (!fileExt || !reg || !str) {
return;
}
reg.lastIndex = 0;
if (fileExt === 'sh') {
let result = str.match(reg);
return result && result.join('\n');
}
else {
let result = reg.exec(str);
return result && result[0];
}
}
module.exports = Object.assign({
extractLicense,
hasPreamble,
addPreamble
}, preambleMap);
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* Find language definations.
*
* Usage:
*
* import ecLangPlugin from 'echarts/build/rollup-plugin-ec-lang';
* let rollupConfig = {
* plugins: [
* ecLangPlugin({lang: 'en'}),
* ...
* ]
* };
*/
const {resolve} = require('path');
const {readFileSync} = require('fs');
/**
* @param {Object} [opt]
* @param {string} [opt.lang=null] null/undefined/'' or 'en' or 'fi' or a file path.
*/
function getPlugin(opt) {
let lang = opt && opt.lang || '';
return {
load: function (absolutePath) {
if (/\/src\/lang\.js$/.test(absolutePath)) {
let langPath = getLangFileInfo(lang).absolutePath;
if (langPath) {
absolutePath = langPath;
}
}
return readFileSync(absolutePath, 'utf-8');
}
};
}
/**
* @param {string} lang null/undefined/'' or 'en' or 'fi' or a file path.
* @return {Object} {isOuter, absolutePath}
*/
let getLangFileInfo = getPlugin.getLangFileInfo = function (lang) {
let absolutePath;
let isOuter = false;
if (lang) {
if (/^[a-zA-Z]{2}$/.test(lang)) {
absolutePath = resolve(__dirname, '../', 'src/lang' + lang.toUpperCase() + '.js');
}
else {
isOuter = true;
// `lang` is an absolute path or a relative path based on process.cwd().
absolutePath = resolve(lang);
}
}
return {isOuter, absolutePath};
};
module.exports = getPlugin;
\ No newline at end of file
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* Remove the code of `if (__DEV__) { ... }`.
*
* Usage:
*
* import ecRemoveDevPlugin from 'echats/build/rollup-plugin-ec-remove-dev';
* let rollupConfig = {
* plugins: [
* ecRemoveDevPlugin(),
* ...
* ]
* };
*/
const babel = require('@babel/core');
const removeDEVPlugin = require('zrender/build/babel-plugin-transform-remove-dev');
/**
* @param {Object} [opt]
* @param {Object} [opt.sourcemap]
*/
module.exports = function ({sourcemap} = {}) {
return {
transform: function (sourceCode) {
let {code, map} = babel.transform(sourceCode, {
plugins: [removeDEVPlugin],
sourceMaps: sourcemap
});
return {code, map};
}
};
};
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("echarts")):"function"==typeof define&&define.amd?define(["exports","echarts"],t):t(e.bmap={},e.echarts)}(this,function(e,y){"use strict";function h(e,t){this._bmap=e,this.dimensions=["lng","lat"],this._mapOffset=[0,0],this._api=t,this._projection=new BMap.MercatorProjection}function o(a,r){return r=r||[0,0],y.util.map([0,1],function(e){var t=r[e],o=a[e]/2,n=[],i=[];return n[e]=t-o,i[e]=t+o,n[1-e]=i[1-e]=r[1-e],Math.abs(this.dataToPoint(n)[e]-this.dataToPoint(i)[e])},this)}var g;function v(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0}h.prototype.dimensions=["lng","lat"],h.prototype.setZoom=function(e){this._zoom=e},h.prototype.setCenter=function(e){this._center=this._projection.lngLatToPoint(new BMap.Point(e[0],e[1]))},h.prototype.setMapOffset=function(e){this._mapOffset=e},h.prototype.getBMap=function(){return this._bmap},h.prototype.dataToPoint=function(e){var t=new BMap.Point(e[0],e[1]),o=this._bmap.pointToOverlayPixel(t),n=this._mapOffset;return[o.x-n[0],o.y-n[1]]},h.prototype.pointToData=function(e){var t=this._mapOffset;return[(e=this._bmap.overlayPixelToPoint({x:e[0]+t[0],y:e[1]+t[1]})).lng,e.lat]},h.prototype.getViewRect=function(){var e=this._api;return new y.graphic.BoundingRect(0,0,e.getWidth(),e.getHeight())},h.prototype.getRoamTransform=function(){return y.matrix.create()},h.prototype.prepareCustoms=function(e){var t=this.getViewRect();return{coordSys:{type:"bmap",x:t.x,y:t.y,width:t.width,height:t.height},api:{coord:y.util.bind(this.dataToPoint,this),size:y.util.bind(o,this)}}},h.dimensions=h.prototype.dimensions,h.create=function(e,l){var f,u=l.getDom();e.eachComponent("bmap",function(e){var t=l.getZr().painter,o=t.getViewportRoot();if("undefined"==typeof BMap)throw new Error("BMap api is not loaded");if(g=g||function(){function e(e){this._root=e}return(e.prototype=new BMap.Overlay).initialize=function(e){return e.getPanes().labelPane.appendChild(this._root),this._root},e.prototype.draw=function(){},e}(),f)throw new Error("Only one bmap component can exist");if(!e.__bmap){var n=u.querySelector(".ec-extension-bmap");n&&(o.style.left="0px",o.style.top="0px",u.removeChild(n)),(n=document.createElement("div")).style.cssText="width:100%;height:100%",n.classList.add("ec-extension-bmap"),u.appendChild(n);var i=e.get("mapOptions")||{};delete i.mapType;var a=e.__bmap=new BMap.Map(n,i),r=new g(o);a.addOverlay(r),t.getViewportRootOffset=function(){return{offsetLeft:0,offsetTop:0}}}a=e.__bmap;var p=e.get("center"),s=e.get("zoom");if(p&&s){var m=a.getCenter(),d=a.getZoom();if(e.centerOrZoomChanged([m.lng,m.lat],d)){var c=new BMap.Point(p[0],p[1]);a.centerAndZoom(c,s)}}(f=new h(a,l)).setMapOffset(e.__mapOffset||[0,0]),f.setZoom(s),f.setCenter(p),e.coordinateSystem=f}),e.eachSeries(function(e){"bmap"===e.get("coordinateSystem")&&(e.coordinateSystem=f)})},y.extendComponentModel({type:"bmap",getBMap:function(){return this.__bmap},setCenterAndZoom:function(e,t){this.option.center=e,this.option.zoom=t},centerOrZoomChanged:function(e,t){var o=this.option;return!(function(e,t){return e&&t&&e[0]===t[0]&&e[1]===t[1]}(e,o.center)&&t===o.zoom)},defaultOption:{center:[104.114129,37.550339],zoom:5,mapStyle:{},mapStyleV2:{},mapOptions:{},roam:!1}}),y.extendComponentView({type:"bmap",render:function(i,e,a){function t(e,t){if(!r){var o=p.parentNode.parentNode.parentNode,n=[-parseInt(o.style.left,10)||0,-parseInt(o.style.top,10)||0];p.style.left=n[0]+"px",p.style.top=n[1]+"px",s.setMapOffset(n),i.__mapOffset=n,a.dispatchAction({type:"bmapRoam"})}}var r=!0,o=i.getBMap(),p=a.getZr().painter.getViewportRoot(),s=i.coordinateSystem;function n(){r||a.dispatchAction({type:"bmapRoam"})}o.removeEventListener("moving",this._oldMoveHandler),o.removeEventListener("moveend",this._oldMoveHandler),o.removeEventListener("zoomend",this._oldZoomEndHandler),o.addEventListener("moving",t),o.addEventListener("moveend",t),o.addEventListener("zoomend",n),this._oldMoveHandler=t,this._oldZoomEndHandler=n;var m=i.get("roam");m&&"scale"!==m?o.enableDragging():o.disableDragging(),m&&"move"!==m?(o.enableScrollWheelZoom(),o.enableDoubleClickZoom(),o.enablePinchToZoom()):(o.disableScrollWheelZoom(),o.disableDoubleClickZoom(),o.disablePinchToZoom());var d=i.__mapStyle,c=i.get("mapStyle")||{},l=JSON.stringify(c);JSON.stringify(d)!==l&&(v(u)||o.setMapStyle(y.util.clone(c)),i.__mapStyle=JSON.parse(l));var f=i.__mapStyle2,u=i.get("mapStyleV2")||{},h=JSON.stringify(u);JSON.stringify(f)!==h&&(v(u)||o.setMapStyleV2(y.util.clone(u)),i.__mapStyle2=JSON.parse(h)),r=!1}}),y.registerCoordinateSystem("bmap",h),y.registerAction({type:"bmapRoam",event:"bmapRoam",update:"updateLayout"},function(e,t){t.eachComponent("bmap",function(e){var t=e.getBMap(),o=t.getCenter();e.setCenterAndZoom([o.lng,o.lat],t.getZoom())})});e.version="1.0.0"});
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("echarts")):"function"==typeof define&&define.amd?define(["exports","echarts"],t):t(e.dataTool={},e.echarts)}(this,function(e,t){"use strict";var i=Array.prototype.map;function l(e,t,r){if(e&&t){if(e.map&&e.map===i)return e.map(t,r);for(var a=[],o=0,n=e.length;o<n;o++)a.push(t.call(r,e[o],o,e));return a}}function v(e,t){return e.getAttribute(t)}function d(e,t){for(var r=e.firstChild;r;){if(1===r.nodeType&&r.nodeName.toLowerCase()===t.toLowerCase())return r;r=r.nextSibling}return null}function g(e,t){for(var r=e.firstChild,a=[];r;)r.nodeName.toLowerCase()===t.toLowerCase()&&a.push(r),r=r.nextSibling;return a}var r=(Object.freeze||Object)({parse:function(e){var t;if(!(t="string"==typeof e?(new DOMParser).parseFromString(e,"text/xml"):e)||t.getElementsByTagName("parsererror").length)return null;var r=d(t,"gexf");if(!r)return null;for(var a=d(r,"graph"),o=function(e){return e?l(g(e,"attribute"),function(e){return{id:v(e,"id"),title:v(e,"title"),type:v(e,"type")}}):[]}(d(a,"attributes")),n={},i=0;i<o.length;i++)n[o[i].id]=o[i];return{nodes:function(e,p){return e?l(g(e,"node"),function(e){var t={id:v(e,"id"),name:v(e,"label"),itemStyle:{normal:{}}},r=d(e,"viz:size"),a=d(e,"viz:position"),o=d(e,"viz:color"),n=d(e,"attvalues");if(r&&(t.symbolSize=parseFloat(v(r,"value"))),a&&(t.x=parseFloat(v(a,"x")),t.y=parseFloat(v(a,"y"))),o&&(t.itemStyle.normal.color="rgb("+[0|v(o,"r"),0|v(o,"g"),0|v(o,"b")].join(",")+")"),n){var i=g(n,"attvalue");t.attributes={};for(var l=0;l<i.length;l++){var u=i[l],s=v(u,"for"),f=v(u,"value"),c=p[s];if(c){switch(c.type){case"integer":case"long":f=parseInt(f,10);break;case"float":case"double":f=parseFloat(f);break;case"boolean":f="true"===f.toLowerCase()}t.attributes[s]=f}}}return t}):[]}(d(a,"nodes"),n),links:function(e){return e?l(g(e,"edge"),function(e){var t={id:v(e,"id"),name:v(e,"label"),source:v(e,"source"),target:v(e,"target"),lineStyle:{normal:{}}},r=t.lineStyle.normal,a=d(e,"viz:thickness"),o=d(e,"viz:color");return a&&(r.width=parseFloat(a.getAttribute("value"))),o&&(r.color="rgb("+[0|v(o,"r"),0|v(o,"g"),0|v(o,"b")].join(",")+")"),t}):[]}(d(a,"edges"))}}});function w(e,t){var r=(e.length-1)*t+1,a=Math.floor(r),o=+e[a-1],n=r-a;return n?o+n*(e[a]-o):o}function a(e,t){for(var r,a=[],o=[],n=[],i=(t=t||[]).boundIQR,l="none"===i||0===i,u=0;u<e.length;u++){n.push(u+"");var s=((r=e[u].slice()).sort(function(e,t){return e-t}),r),f=w(s,.25),c=w(s,.5),p=w(s,.75),v=s[0],d=s[s.length-1],g=(null==i?1.5:i)*(p-f),h=l?v:Math.max(v,f-g),b=l?d:Math.min(d,p+g);a.push([h,f,c,p,b]);for(var m=0;m<s.length;m++){var y=s[m];if(y<h||b<y){var x=[u,y];"vertical"===t.layout&&x.reverse(),o.push(x)}}}return{boxData:a,outliers:o,axisData:n}}var o="1.0.0";t.dataTool&&(t.dataTool.version=o,t.dataTool.gexf=r,t.dataTool.prepareBoxplotData=a),e.version=o,e.gexf=r,e.prepareBoxplotData=a});
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
export * from './src/echarts';
export * from './src/export';
import './src/component/dataset';
// ----------------------------------------------
// All of the modules that are allowed to be
// imported are listed below.
//
// Users MUST NOT import other modules that are
// not included in this list.
// ----------------------------------------------
// ----------------
// Charts (series)
// ----------------
// All of the series types, for example:
// chart.setOption({
// series: [{
// type: 'line' // or 'bar', 'pie', ...
// }]
// });
import './src/chart/line';
import './src/chart/bar';
import './src/chart/pie';
import './src/chart/scatter';
import './src/chart/radar';
import './src/chart/map';
import './src/chart/tree';
import './src/chart/treemap';
import './src/chart/graph';
import './src/chart/gauge';
import './src/chart/funnel';
import './src/chart/parallel';
import './src/chart/sankey';
import './src/chart/boxplot';
import './src/chart/candlestick';
import './src/chart/effectScatter';
import './src/chart/lines';
import './src/chart/heatmap';
import './src/chart/pictorialBar';
import './src/chart/themeRiver';
import './src/chart/sunburst';
import './src/chart/custom';
// -------------------
// Coordinate systems
// -------------------
// All of the axis modules have been included in the
// coordinate system module below, do not need to
// make extra import.
// `cartesian` coordinate system. For some historical
// reasons, it is named as grid, for example:
// chart.setOption({
// grid: {...},
// xAxis: {...},
// yAxis: {...},
// series: [{...}]
// });
import './src/component/grid';
// `polar` coordinate system, for example:
// chart.setOption({
// polar: {...},
// radiusAxis: {...},
// angleAxis: {...},
// series: [{
// coordinateSystem: 'polar'
// }]
// });
import './src/component/polar';
// `geo` coordinate system, for example:
// chart.setOption({
// geo: {...},
// series: [{
// coordinateSystem: 'geo'
// }]
// });
import './src/component/geo';
// `singleAxis` coordinate system (notice, it is a coordinate system
// with only one axis, work for chart like theme river), for example:
// chart.setOption({
// singleAxis: {...}
// series: [{type: 'themeRiver', ...}]
// });
import './src/component/singleAxis';
// `parallel` coordinate system, only work for parallel series, for example:
// chart.setOption({
// parallel: {...},
// parallelAxis: [{...}, ...],
// series: [{
// type: 'parallel'
// }]
// });
import './src/component/parallel';
// `calendar` coordinate system. for example,
// chart.setOptionp({
// calendar: {...},
// series: [{
// coordinateSystem: 'calendar'
// }]
// );
import './src/component/calendar';
// ------------------
// Other components
// ------------------
// `graphic` component, for example:
// chart.setOption({
// graphic: {...}
// });
import './src/component/graphic';
// `toolbox` component, for example:
// chart.setOption({
// toolbox: {...}
// });
import './src/component/toolbox';
// `tooltip` component, for example:
// chart.setOption({
// tooltip: {...}
// });
import './src/component/tooltip';
// `axisPointer` component, for example:
// chart.setOption({
// tooltip: {axisPointer: {...}, ...}
// });
// Or
// chart.setOption({
// axisPointer: {...}
// });
import './src/component/axisPointer';
// `brush` component, for example:
// chart.setOption({
// brush: {...}
// });
// Or
// chart.setOption({
// tooltip: {feature: {brush: {...}}
// })
import './src/component/brush';
// `title` component, for example:
// chart.setOption({
// title: {...}
// });
import './src/component/title';
// `timeline` component, for example:
// chart.setOption({
// timeline: {...}
// });
import './src/component/timeline';
// `markPoint` component, for example:
// chart.setOption({
// series: [{markPoint: {...}}]
// });
import './src/component/markPoint';
// `markLine` component, for example:
// chart.setOption({
// series: [{markLine: {...}}]
// });
import './src/component/markLine';
// `markArea` component, for example:
// chart.setOption({
// series: [{markArea: {...}}]
// });
import './src/component/markArea';
// `legend` component scrollable, for example:
// chart.setOption({
// legend: {type: 'scroll'}
// });
import './src/component/legendScroll';
// `legend` component not scrollable. for example:
// chart.setOption({
// legend: {...}
// });
import './src/component/legend';
// `dataZoom` component including both `dataZoomInside` and `dataZoomSlider`.
import './src/component/dataZoom';
// `dataZoom` component providing drag, pinch, wheel behaviors
// inside coodinate system, for example:
// chart.setOption({
// dataZoom: {type: 'inside'}
// });
import './src/component/dataZoomInside';
// `dataZoom` component providing a slider bar, for example:
// chart.setOption({
// dataZoom: {type: 'slider'}
// });
import './src/component/dataZoomSlider';
// `dataZoom` component including both `visualMapContinuous` and `visualMapPiecewise`.
import './src/component/visualMap';
// `visualMap` component providing continuous bar, for example:
// chart.setOption({
// visualMap: {type: 'continuous'}
// });
import './src/component/visualMapContinuous';
// `visualMap` component providing pieces bar, for example:
// chart.setOption({
// visualMap: {type: 'piecewise'}
// });
import './src/component/visualMapPiecewise';
// -----------------
// Render engines
// -----------------
// Provide IE 6,7,8 compatibility.
import 'zrender/src/vml/vml';
// Render via SVG rather than canvas.
import 'zrender/src/svg/svg';
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
export * from './src/echarts';
export * from './src/export';
import './src/component/dataset';
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
export * from './src/echarts';
export * from './src/export';
import './src/component/dataset';
import './src/chart/line';
import './src/chart/bar';
import './src/chart/pie';
import './src/chart/scatter';
import './src/component/graphic';
import './src/component/tooltip';
import './src/component/axisPointer';
import './src/component/legendScroll';
import './src/component/grid';
import './src/component/title';
import './src/component/markPoint';
import './src/component/markLine';
import './src/component/markArea';
import './src/component/dataZoom';
import './src/component/toolbox';
import 'zrender/src/vml/vml';
import 'zrender/src/svg/svg';
\ No newline at end of file
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
export * from './src/echarts';
import './src/component/dataset';
import './src/chart/line';
import './src/chart/bar';
import './src/chart/pie';
import './src/component/gridSimple';
\ No newline at end of file
parserOptions:
# If using ES Module, ecmaVersion have to be set as `2015`.
ecmaVersion: 2015
sourceType: "module"
env:
browser: true
node: true
es6: false
globals:
jQuery: true
Promise: true
rules:
no-console:
- 2
-
allow:
- "warn"
- "error"
no-constant-condition: 0
comma-dangle: 2
no-debugger: 2
no-dupe-keys: 2
no-empty-character-class: 2
no-ex-assign: 2
no-extra-boolean-cast: 0
no-func-assign: 2
no-inner-declarations: 2
no-invalid-regexp: 2
no-negated-in-lhs: 2
no-obj-calls: 2
no-sparse-arrays: 2
no-unreachable: 2
use-isnan: 2
valid-typeof: 2
block-scoped-var: 0
curly:
- 2
- "all"
eqeqeq:
- 2
- "allow-null"
guard-for-in: 2
no-else-return: 0
no-labels:
- 2
-
allowLoop: true
no-eval: 2
no-extend-native: 2
no-extra-bind: 0
no-implied-eval: 2
no-iterator: 2
no-irregular-whitespace: 2
no-lone-blocks: 2
no-loop-func: 2
no-multi-str: 2
no-native-reassign: 2
no-new-wrappers: 2
no-octal: 2
no-octal-escape: 2
no-proto: 2
no-redeclare: 0
no-self-compare: 2
no-unneeded-ternary: 2
no-with: 2
radix: 2
wrap-iife:
- 2
- "any"
no-delete-var: 2
no-dupe-args: 2
no-duplicate-case: 2
no-label-var: 2
no-shadow-restricted-names: 2
no-undef: 2
no-undef-init: 2
no-unused-vars:
- 2
-
vars: "local"
args: "none"
no-use-before-define: 0
brace-style:
- 2
- "stroustrup"
- {}
comma-spacing:
- 2
-
before: false
after: true
comma-style:
- 2
- "last"
new-parens: 2
no-array-constructor: 2
no-multi-spaces:
- 2
-
ignoreEOLComments: true
exceptions:
Property: true
no-new-object: 2
no-spaced-func: 2
no-trailing-spaces: 2
no-extra-parens:
- 2
- "functions"
no-mixed-spaces-and-tabs: 2
one-var:
- 2
- "never"
operator-linebreak:
- 2
- "before"
-
overrides:
"=": "after"
quotes:
- 2
- "single"
semi:
- 2
- "always"
semi-spacing: 2
keyword-spacing: 2
key-spacing:
- 2
-
beforeColon: false
afterColon: true
space-before-function-paren:
- 2
-
anonymous: "always"
named: "never"
space-before-blocks:
- 2
- "always"
computed-property-spacing:
- 2
- "never"
space-in-parens:
- 2
- "never"
space-unary-ops: 2
spaced-comment: 0
max-nested-callbacks:
- 1
- 5
max-depth:
- 1
- 6
max-len:
- 2
- 120
- 4
-
ignoreUrls: true
ignoreComments: true
max-params:
- 1
- 15
space-infix-ops: 2
dot-notation:
- 2
-
allowKeywords: true
allowPattern: "^catch$"
arrow-spacing: 2
constructor-super: 2
no-confusing-arrow:
- 2
-
allowParens: true
no-class-assign: 2
no-const-assign: 2
no-dupe-class-members: 2
no-this-before-super: 0
no-var: 0
no-duplicate-imports: 2
prefer-rest-params: 0
unicode-bom: 2
max-statements-per-line: 2
no-useless-constructor: 0
\ No newline at end of file
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/* global BMap */
import {
util as zrUtil,
graphic,
matrix
} from 'echarts';
function BMapCoordSys(bmap, api) {
this._bmap = bmap;
this.dimensions = ['lng', 'lat'];
this._mapOffset = [0, 0];
this._api = api;
this._projection = new BMap.MercatorProjection();
}
BMapCoordSys.prototype.dimensions = ['lng', 'lat'];
BMapCoordSys.prototype.setZoom = function (zoom) {
this._zoom = zoom;
};
BMapCoordSys.prototype.setCenter = function (center) {
this._center = this._projection.lngLatToPoint(new BMap.Point(center[0], center[1]));
};
BMapCoordSys.prototype.setMapOffset = function (mapOffset) {
this._mapOffset = mapOffset;
};
BMapCoordSys.prototype.getBMap = function () {
return this._bmap;
};
BMapCoordSys.prototype.dataToPoint = function (data) {
var point = new BMap.Point(data[0], data[1]);
// TODO mercator projection is toooooooo slow
// var mercatorPoint = this._projection.lngLatToPoint(point);
// var width = this._api.getZr().getWidth();
// var height = this._api.getZr().getHeight();
// var divider = Math.pow(2, 18 - 10);
// return [
// Math.round((mercatorPoint.x - this._center.x) / divider + width / 2),
// Math.round((this._center.y - mercatorPoint.y) / divider + height / 2)
// ];
var px = this._bmap.pointToOverlayPixel(point);
var mapOffset = this._mapOffset;
return [px.x - mapOffset[0], px.y - mapOffset[1]];
};
BMapCoordSys.prototype.pointToData = function (pt) {
var mapOffset = this._mapOffset;
var pt = this._bmap.overlayPixelToPoint({
x: pt[0] + mapOffset[0],
y: pt[1] + mapOffset[1]
});
return [pt.lng, pt.lat];
};
BMapCoordSys.prototype.getViewRect = function () {
var api = this._api;
return new graphic.BoundingRect(0, 0, api.getWidth(), api.getHeight());
};
BMapCoordSys.prototype.getRoamTransform = function () {
return matrix.create();
};
BMapCoordSys.prototype.prepareCustoms = function (data) {
var rect = this.getViewRect();
return {
coordSys: {
// The name exposed to user is always 'cartesian2d' but not 'grid'.
type: 'bmap',
x: rect.x,
y: rect.y,
width: rect.width,
height: rect.height
},
api: {
coord: zrUtil.bind(this.dataToPoint, this),
size: zrUtil.bind(dataToCoordSize, this)
}
};
};
function dataToCoordSize(dataSize, dataItem) {
dataItem = dataItem || [0, 0];
return zrUtil.map([0, 1], function (dimIdx) {
var val = dataItem[dimIdx];
var halfSize = dataSize[dimIdx] / 2;
var p1 = [];
var p2 = [];
p1[dimIdx] = val - halfSize;
p2[dimIdx] = val + halfSize;
p1[1 - dimIdx] = p2[1 - dimIdx] = dataItem[1 - dimIdx];
return Math.abs(this.dataToPoint(p1)[dimIdx] - this.dataToPoint(p2)[dimIdx]);
}, this);
}
var Overlay;
// For deciding which dimensions to use when creating list data
BMapCoordSys.dimensions = BMapCoordSys.prototype.dimensions;
function createOverlayCtor() {
function Overlay(root) {
this._root = root;
}
Overlay.prototype = new BMap.Overlay();
/**
* 初始化
*
* @param {BMap.Map} map
* @override
*/
Overlay.prototype.initialize = function (map) {
map.getPanes().labelPane.appendChild(this._root);
return this._root;
};
/**
* @override
*/
Overlay.prototype.draw = function () {};
return Overlay;
}
BMapCoordSys.create = function (ecModel, api) {
var bmapCoordSys;
var root = api.getDom();
// TODO Dispose
ecModel.eachComponent('bmap', function (bmapModel) {
var painter = api.getZr().painter;
var viewportRoot = painter.getViewportRoot();
if (typeof BMap === 'undefined') {
throw new Error('BMap api is not loaded');
}
Overlay = Overlay || createOverlayCtor();
if (bmapCoordSys) {
throw new Error('Only one bmap component can exist');
}
if (!bmapModel.__bmap) {
// Not support IE8
var bmapRoot = root.querySelector('.ec-extension-bmap');
if (bmapRoot) {
// Reset viewport left and top, which will be changed
// in moving handler in BMapView
viewportRoot.style.left = '0px';
viewportRoot.style.top = '0px';
root.removeChild(bmapRoot);
}
bmapRoot = document.createElement('div');
bmapRoot.style.cssText = 'width:100%;height:100%';
// Not support IE8
bmapRoot.classList.add('ec-extension-bmap');
root.appendChild(bmapRoot);
// initialize bmap
var mapOptions = bmapModel.get('mapOptions') || {};
// Not support `mapType`, use `bmap.setMapType(MapType)` instead.
delete mapOptions.mapType;
var bmap = bmapModel.__bmap = new BMap.Map(bmapRoot, mapOptions);
var overlay = new Overlay(viewportRoot);
bmap.addOverlay(overlay);
// Override
painter.getViewportRootOffset = function () {
return {offsetLeft: 0, offsetTop: 0};
};
}
var bmap = bmapModel.__bmap;
// Set bmap options
// centerAndZoom before layout and render
var center = bmapModel.get('center');
var zoom = bmapModel.get('zoom');
if (center && zoom) {
var bmapCenter = bmap.getCenter();
var bmapZoom = bmap.getZoom();
var centerOrZoomChanged = bmapModel.centerOrZoomChanged([bmapCenter.lng, bmapCenter.lat], bmapZoom);
if (centerOrZoomChanged) {
var pt = new BMap.Point(center[0], center[1]);
bmap.centerAndZoom(pt, zoom);
}
}
bmapCoordSys = new BMapCoordSys(bmap, api);
bmapCoordSys.setMapOffset(bmapModel.__mapOffset || [0, 0]);
bmapCoordSys.setZoom(zoom);
bmapCoordSys.setCenter(center);
bmapModel.coordinateSystem = bmapCoordSys;
});
ecModel.eachSeries(function (seriesModel) {
if (seriesModel.get('coordinateSystem') === 'bmap') {
seriesModel.coordinateSystem = bmapCoordSys;
}
});
};
export default BMapCoordSys;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import * as echarts from 'echarts';
function v2Equal(a, b) {
return a && b && a[0] === b[0] && a[1] === b[1];
}
export default echarts.extendComponentModel({
type: 'bmap',
getBMap: function () {
// __bmap is injected when creating BMapCoordSys
return this.__bmap;
},
setCenterAndZoom: function (center, zoom) {
this.option.center = center;
this.option.zoom = zoom;
},
centerOrZoomChanged: function (center, zoom) {
var option = this.option;
return !(v2Equal(center, option.center) && zoom === option.zoom);
},
defaultOption: {
center: [104.114129, 37.550339],
zoom: 5,
// 2.0 http://lbsyun.baidu.com/custom/index.htm
mapStyle: {},
// 3.0 http://lbsyun.baidu.com/index.php?title=open/custom
mapStyleV2: {},
// See https://lbsyun.baidu.com/cms/jsapi/reference/jsapi_reference.html#a0b1
mapOptions: {},
roam: false
}
});
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.