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.

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