echarts-rails 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/vendor/assets/javascripts/echarts.common.js +40855 -0
- data/vendor/assets/javascripts/echarts.js +62926 -16
- data/vendor/assets/javascripts/echarts.simple.js +29012 -0
- data/vendor/assets/javascripts/extension/bmap.js +369 -0
- data/vendor/assets/javascripts/extension/dataTool.js +405 -0
- metadata +7 -5
- data/vendor/assets/javascripts/echarts-common.js +0 -27
- data/vendor/assets/javascripts/echarts-simple.js +0 -24
@@ -0,0 +1,369 @@
|
|
1
|
+
(function webpackUniversalModuleDefinition(root, factory) {
|
2
|
+
if(typeof exports === 'object' && typeof module === 'object')
|
3
|
+
module.exports = factory(require("echarts"));
|
4
|
+
else if(typeof define === 'function' && define.amd)
|
5
|
+
define(["echarts"], factory);
|
6
|
+
else if(typeof exports === 'object')
|
7
|
+
exports["bmap"] = factory(require("echarts"));
|
8
|
+
else
|
9
|
+
root["echarts"] = root["echarts"] || {}, root["echarts"]["bmap"] = factory(root["echarts"]);
|
10
|
+
})(this, function(__WEBPACK_EXTERNAL_MODULE_1__) {
|
11
|
+
return /******/ (function(modules) { // webpackBootstrap
|
12
|
+
/******/ // The module cache
|
13
|
+
/******/ var installedModules = {};
|
14
|
+
|
15
|
+
/******/ // The require function
|
16
|
+
/******/ function __webpack_require__(moduleId) {
|
17
|
+
|
18
|
+
/******/ // Check if module is in cache
|
19
|
+
/******/ if(installedModules[moduleId])
|
20
|
+
/******/ return installedModules[moduleId].exports;
|
21
|
+
|
22
|
+
/******/ // Create a new module (and put it into the cache)
|
23
|
+
/******/ var module = installedModules[moduleId] = {
|
24
|
+
/******/ exports: {},
|
25
|
+
/******/ id: moduleId,
|
26
|
+
/******/ loaded: false
|
27
|
+
/******/ };
|
28
|
+
|
29
|
+
/******/ // Execute the module function
|
30
|
+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
31
|
+
|
32
|
+
/******/ // Flag the module as loaded
|
33
|
+
/******/ module.loaded = true;
|
34
|
+
|
35
|
+
/******/ // Return the exports of the module
|
36
|
+
/******/ return module.exports;
|
37
|
+
/******/ }
|
38
|
+
|
39
|
+
|
40
|
+
/******/ // expose the modules object (__webpack_modules__)
|
41
|
+
/******/ __webpack_require__.m = modules;
|
42
|
+
|
43
|
+
/******/ // expose the module cache
|
44
|
+
/******/ __webpack_require__.c = installedModules;
|
45
|
+
|
46
|
+
/******/ // __webpack_public_path__
|
47
|
+
/******/ __webpack_require__.p = "";
|
48
|
+
|
49
|
+
/******/ // Load entry module and return exports
|
50
|
+
/******/ return __webpack_require__(0);
|
51
|
+
/******/ })
|
52
|
+
/************************************************************************/
|
53
|
+
/******/ ([
|
54
|
+
/* 0 */
|
55
|
+
/***/ function(module, exports, __webpack_require__) {
|
56
|
+
|
57
|
+
var __WEBPACK_AMD_DEFINE_RESULT__;/**
|
58
|
+
* BMap component extension
|
59
|
+
*/
|
60
|
+
!(__WEBPACK_AMD_DEFINE_RESULT__ = function (require) {
|
61
|
+
|
62
|
+
__webpack_require__(1).registerCoordinateSystem(
|
63
|
+
'bmap', __webpack_require__(2)
|
64
|
+
);
|
65
|
+
__webpack_require__(3);
|
66
|
+
__webpack_require__(4);
|
67
|
+
|
68
|
+
// Action
|
69
|
+
__webpack_require__(1).registerAction({
|
70
|
+
type: 'bmapRoam',
|
71
|
+
event: 'bmapRoam',
|
72
|
+
update: 'updateLayout'
|
73
|
+
}, function (payload, ecModel) {
|
74
|
+
ecModel.eachComponent('bmap', function (bMapModel) {
|
75
|
+
var bmap = bMapModel.getBMap();
|
76
|
+
var center = bmap.getCenter();
|
77
|
+
bMapModel.setCenterAndZoom([center.lng, center.lat], bmap.getZoom());
|
78
|
+
});
|
79
|
+
});
|
80
|
+
|
81
|
+
return {
|
82
|
+
version: '1.0.0'
|
83
|
+
};
|
84
|
+
}.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
|
85
|
+
|
86
|
+
/***/ },
|
87
|
+
/* 1 */
|
88
|
+
/***/ function(module, exports) {
|
89
|
+
|
90
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE_1__;
|
91
|
+
|
92
|
+
/***/ },
|
93
|
+
/* 2 */
|
94
|
+
/***/ function(module, exports, __webpack_require__) {
|
95
|
+
|
96
|
+
var __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_RESULT__ = function (require) {
|
97
|
+
|
98
|
+
var echarts = __webpack_require__(1);
|
99
|
+
|
100
|
+
function BMapCoordSys(bmap, api) {
|
101
|
+
this._bmap = bmap;
|
102
|
+
this.dimensions = ['lng', 'lat'];
|
103
|
+
this._mapOffset = [0, 0];
|
104
|
+
|
105
|
+
this._api = api;
|
106
|
+
}
|
107
|
+
|
108
|
+
BMapCoordSys.prototype.dimensions = ['lng', 'lat'];
|
109
|
+
|
110
|
+
BMapCoordSys.prototype.setMapOffset = function (mapOffset) {
|
111
|
+
this._mapOffset = mapOffset;
|
112
|
+
};
|
113
|
+
|
114
|
+
BMapCoordSys.prototype.getBMap = function () {
|
115
|
+
return this._bmap;
|
116
|
+
};
|
117
|
+
|
118
|
+
BMapCoordSys.prototype.dataToPoint = function (data) {
|
119
|
+
var point = new BMap.Point(data[0], data[1]);
|
120
|
+
// TODO pointToOverlayPixel is toooooooo slow, cache the transform
|
121
|
+
var px = this._bmap.pointToOverlayPixel(point);
|
122
|
+
var mapOffset = this._mapOffset;
|
123
|
+
return [px.x - mapOffset[0], px.y - mapOffset[1]];
|
124
|
+
};
|
125
|
+
|
126
|
+
BMapCoordSys.prototype.pointToData = function (pt) {
|
127
|
+
var mapOffset = this._mapOffset;
|
128
|
+
var pt = this._bmap.overlayPixelToPoint({
|
129
|
+
x: pt[0] + mapOffset[0],
|
130
|
+
y: pt[1] + mapOffset[1]
|
131
|
+
});
|
132
|
+
return [pt.lng, pt.lat];
|
133
|
+
};
|
134
|
+
|
135
|
+
BMapCoordSys.prototype.getViewRect = function () {
|
136
|
+
var api = this._api;
|
137
|
+
return new echarts.graphic.BoundingRect(0, 0, api.getWidth(), api.getHeight());
|
138
|
+
};
|
139
|
+
|
140
|
+
BMapCoordSys.prototype.getRoamTransform = function () {
|
141
|
+
return echarts.matrix.create();
|
142
|
+
};
|
143
|
+
|
144
|
+
var Overlay;
|
145
|
+
|
146
|
+
// For deciding which dimensions to use when creating list data
|
147
|
+
BMapCoordSys.dimensions = BMapCoordSys.prototype.dimensions;
|
148
|
+
|
149
|
+
function createOverlayCtor() {
|
150
|
+
function Overlay(root) {
|
151
|
+
this._root = root;
|
152
|
+
}
|
153
|
+
|
154
|
+
Overlay.prototype = new BMap.Overlay();
|
155
|
+
/**
|
156
|
+
* 初始化
|
157
|
+
*
|
158
|
+
* @param {BMap.Map} map
|
159
|
+
* @override
|
160
|
+
*/
|
161
|
+
Overlay.prototype.initialize = function (map) {
|
162
|
+
map.getPanes().labelPane.appendChild(this._root);
|
163
|
+
return this._root;
|
164
|
+
};
|
165
|
+
/**
|
166
|
+
* @override
|
167
|
+
*/
|
168
|
+
Overlay.prototype.draw = function () {};
|
169
|
+
|
170
|
+
return Overlay;
|
171
|
+
}
|
172
|
+
|
173
|
+
BMapCoordSys.create = function (ecModel, api) {
|
174
|
+
var bmapCoordSys;
|
175
|
+
var root = api.getDom();
|
176
|
+
|
177
|
+
// TODO Dispose
|
178
|
+
ecModel.eachComponent('bmap', function (bmapModel) {
|
179
|
+
var viewportRoot = api.getZr().painter.getViewportRoot();
|
180
|
+
if (typeof BMap === 'undefined') {
|
181
|
+
throw new Error('BMap api is not loaded');
|
182
|
+
}
|
183
|
+
Overlay = Overlay || createOverlayCtor();
|
184
|
+
if (bmapCoordSys) {
|
185
|
+
throw new Error('Only one bmap component can exist');
|
186
|
+
}
|
187
|
+
if (!bmapModel.__bmap) {
|
188
|
+
// Not support IE8
|
189
|
+
var bmapRoot = root.querySelector('.ec-extension-bmap');
|
190
|
+
if (bmapRoot) {
|
191
|
+
// Reset viewport left and top, which will be changed
|
192
|
+
// in moving handler in BMapView
|
193
|
+
viewportRoot.style.left = '0px';
|
194
|
+
viewportRoot.style.top = '0px';
|
195
|
+
root.removeChild(bmapRoot);
|
196
|
+
}
|
197
|
+
bmapRoot = document.createElement('div');
|
198
|
+
bmapRoot.style.cssText = 'width:100%;height:100%';
|
199
|
+
// Not support IE8
|
200
|
+
bmapRoot.classList.add('ec-extension-bmap');
|
201
|
+
root.appendChild(bmapRoot);
|
202
|
+
var bmap = bmapModel.__bmap = new BMap.Map(bmapRoot);
|
203
|
+
|
204
|
+
var overlay = new Overlay(viewportRoot);
|
205
|
+
bmap.addOverlay(overlay);
|
206
|
+
}
|
207
|
+
var bmap = bmapModel.__bmap;
|
208
|
+
|
209
|
+
// Set bmap options
|
210
|
+
// centerAndZoom before layout and render
|
211
|
+
var center = bmapModel.get('center');
|
212
|
+
var zoom = bmapModel.get('zoom');
|
213
|
+
if (center && zoom) {
|
214
|
+
var pt = new BMap.Point(center[0], center[1]);
|
215
|
+
bmap.centerAndZoom(pt, zoom);
|
216
|
+
}
|
217
|
+
|
218
|
+
bmapCoordSys = new BMapCoordSys(bmap, api);
|
219
|
+
bmapCoordSys.setMapOffset(bmapModel.__mapOffset || [0, 0]);
|
220
|
+
bmapModel.coordinateSystem = bmapCoordSys;
|
221
|
+
});
|
222
|
+
|
223
|
+
ecModel.eachSeries(function (seriesModel) {
|
224
|
+
if (seriesModel.get('coordinateSystem') === 'bmap') {
|
225
|
+
seriesModel.coordinateSystem = bmapCoordSys;
|
226
|
+
}
|
227
|
+
});
|
228
|
+
};
|
229
|
+
|
230
|
+
return BMapCoordSys;
|
231
|
+
}.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
|
232
|
+
|
233
|
+
/***/ },
|
234
|
+
/* 3 */
|
235
|
+
/***/ function(module, exports, __webpack_require__) {
|
236
|
+
|
237
|
+
var __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_RESULT__ = function (require) {
|
238
|
+
|
239
|
+
function v2Equal(a, b) {
|
240
|
+
return a && b && a[0] === b[0] && a[1] === b[1];
|
241
|
+
}
|
242
|
+
|
243
|
+
return __webpack_require__(1).extendComponentModel({
|
244
|
+
type: 'bmap',
|
245
|
+
|
246
|
+
getBMap: function () {
|
247
|
+
// __bmap is injected when creating BMapCoordSys
|
248
|
+
return this.__bmap;
|
249
|
+
},
|
250
|
+
|
251
|
+
setCenterAndZoom: function (center, zoom) {
|
252
|
+
this.option.center = center;
|
253
|
+
this.option.zoom = zoom;
|
254
|
+
},
|
255
|
+
|
256
|
+
centerOrZoomChanged: function (center, zoom) {
|
257
|
+
var option = this.option;
|
258
|
+
return !(v2Equal(center, option.center) && zoom === option.zoom);
|
259
|
+
},
|
260
|
+
|
261
|
+
defaultOption: {
|
262
|
+
|
263
|
+
center: [104.114129, 37.550339],
|
264
|
+
|
265
|
+
zoom: 5,
|
266
|
+
|
267
|
+
mapStyle: {},
|
268
|
+
|
269
|
+
roam: false
|
270
|
+
}
|
271
|
+
});
|
272
|
+
}.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
|
273
|
+
|
274
|
+
/***/ },
|
275
|
+
/* 4 */
|
276
|
+
/***/ function(module, exports, __webpack_require__) {
|
277
|
+
|
278
|
+
var __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_RESULT__ = function (require) {
|
279
|
+
|
280
|
+
return __webpack_require__(1).extendComponentView({
|
281
|
+
type: 'bmap',
|
282
|
+
|
283
|
+
render: function (bMapModel, ecModel, api) {
|
284
|
+
var rendering = true;
|
285
|
+
|
286
|
+
var bmap = bMapModel.getBMap();
|
287
|
+
var viewportRoot = api.getZr().painter.getViewportRoot();
|
288
|
+
var coordSys = bMapModel.coordinateSystem;
|
289
|
+
var moveHandler = function (type, target) {
|
290
|
+
if (rendering) {
|
291
|
+
return;
|
292
|
+
}
|
293
|
+
var offsetEl = viewportRoot.parentNode.parentNode.parentNode;
|
294
|
+
var mapOffset = [
|
295
|
+
-parseInt(offsetEl.style.left, 10) || 0,
|
296
|
+
-parseInt(offsetEl.style.top, 10) || 0
|
297
|
+
];
|
298
|
+
viewportRoot.style.left = mapOffset[0] + 'px';
|
299
|
+
viewportRoot.style.top = mapOffset[1] + 'px';
|
300
|
+
|
301
|
+
coordSys.setMapOffset(mapOffset);
|
302
|
+
bMapModel.__mapOffset = mapOffset;
|
303
|
+
|
304
|
+
api.dispatchAction({
|
305
|
+
type: 'bmapRoam'
|
306
|
+
});
|
307
|
+
};
|
308
|
+
|
309
|
+
function zoomEndHandler() {
|
310
|
+
if (rendering) {
|
311
|
+
return;
|
312
|
+
}
|
313
|
+
api.dispatchAction({
|
314
|
+
type: 'bmapRoam'
|
315
|
+
});
|
316
|
+
}
|
317
|
+
|
318
|
+
bmap.removeEventListener('moving', this._oldMoveHandler);
|
319
|
+
// FIXME
|
320
|
+
// Moveend may be triggered by centerAndZoom method when creating coordSys next time
|
321
|
+
// bmap.removeEventListener('moveend', this._oldMoveHandler);
|
322
|
+
bmap.removeEventListener('zoomend', this._oldZoomEndHandler);
|
323
|
+
bmap.addEventListener('moving', moveHandler);
|
324
|
+
// bmap.addEventListener('moveend', moveHandler);
|
325
|
+
bmap.addEventListener('zoomend', zoomEndHandler);
|
326
|
+
|
327
|
+
this._oldMoveHandler = moveHandler;
|
328
|
+
this._oldZoomEndHandler = zoomEndHandler;
|
329
|
+
|
330
|
+
var roam = bMapModel.get('roam');
|
331
|
+
if (roam && roam !== 'scale') {
|
332
|
+
bmap.enableDragging();
|
333
|
+
}
|
334
|
+
else {
|
335
|
+
bmap.disableDragging();
|
336
|
+
}
|
337
|
+
if (roam && roam !== 'move') {
|
338
|
+
bmap.enableScrollWheelZoom();
|
339
|
+
bmap.enableDoubleClickZoom();
|
340
|
+
bmap.enablePinchToZoom();
|
341
|
+
}
|
342
|
+
else {
|
343
|
+
bmap.disableScrollWheelZoom();
|
344
|
+
bmap.disableDoubleClickZoom();
|
345
|
+
bmap.disablePinchToZoom();
|
346
|
+
}
|
347
|
+
|
348
|
+
var originalStyle = bMapModel.__mapStyle;
|
349
|
+
|
350
|
+
var newMapStyle = bMapModel.get('mapStyle') || {};
|
351
|
+
// FIXME, Not use JSON methods
|
352
|
+
var mapStyleStr = JSON.stringify(newMapStyle);
|
353
|
+
if (JSON.stringify(originalStyle) !== mapStyleStr) {
|
354
|
+
// FIXME May have blank tile when dragging if setMapStyle
|
355
|
+
if (Object.keys(newMapStyle).length) {
|
356
|
+
bmap.setMapStyle(newMapStyle);
|
357
|
+
}
|
358
|
+
bMapModel.__mapStyle = JSON.parse(mapStyleStr);
|
359
|
+
}
|
360
|
+
|
361
|
+
rendering = false;
|
362
|
+
}
|
363
|
+
});
|
364
|
+
}.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
|
365
|
+
|
366
|
+
/***/ }
|
367
|
+
/******/ ])
|
368
|
+
});
|
369
|
+
;
|
@@ -0,0 +1,405 @@
|
|
1
|
+
(function webpackUniversalModuleDefinition(root, factory) {
|
2
|
+
if(typeof exports === 'object' && typeof module === 'object')
|
3
|
+
module.exports = factory(require("echarts"));
|
4
|
+
else if(typeof define === 'function' && define.amd)
|
5
|
+
define(["echarts"], factory);
|
6
|
+
else if(typeof exports === 'object')
|
7
|
+
exports["dataTool"] = factory(require("echarts"));
|
8
|
+
else
|
9
|
+
root["echarts"] = root["echarts"] || {}, root["echarts"]["dataTool"] = factory(root["echarts"]);
|
10
|
+
})(this, function(__WEBPACK_EXTERNAL_MODULE_1__) {
|
11
|
+
return /******/ (function(modules) { // webpackBootstrap
|
12
|
+
/******/ // The module cache
|
13
|
+
/******/ var installedModules = {};
|
14
|
+
|
15
|
+
/******/ // The require function
|
16
|
+
/******/ function __webpack_require__(moduleId) {
|
17
|
+
|
18
|
+
/******/ // Check if module is in cache
|
19
|
+
/******/ if(installedModules[moduleId])
|
20
|
+
/******/ return installedModules[moduleId].exports;
|
21
|
+
|
22
|
+
/******/ // Create a new module (and put it into the cache)
|
23
|
+
/******/ var module = installedModules[moduleId] = {
|
24
|
+
/******/ exports: {},
|
25
|
+
/******/ id: moduleId,
|
26
|
+
/******/ loaded: false
|
27
|
+
/******/ };
|
28
|
+
|
29
|
+
/******/ // Execute the module function
|
30
|
+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
31
|
+
|
32
|
+
/******/ // Flag the module as loaded
|
33
|
+
/******/ module.loaded = true;
|
34
|
+
|
35
|
+
/******/ // Return the exports of the module
|
36
|
+
/******/ return module.exports;
|
37
|
+
/******/ }
|
38
|
+
|
39
|
+
|
40
|
+
/******/ // expose the modules object (__webpack_modules__)
|
41
|
+
/******/ __webpack_require__.m = modules;
|
42
|
+
|
43
|
+
/******/ // expose the module cache
|
44
|
+
/******/ __webpack_require__.c = installedModules;
|
45
|
+
|
46
|
+
/******/ // __webpack_public_path__
|
47
|
+
/******/ __webpack_require__.p = "";
|
48
|
+
|
49
|
+
/******/ // Load entry module and return exports
|
50
|
+
/******/ return __webpack_require__(0);
|
51
|
+
/******/ })
|
52
|
+
/************************************************************************/
|
53
|
+
/******/ ([
|
54
|
+
/* 0 */
|
55
|
+
/***/ function(module, exports, __webpack_require__) {
|
56
|
+
|
57
|
+
var __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_RESULT__ = function (require) {
|
58
|
+
var echarts = __webpack_require__(1);
|
59
|
+
echarts.dataTool = {
|
60
|
+
version: '1.0.0',
|
61
|
+
gexf: __webpack_require__(5),
|
62
|
+
prepareBoxplotData: __webpack_require__(6)
|
63
|
+
};
|
64
|
+
return echarts.dataTool;
|
65
|
+
}.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
|
66
|
+
|
67
|
+
/***/ },
|
68
|
+
/* 1 */
|
69
|
+
/***/ function(module, exports) {
|
70
|
+
|
71
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE_1__;
|
72
|
+
|
73
|
+
/***/ },
|
74
|
+
/* 2 */,
|
75
|
+
/* 3 */,
|
76
|
+
/* 4 */,
|
77
|
+
/* 5 */
|
78
|
+
/***/ function(module, exports, __webpack_require__) {
|
79
|
+
|
80
|
+
var __WEBPACK_AMD_DEFINE_RESULT__;// GEXF File Parser
|
81
|
+
// http://gexf.net/1.2draft/gexf-12draft-primer.pdf
|
82
|
+
!(__WEBPACK_AMD_DEFINE_RESULT__ = function (require) {
|
83
|
+
|
84
|
+
'use strict';
|
85
|
+
var zrUtil = __webpack_require__(1).util;
|
86
|
+
|
87
|
+
function parse(xml) {
|
88
|
+
var doc;
|
89
|
+
if (typeof xml === 'string') {
|
90
|
+
var parser = new DOMParser();
|
91
|
+
doc = parser.parseFromString(xml, 'text/xml');
|
92
|
+
}
|
93
|
+
else {
|
94
|
+
doc = xml;
|
95
|
+
}
|
96
|
+
if (!doc || doc.getElementsByTagName('parsererror').length) {
|
97
|
+
return null;
|
98
|
+
}
|
99
|
+
|
100
|
+
var gexfRoot = getChildByTagName(doc, 'gexf');
|
101
|
+
|
102
|
+
if (!gexfRoot) {
|
103
|
+
return null;
|
104
|
+
}
|
105
|
+
|
106
|
+
var graphRoot = getChildByTagName(gexfRoot, 'graph');
|
107
|
+
|
108
|
+
var attributes = parseAttributes(getChildByTagName(graphRoot, 'attributes'));
|
109
|
+
var attributesMap = {};
|
110
|
+
for (var i = 0; i < attributes.length; i++) {
|
111
|
+
attributesMap[attributes[i].id] = attributes[i];
|
112
|
+
}
|
113
|
+
|
114
|
+
return {
|
115
|
+
nodes: parseNodes(getChildByTagName(graphRoot, 'nodes'), attributesMap),
|
116
|
+
links: parseEdges(getChildByTagName(graphRoot, 'edges'))
|
117
|
+
};
|
118
|
+
}
|
119
|
+
|
120
|
+
function parseAttributes(parent) {
|
121
|
+
return parent ? zrUtil.map(getChildrenByTagName(parent, 'attribute'), function (attribDom) {
|
122
|
+
return {
|
123
|
+
id: getAttr(attribDom, 'id'),
|
124
|
+
title: getAttr(attribDom, 'title'),
|
125
|
+
type: getAttr(attribDom, 'type')
|
126
|
+
};
|
127
|
+
}) : [];
|
128
|
+
}
|
129
|
+
|
130
|
+
function parseNodes(parent, attributesMap) {
|
131
|
+
return parent ? zrUtil.map(getChildrenByTagName(parent, 'node'), function (nodeDom) {
|
132
|
+
|
133
|
+
var id = getAttr(nodeDom, 'id');
|
134
|
+
var label = getAttr(nodeDom, 'label');
|
135
|
+
|
136
|
+
var node = {
|
137
|
+
id: id,
|
138
|
+
name: label,
|
139
|
+
itemStyle: {
|
140
|
+
normal: {}
|
141
|
+
}
|
142
|
+
};
|
143
|
+
|
144
|
+
var vizSizeDom = getChildByTagName(nodeDom, 'viz:size');
|
145
|
+
var vizPosDom = getChildByTagName(nodeDom, 'viz:position');
|
146
|
+
var vizColorDom = getChildByTagName(nodeDom, 'viz:color');
|
147
|
+
// var vizShapeDom = getChildByTagName(nodeDom, 'viz:shape');
|
148
|
+
|
149
|
+
var attvaluesDom = getChildByTagName(nodeDom, 'attvalues');
|
150
|
+
|
151
|
+
if (vizSizeDom) {
|
152
|
+
node.symbolSize = parseFloat(getAttr(vizSizeDom, 'value'));
|
153
|
+
}
|
154
|
+
if (vizPosDom) {
|
155
|
+
node.x = parseFloat(getAttr(vizPosDom, 'x'));
|
156
|
+
node.y = parseFloat(getAttr(vizPosDom, 'y'));
|
157
|
+
// z
|
158
|
+
}
|
159
|
+
if (vizColorDom) {
|
160
|
+
node.itemStyle.normal.color = 'rgb(' +[
|
161
|
+
getAttr(vizColorDom, 'r') | 0,
|
162
|
+
getAttr(vizColorDom, 'g') | 0,
|
163
|
+
getAttr(vizColorDom, 'b') | 0
|
164
|
+
].join(',') + ')';
|
165
|
+
}
|
166
|
+
// if (vizShapeDom) {
|
167
|
+
// node.shape = getAttr(vizShapeDom, 'shape');
|
168
|
+
// }
|
169
|
+
if (attvaluesDom) {
|
170
|
+
var attvalueDomList = getChildrenByTagName(attvaluesDom, 'attvalue');
|
171
|
+
|
172
|
+
node.attributes = {};
|
173
|
+
|
174
|
+
for (var j = 0; j < attvalueDomList.length; j++) {
|
175
|
+
var attvalueDom = attvalueDomList[j];
|
176
|
+
var attId = getAttr(attvalueDom, 'for');
|
177
|
+
var attValue = getAttr(attvalueDom, 'value');
|
178
|
+
var attribute = attributesMap[attId];
|
179
|
+
|
180
|
+
if (attribute) {
|
181
|
+
switch (attribute.type) {
|
182
|
+
case 'integer':
|
183
|
+
case 'long':
|
184
|
+
attValue = parseInt(attValue, 10);
|
185
|
+
break;
|
186
|
+
case 'float':
|
187
|
+
case 'double':
|
188
|
+
attValue = parseFloat(attValue);
|
189
|
+
break;
|
190
|
+
case 'boolean':
|
191
|
+
attValue = attValue.toLowerCase() == 'true';
|
192
|
+
break;
|
193
|
+
default:
|
194
|
+
}
|
195
|
+
node.attributes[attId] = attValue;
|
196
|
+
}
|
197
|
+
}
|
198
|
+
}
|
199
|
+
|
200
|
+
return node;
|
201
|
+
}) : [];
|
202
|
+
}
|
203
|
+
|
204
|
+
function parseEdges(parent) {
|
205
|
+
return parent ? zrUtil.map(getChildrenByTagName(parent, 'edge'), function (edgeDom) {
|
206
|
+
var id = getAttr(edgeDom, 'id');
|
207
|
+
var label = getAttr(edgeDom, 'label');
|
208
|
+
|
209
|
+
var sourceId = getAttr(edgeDom, 'source');
|
210
|
+
var targetId = getAttr(edgeDom, 'target');
|
211
|
+
|
212
|
+
var edge = {
|
213
|
+
id: id,
|
214
|
+
name: label,
|
215
|
+
source: sourceId,
|
216
|
+
target: targetId,
|
217
|
+
lineStyle: {
|
218
|
+
normal: {}
|
219
|
+
}
|
220
|
+
};
|
221
|
+
|
222
|
+
var lineStyle = edge.lineStyle.normal;
|
223
|
+
|
224
|
+
var vizThicknessDom = getChildByTagName(edgeDom, 'viz:thickness');
|
225
|
+
var vizColorDom = getChildByTagName(edgeDom, 'viz:color');
|
226
|
+
// var vizShapeDom = getChildByTagName(edgeDom, 'viz:shape');
|
227
|
+
|
228
|
+
if (vizThicknessDom) {
|
229
|
+
lineStyle.width = parseFloat(vizThicknessDom.getAttribute('value'));
|
230
|
+
}
|
231
|
+
if (vizColorDom) {
|
232
|
+
lineStyle.color = 'rgb(' + [
|
233
|
+
getAttr(vizColorDom, 'r') | 0,
|
234
|
+
getAttr(vizColorDom, 'g') | 0,
|
235
|
+
getAttr(vizColorDom, 'b') | 0
|
236
|
+
].join(',') + ')';
|
237
|
+
}
|
238
|
+
// if (vizShapeDom) {
|
239
|
+
// edge.shape = vizShapeDom.getAttribute('shape');
|
240
|
+
// }
|
241
|
+
|
242
|
+
return edge;
|
243
|
+
}) : [];
|
244
|
+
}
|
245
|
+
|
246
|
+
function getAttr(el, attrName) {
|
247
|
+
return el.getAttribute(attrName);
|
248
|
+
}
|
249
|
+
|
250
|
+
function getChildByTagName (parent, tagName) {
|
251
|
+
var node = parent.firstChild;
|
252
|
+
|
253
|
+
while (node) {
|
254
|
+
if (
|
255
|
+
node.nodeType != 1 ||
|
256
|
+
node.nodeName.toLowerCase() != tagName.toLowerCase()
|
257
|
+
) {
|
258
|
+
node = node.nextSibling;
|
259
|
+
} else {
|
260
|
+
return node;
|
261
|
+
}
|
262
|
+
}
|
263
|
+
|
264
|
+
return null;
|
265
|
+
}
|
266
|
+
|
267
|
+
function getChildrenByTagName (parent, tagName) {
|
268
|
+
var node = parent.firstChild;
|
269
|
+
var children = [];
|
270
|
+
while (node) {
|
271
|
+
if (node.nodeName.toLowerCase() == tagName.toLowerCase()) {
|
272
|
+
children.push(node);
|
273
|
+
}
|
274
|
+
node = node.nextSibling;
|
275
|
+
}
|
276
|
+
|
277
|
+
return children;
|
278
|
+
}
|
279
|
+
|
280
|
+
return {
|
281
|
+
parse: parse
|
282
|
+
};
|
283
|
+
}.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
|
284
|
+
|
285
|
+
/***/ },
|
286
|
+
/* 6 */
|
287
|
+
/***/ function(module, exports, __webpack_require__) {
|
288
|
+
|
289
|
+
var __WEBPACK_AMD_DEFINE_RESULT__;!(__WEBPACK_AMD_DEFINE_RESULT__ = function (require) {
|
290
|
+
|
291
|
+
var quantile = __webpack_require__(7);
|
292
|
+
var numberUtil = __webpack_require__(1).number;
|
293
|
+
|
294
|
+
/**
|
295
|
+
* Helper method for preparing data.
|
296
|
+
* @param {Array.<number>} rawData like
|
297
|
+
* [
|
298
|
+
* [12,232,443], (raw data set for the first box)
|
299
|
+
* [3843,5545,1232], (raw datat set for the second box)
|
300
|
+
* ...
|
301
|
+
* ]
|
302
|
+
* @param {Object} [opt]
|
303
|
+
*
|
304
|
+
* @param {(number|string)} [opt.boundIQR=1.5] Data less than min bound is outlier.
|
305
|
+
* default 1.5, means Q1 - 1.5 * (Q3 - Q1).
|
306
|
+
* If pass 'none', min bound will not be used.
|
307
|
+
* @param {(number|string)} [opt.layout='horizontal']
|
308
|
+
* Box plot layout, can be 'horizontal' or 'vertical'
|
309
|
+
*/
|
310
|
+
return function (rawData, opt) {
|
311
|
+
opt = opt || [];
|
312
|
+
var boxData = [];
|
313
|
+
var outliers = [];
|
314
|
+
var axisData = [];
|
315
|
+
var boundIQR = opt.boundIQR;
|
316
|
+
|
317
|
+
for (var i = 0; i < rawData.length; i++) {
|
318
|
+
axisData.push(i + '');
|
319
|
+
var ascList = numberUtil.asc(rawData[i].slice());
|
320
|
+
|
321
|
+
var Q1 = quantile(ascList, 0.25);
|
322
|
+
var Q2 = quantile(ascList, 0.5);
|
323
|
+
var Q3 = quantile(ascList, 0.75);
|
324
|
+
var IQR = Q3 - Q1;
|
325
|
+
|
326
|
+
var low = boundIQR === 'none'
|
327
|
+
? ascList[0]
|
328
|
+
: Q1 - (boundIQR == null ? 1.5 : boundIQR) * IQR;
|
329
|
+
var high = boundIQR === 'none'
|
330
|
+
? ascList[ascList.length - 1]
|
331
|
+
: Q3 + (boundIQR == null ? 1.5 : boundIQR) * IQR;
|
332
|
+
|
333
|
+
boxData.push([low, Q1, Q2, Q3, high]);
|
334
|
+
|
335
|
+
for (var j = 0; j < ascList.length; j++) {
|
336
|
+
var dataItem = ascList[j];
|
337
|
+
if (dataItem < low || dataItem > high) {
|
338
|
+
var outlier = [i, dataItem];
|
339
|
+
opt.layout === 'vertical' && outlier.reverse();
|
340
|
+
outliers.push(outlier);
|
341
|
+
}
|
342
|
+
}
|
343
|
+
}
|
344
|
+
return {
|
345
|
+
boxData: boxData,
|
346
|
+
outliers: outliers,
|
347
|
+
axisData: axisData
|
348
|
+
};
|
349
|
+
};
|
350
|
+
|
351
|
+
}.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
|
352
|
+
|
353
|
+
/***/ },
|
354
|
+
/* 7 */
|
355
|
+
/***/ function(module, exports, __webpack_require__) {
|
356
|
+
|
357
|
+
var __WEBPACK_AMD_DEFINE_RESULT__;/**
|
358
|
+
* Copyright (c) 2010-2015, Michael Bostock
|
359
|
+
* All rights reserved.
|
360
|
+
*
|
361
|
+
* Redistribution and use in source and binary forms, with or without
|
362
|
+
* modification, are permitted provided that the following conditions are met:
|
363
|
+
*
|
364
|
+
* * Redistributions of source code must retain the above copyright notice, this
|
365
|
+
* list of conditions and the following disclaimer.
|
366
|
+
*
|
367
|
+
* * Redistributions in binary form must reproduce the above copyright notice,
|
368
|
+
* this list of conditions and the following disclaimer in the documentation
|
369
|
+
* and/or other materials provided with the distribution.
|
370
|
+
*
|
371
|
+
* * The name Michael Bostock may not be used to endorse or promote products
|
372
|
+
* derived from this software without specific prior written permission.
|
373
|
+
*
|
374
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
375
|
+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
376
|
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
377
|
+
* DISCLAIMED. IN NO EVENT SHALL MICHAEL BOSTOCK BE LIABLE FOR ANY DIRECT,
|
378
|
+
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
379
|
+
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
380
|
+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
381
|
+
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
382
|
+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
383
|
+
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
384
|
+
*/
|
385
|
+
!(__WEBPACK_AMD_DEFINE_RESULT__ = function (require) {
|
386
|
+
|
387
|
+
/**
|
388
|
+
* @see <https://github.com/mbostock/d3/blob/master/src/arrays/quantile.js>
|
389
|
+
* @see <http://en.wikipedia.org/wiki/Quantile>
|
390
|
+
* @param {Array.<number>} ascArr
|
391
|
+
*/
|
392
|
+
return function(ascArr, p) {
|
393
|
+
var H = (ascArr.length - 1) * p + 1,
|
394
|
+
h = Math.floor(H),
|
395
|
+
v = +ascArr[h - 1],
|
396
|
+
e = H - h;
|
397
|
+
return e ? v + e * (ascArr[h] - v) : v;
|
398
|
+
};
|
399
|
+
|
400
|
+
}.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
|
401
|
+
|
402
|
+
/***/ }
|
403
|
+
/******/ ])
|
404
|
+
});
|
405
|
+
;
|