更新设备变量信息

This commit is contained in:
dell
2023-03-10 16:39:21 +08:00
parent d62c6b0122
commit 80564727ea
739 changed files with 512610 additions and 0 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,413 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('echarts')) :
typeof define === 'function' && define.amd ? define(['exports', 'echarts'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bmap = {}, global.echarts));
}(this, (function (exports, echarts) { 'use strict';
function BMapCoordSys(bmap, api) {
this._bmap = bmap;
this.dimensions = ['lng', 'lat'];
this._mapOffset = [0, 0];
this._api = api;
this._projection = new BMap.MercatorProjection();
}
BMapCoordSys.prototype.dimensions = ['lng', 'lat'];
BMapCoordSys.prototype.setZoom = function (zoom) {
this._zoom = zoom;
};
BMapCoordSys.prototype.setCenter = function (center) {
this._center = this._projection.lngLatToPoint(new BMap.Point(center[0], center[1]));
};
BMapCoordSys.prototype.setMapOffset = function (mapOffset) {
this._mapOffset = mapOffset;
};
BMapCoordSys.prototype.getBMap = function () {
return this._bmap;
};
BMapCoordSys.prototype.dataToPoint = function (data) {
var point = new BMap.Point(data[0], data[1]); // TODO mercator projection is toooooooo slow
// let mercatorPoint = this._projection.lngLatToPoint(point);
// let width = this._api.getZr().getWidth();
// let height = this._api.getZr().getHeight();
// let divider = Math.pow(2, 18 - 10);
// return [
// Math.round((mercatorPoint.x - this._center.x) / divider + width / 2),
// Math.round((this._center.y - mercatorPoint.y) / divider + height / 2)
// ];
var px = this._bmap.pointToOverlayPixel(point);
var mapOffset = this._mapOffset;
return [px.x - mapOffset[0], px.y - mapOffset[1]];
};
BMapCoordSys.prototype.pointToData = function (pt) {
var mapOffset = this._mapOffset;
pt = this._bmap.overlayPixelToPoint({
x: pt[0] + mapOffset[0],
y: pt[1] + mapOffset[1]
});
return [pt.lng, pt.lat];
};
BMapCoordSys.prototype.getViewRect = function () {
var api = this._api;
return new echarts.graphic.BoundingRect(0, 0, api.getWidth(), api.getHeight());
};
BMapCoordSys.prototype.getRoamTransform = function () {
return echarts.matrix.create();
};
BMapCoordSys.prototype.prepareCustoms = function () {
var rect = this.getViewRect();
return {
coordSys: {
// The name exposed to user is always 'cartesian2d' but not 'grid'.
type: 'bmap',
x: rect.x,
y: rect.y,
width: rect.width,
height: rect.height
},
api: {
coord: echarts.util.bind(this.dataToPoint, this),
size: echarts.util.bind(dataToCoordSize, this)
}
};
};
function dataToCoordSize(dataSize, dataItem) {
dataItem = dataItem || [0, 0];
return echarts.util.map([0, 1], function (dimIdx) {
var val = dataItem[dimIdx];
var halfSize = dataSize[dimIdx] / 2;
var p1 = [];
var p2 = [];
p1[dimIdx] = val - halfSize;
p2[dimIdx] = val + halfSize;
p1[1 - dimIdx] = p2[1 - dimIdx] = dataItem[1 - dimIdx];
return Math.abs(this.dataToPoint(p1)[dimIdx] - this.dataToPoint(p2)[dimIdx]);
}, this);
}
var Overlay; // For deciding which dimensions to use when creating list data
BMapCoordSys.dimensions = BMapCoordSys.prototype.dimensions;
function createOverlayCtor() {
function Overlay(root) {
this._root = root;
}
Overlay.prototype = new BMap.Overlay();
/**
* 初始化
*
* @param {BMap.Map} map
* @override
*/
Overlay.prototype.initialize = function (map) {
map.getPanes().labelPane.appendChild(this._root);
return this._root;
};
/**
* @override
*/
Overlay.prototype.draw = function () {};
return Overlay;
}
BMapCoordSys.create = function (ecModel, api) {
var bmapCoordSys;
var root = api.getDom(); // TODO Dispose
ecModel.eachComponent('bmap', function (bmapModel) {
var painter = api.getZr().painter;
var viewportRoot = painter.getViewportRoot();
if (typeof BMap === 'undefined') {
throw new Error('BMap api is not loaded');
}
Overlay = Overlay || createOverlayCtor();
if (bmapCoordSys) {
throw new Error('Only one bmap component can exist');
}
var bmap;
if (!bmapModel.__bmap) {
// Not support IE8
var bmapRoot = root.querySelector('.ec-extension-bmap');
if (bmapRoot) {
// Reset viewport left and top, which will be changed
// in moving handler in BMapView
viewportRoot.style.left = '0px';
viewportRoot.style.top = '0px';
root.removeChild(bmapRoot);
}
bmapRoot = document.createElement('div');
bmapRoot.className = 'ec-extension-bmap'; // fix #13424
bmapRoot.style.cssText = 'position:absolute;width:100%;height:100%';
root.appendChild(bmapRoot); // initializes bmap
var mapOptions = bmapModel.get('mapOptions');
if (mapOptions) {
mapOptions = echarts.util.clone(mapOptions); // Not support `mapType`, use `bmap.setMapType(MapType)` instead.
delete mapOptions.mapType;
}
bmap = bmapModel.__bmap = new BMap.Map(bmapRoot, mapOptions);
var overlay = new Overlay(viewportRoot);
bmap.addOverlay(overlay); // Override
painter.getViewportRootOffset = function () {
return {
offsetLeft: 0,
offsetTop: 0
};
};
}
bmap = bmapModel.__bmap; // Set bmap options
// centerAndZoom before layout and render
var center = bmapModel.get('center');
var zoom = bmapModel.get('zoom');
if (center && zoom) {
var bmapCenter = bmap.getCenter();
var bmapZoom = bmap.getZoom();
var centerOrZoomChanged = bmapModel.centerOrZoomChanged([bmapCenter.lng, bmapCenter.lat], bmapZoom);
if (centerOrZoomChanged) {
var pt = new BMap.Point(center[0], center[1]);
bmap.centerAndZoom(pt, zoom);
}
}
bmapCoordSys = new BMapCoordSys(bmap, api);
bmapCoordSys.setMapOffset(bmapModel.__mapOffset || [0, 0]);
bmapCoordSys.setZoom(zoom);
bmapCoordSys.setCenter(center);
bmapModel.coordinateSystem = bmapCoordSys;
});
ecModel.eachSeries(function (seriesModel) {
if (seriesModel.get('coordinateSystem') === 'bmap') {
seriesModel.coordinateSystem = bmapCoordSys;
}
});
};
function v2Equal(a, b) {
return a && b && a[0] === b[0] && a[1] === b[1];
}
echarts.extendComponentModel({
type: 'bmap',
getBMap: function () {
// __bmap is injected when creating BMapCoordSys
return this.__bmap;
},
setCenterAndZoom: function (center, zoom) {
this.option.center = center;
this.option.zoom = zoom;
},
centerOrZoomChanged: function (center, zoom) {
var option = this.option;
return !(v2Equal(center, option.center) && zoom === option.zoom);
},
defaultOption: {
center: [104.114129, 37.550339],
zoom: 5,
// 2.0 http://lbsyun.baidu.com/custom/index.htm
mapStyle: {},
// 3.0 http://lbsyun.baidu.com/index.php?title=open/custom
mapStyleV2: {},
// See https://lbsyun.baidu.com/cms/jsapi/reference/jsapi_reference.html#a0b1
mapOptions: {},
roam: false
}
});
function isEmptyObject(obj) {
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
return false;
}
}
return true;
}
echarts.extendComponentView({
type: 'bmap',
render: function (bMapModel, ecModel, api) {
var rendering = true;
var bmap = bMapModel.getBMap();
var viewportRoot = api.getZr().painter.getViewportRoot();
var coordSys = bMapModel.coordinateSystem;
var moveHandler = function (type, target) {
if (rendering) {
return;
}
var offsetEl = viewportRoot.parentNode.parentNode.parentNode;
var mapOffset = [-parseInt(offsetEl.style.left, 10) || 0, -parseInt(offsetEl.style.top, 10) || 0]; // only update style when map offset changed
var viewportRootStyle = viewportRoot.style;
var offsetLeft = mapOffset[0] + 'px';
var offsetTop = mapOffset[1] + 'px';
if (viewportRootStyle.left !== offsetLeft) {
viewportRootStyle.left = offsetLeft;
}
if (viewportRootStyle.top !== offsetTop) {
viewportRootStyle.top = offsetTop;
}
coordSys.setMapOffset(mapOffset);
bMapModel.__mapOffset = mapOffset;
api.dispatchAction({
type: 'bmapRoam',
animation: {
duration: 0
}
});
};
function zoomEndHandler() {
if (rendering) {
return;
}
api.dispatchAction({
type: 'bmapRoam',
animation: {
duration: 0
}
});
}
bmap.removeEventListener('moving', this._oldMoveHandler);
bmap.removeEventListener('moveend', this._oldMoveHandler);
bmap.removeEventListener('zoomend', this._oldZoomEndHandler);
bmap.addEventListener('moving', moveHandler);
bmap.addEventListener('moveend', moveHandler);
bmap.addEventListener('zoomend', zoomEndHandler);
this._oldMoveHandler = moveHandler;
this._oldZoomEndHandler = zoomEndHandler;
var roam = bMapModel.get('roam');
if (roam && roam !== 'scale') {
bmap.enableDragging();
} else {
bmap.disableDragging();
}
if (roam && roam !== 'move') {
bmap.enableScrollWheelZoom();
bmap.enableDoubleClickZoom();
bmap.enablePinchToZoom();
} else {
bmap.disableScrollWheelZoom();
bmap.disableDoubleClickZoom();
bmap.disablePinchToZoom();
}
/* map 2.0 */
var originalStyle = bMapModel.__mapStyle;
var newMapStyle = bMapModel.get('mapStyle') || {}; // FIXME, Not use JSON methods
var mapStyleStr = JSON.stringify(newMapStyle);
if (JSON.stringify(originalStyle) !== mapStyleStr) {
// FIXME May have blank tile when dragging if setMapStyle
if (!isEmptyObject(newMapStyle)) {
bmap.setMapStyle(echarts.util.clone(newMapStyle));
}
bMapModel.__mapStyle = JSON.parse(mapStyleStr);
}
/* map 3.0 */
var originalStyle2 = bMapModel.__mapStyle2;
var newMapStyle2 = bMapModel.get('mapStyleV2') || {}; // FIXME, Not use JSON methods
var mapStyleStr2 = JSON.stringify(newMapStyle2);
if (JSON.stringify(originalStyle2) !== mapStyleStr2) {
// FIXME May have blank tile when dragging if setMapStyle
if (!isEmptyObject(newMapStyle2)) {
bmap.setMapStyleV2(echarts.util.clone(newMapStyle2));
}
bMapModel.__mapStyle2 = JSON.parse(mapStyleStr2);
}
rendering = false;
}
});
echarts.registerCoordinateSystem('bmap', BMapCoordSys); // Action
echarts.registerAction({
type: 'bmapRoam',
event: 'bmapRoam',
update: 'updateLayout'
}, function (payload, ecModel) {
ecModel.eachComponent('bmap', function (bMapModel) {
var bmap = bMapModel.getBMap();
var center = bmap.getCenter();
bMapModel.setCenterAndZoom([center.lng, center.lat], bmap.getZoom());
});
});
var version = '1.0.0';
exports.version = version;
Object.defineProperty(exports, '__esModule', { value: true });
})));
//# sourceMappingURL=bmap.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,22 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("echarts")):"function"==typeof define&&define.amd?define(["exports","echarts"],t):t((e=e||self).bmap={},e.echarts)}(this,function(e,d){"use strict";function l(e,t){this._bmap=e,this.dimensions=["lng","lat"],this._mapOffset=[0,0],this._api=t,this._projection=new BMap.MercatorProjection}function t(a,r){return r=r||[0,0],d.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 c;function f(e){for(var t in e)if(e.hasOwnProperty(t))return;return 1}l.prototype.dimensions=["lng","lat"],l.prototype.setZoom=function(e){this._zoom=e},l.prototype.setCenter=function(e){this._center=this._projection.lngLatToPoint(new BMap.Point(e[0],e[1]))},l.prototype.setMapOffset=function(e){this._mapOffset=e},l.prototype.getBMap=function(){return this._bmap},l.prototype.dataToPoint=function(e){var t=new BMap.Point(e[0],e[1]),e=this._bmap.pointToOverlayPixel(t),t=this._mapOffset;return[e.x-t[0],e.y-t[1]]},l.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]},l.prototype.getViewRect=function(){var e=this._api;return new d.graphic.BoundingRect(0,0,e.getWidth(),e.getHeight())},l.prototype.getRoamTransform=function(){return d.matrix.create()},l.prototype.prepareCustoms=function(){var e=this.getViewRect();return{coordSys:{type:"bmap",x:e.x,y:e.y,width:e.width,height:e.height},api:{coord:d.util.bind(this.dataToPoint,this),size:d.util.bind(t,this)}}},l.dimensions=l.prototype.dimensions,l.create=function(e,p){var s,m=p.getDom();e.eachComponent("bmap",function(e){var t,o=p.getZr().painter,n=o.getViewportRoot();if("undefined"==typeof BMap)throw new Error("BMap api is not loaded");function i(e){this._root=e}if(c=c||((i.prototype=new BMap.Overlay).initialize=function(e){return e.getPanes().labelPane.appendChild(this._root),this._root},i.prototype.draw=function(){},i),s)throw new Error("Only one bmap component can exist");e.__bmap||((a=m.querySelector(".ec-extension-bmap"))&&(n.style.left="0px",n.style.top="0px",m.removeChild(a)),(a=document.createElement("div")).className="ec-extension-bmap",a.style.cssText="position:absolute;width:100%;height:100%",m.appendChild(a),(r=e.get("mapOptions"))&&delete(r=d.util.clone(r)).mapType,t=e.__bmap=new BMap.Map(a,r),a=new c(n),t.addOverlay(a),o.getViewportRootOffset=function(){return{offsetLeft:0,offsetTop:0}}),t=e.__bmap;var a,r=e.get("center"),n=e.get("zoom");r&&n&&(a=t.getCenter(),o=t.getZoom(),e.centerOrZoomChanged([a.lng,a.lat],o)&&(o=new BMap.Point(r[0],r[1]),t.centerAndZoom(o,n))),(s=new l(t,p)).setMapOffset(e.__mapOffset||[0,0]),s.setZoom(n),s.setCenter(r),e.coordinateSystem=s}),e.eachSeries(function(e){"bmap"===e.get("coordinateSystem")&&(e.coordinateSystem=s)})},d.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,n=this.option;return o=e,e=n.center,!(o&&e&&o[0]===e[0]&&o[1]===e[1]&&t===n.zoom)},defaultOption:{center:[104.114129,37.550339],zoom:5,mapStyle:{},mapStyleV2:{},mapOptions:{},roam:!1}}),d.extendComponentView({type:"bmap",render:function(r,e,p){var s=!0,t=r.getBMap(),m=p.getZr().painter.getViewportRoot(),l=r.coordinateSystem,o=function(e,t){var o,n,i,a;s||(a=m.parentNode.parentNode.parentNode,o=[-parseInt(a.style.left,10)||0,-parseInt(a.style.top,10)||0],n=m.style,i=o[0]+"px",a=o[1]+"px",n.left!==i&&(n.left=i),n.top!==a&&(n.top=a),l.setMapOffset(o),r.__mapOffset=o,p.dispatchAction({type:"bmapRoam",animation:{duration:0}}))};function n(){s||p.dispatchAction({type:"bmapRoam",animation:{duration:0}})}t.removeEventListener("moving",this._oldMoveHandler),t.removeEventListener("moveend",this._oldMoveHandler),t.removeEventListener("zoomend",this._oldZoomEndHandler),t.addEventListener("moving",o),t.addEventListener("moveend",o),t.addEventListener("zoomend",n),this._oldMoveHandler=o,this._oldZoomEndHandler=n;var i=r.get("roam");i&&"scale"!==i?t.enableDragging():t.disableDragging(),i&&"move"!==i?(t.enableScrollWheelZoom(),t.enableDoubleClickZoom(),t.enablePinchToZoom()):(t.disableScrollWheelZoom(),t.disableDoubleClickZoom(),t.disablePinchToZoom());var a=r.__mapStyle,o=r.get("mapStyle")||{},i=JSON.stringify(o);JSON.stringify(a)!==i&&(f(o)||t.setMapStyle(d.util.clone(o)),r.__mapStyle=JSON.parse(i));a=r.__mapStyle2,o=r.get("mapStyleV2")||{},i=JSON.stringify(o);JSON.stringify(a)!==i&&(f(o)||t.setMapStyleV2(d.util.clone(o)),r.__mapStyle2=JSON.parse(i)),s=!1}}),d.registerCoordinateSystem("bmap",l),d.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",Object.defineProperty(e,"__esModule",{value:!0})});

View File

@ -0,0 +1,436 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('echarts')) :
typeof define === 'function' && define.amd ? define(['exports', 'echarts'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.dataTool = {}, global.echarts));
}(this, (function (exports, echarts) { 'use strict';
var BUILTIN_OBJECT = reduce([
'Function',
'RegExp',
'Date',
'Error',
'CanvasGradient',
'CanvasPattern',
'Image',
'Canvas'
], function (obj, val) {
obj['[object ' + val + ']'] = true;
return obj;
}, {});
var TYPED_ARRAY = reduce([
'Int8',
'Uint8',
'Uint8Clamped',
'Int16',
'Uint16',
'Int32',
'Uint32',
'Float32',
'Float64'
], function (obj, val) {
obj['[object ' + val + 'Array]'] = true;
return obj;
}, {});
var arrayProto = Array.prototype;
var nativeSlice = arrayProto.slice;
var nativeMap = arrayProto.map;
var ctorFunction = function () { }.constructor;
var protoFunction = ctorFunction ? ctorFunction.prototype : null;
function map(arr, cb, context) {
if (!arr) {
return [];
}
if (!cb) {
return slice(arr);
}
if (arr.map && arr.map === nativeMap) {
return arr.map(cb, context);
}
else {
var result = [];
for (var i = 0, len = arr.length; i < len; i++) {
result.push(cb.call(context, arr[i], i, arr));
}
return result;
}
}
function reduce(arr, cb, memo, context) {
if (!(arr && cb)) {
return;
}
for (var i = 0, len = arr.length; i < len; i++) {
memo = cb.call(context, memo, arr[i], i, arr);
}
return memo;
}
function bindPolyfill(func, context) {
var args = [];
for (var _i = 2; _i < arguments.length; _i++) {
args[_i - 2] = arguments[_i];
}
return function () {
return func.apply(context, args.concat(nativeSlice.call(arguments)));
};
}
var bind = (protoFunction && isFunction(protoFunction.bind))
? protoFunction.call.bind(protoFunction.bind)
: bindPolyfill;
function isFunction(value) {
return typeof value === 'function';
}
function slice(arr) {
var args = [];
for (var _i = 1; _i < arguments.length; _i++) {
args[_i - 1] = arguments[_i];
}
return nativeSlice.apply(arr, args);
}
function parse(xml) {
var doc;
if (typeof xml === 'string') {
var parser = new DOMParser();
doc = parser.parseFromString(xml, 'text/xml');
} else {
doc = xml;
}
if (!doc || doc.getElementsByTagName('parsererror').length) {
return null;
}
var gexfRoot = getChildByTagName(doc, 'gexf');
if (!gexfRoot) {
return null;
}
var graphRoot = getChildByTagName(gexfRoot, 'graph');
var attributes = parseAttributes(getChildByTagName(graphRoot, 'attributes'));
var attributesMap = {};
for (var i = 0; i < attributes.length; i++) {
attributesMap[attributes[i].id] = attributes[i];
}
return {
nodes: parseNodes(getChildByTagName(graphRoot, 'nodes'), attributesMap),
links: parseEdges(getChildByTagName(graphRoot, 'edges'))
};
}
function parseAttributes(parent) {
return parent ? map(getChildrenByTagName(parent, 'attribute'), function (attribDom) {
return {
id: getAttr(attribDom, 'id'),
title: getAttr(attribDom, 'title'),
type: getAttr(attribDom, 'type')
};
}) : [];
}
function parseNodes(parent, attributesMap) {
return parent ? map(getChildrenByTagName(parent, 'node'), function (nodeDom) {
var id = getAttr(nodeDom, 'id');
var label = getAttr(nodeDom, 'label');
var node = {
id: id,
name: label,
itemStyle: {
normal: {}
}
};
var vizSizeDom = getChildByTagName(nodeDom, 'viz:size');
var vizPosDom = getChildByTagName(nodeDom, 'viz:position');
var vizColorDom = getChildByTagName(nodeDom, 'viz:color'); // let vizShapeDom = getChildByTagName(nodeDom, 'viz:shape');
var attvaluesDom = getChildByTagName(nodeDom, 'attvalues');
if (vizSizeDom) {
node.symbolSize = parseFloat(getAttr(vizSizeDom, 'value'));
}
if (vizPosDom) {
node.x = parseFloat(getAttr(vizPosDom, 'x'));
node.y = parseFloat(getAttr(vizPosDom, 'y')); // z
}
if (vizColorDom) {
node.itemStyle.normal.color = 'rgb(' + [getAttr(vizColorDom, 'r') | 0, getAttr(vizColorDom, 'g') | 0, getAttr(vizColorDom, 'b') | 0].join(',') + ')';
} // if (vizShapeDom) {
// node.shape = getAttr(vizShapeDom, 'shape');
// }
if (attvaluesDom) {
var attvalueDomList = getChildrenByTagName(attvaluesDom, 'attvalue');
node.attributes = {};
for (var j = 0; j < attvalueDomList.length; j++) {
var attvalueDom = attvalueDomList[j];
var attId = getAttr(attvalueDom, 'for');
var attValue = getAttr(attvalueDom, 'value');
var attribute = attributesMap[attId];
if (attribute) {
switch (attribute.type) {
case 'integer':
case 'long':
attValue = parseInt(attValue, 10);
break;
case 'float':
case 'double':
attValue = parseFloat(attValue);
break;
case 'boolean':
attValue = attValue.toLowerCase() === 'true';
break;
}
node.attributes[attId] = attValue;
}
}
}
return node;
}) : [];
}
function parseEdges(parent) {
return parent ? map(getChildrenByTagName(parent, 'edge'), function (edgeDom) {
var id = getAttr(edgeDom, 'id');
var label = getAttr(edgeDom, 'label');
var sourceId = getAttr(edgeDom, 'source');
var targetId = getAttr(edgeDom, 'target');
var edge = {
id: id,
name: label,
source: sourceId,
target: targetId,
lineStyle: {
normal: {}
}
};
var lineStyle = edge.lineStyle.normal;
var vizThicknessDom = getChildByTagName(edgeDom, 'viz:thickness');
var vizColorDom = getChildByTagName(edgeDom, 'viz:color'); // let vizShapeDom = getChildByTagName(edgeDom, 'viz:shape');
if (vizThicknessDom) {
lineStyle.width = parseFloat(vizThicknessDom.getAttribute('value'));
}
if (vizColorDom) {
lineStyle.color = 'rgb(' + [getAttr(vizColorDom, 'r') | 0, getAttr(vizColorDom, 'g') | 0, getAttr(vizColorDom, 'b') | 0].join(',') + ')';
} // if (vizShapeDom) {
// edge.shape = vizShapeDom.getAttribute('shape');
// }
return edge;
}) : [];
}
function getAttr(el, attrName) {
return el.getAttribute(attrName);
}
function getChildByTagName(parent, tagName) {
var node = parent.firstChild;
while (node) {
if (node.nodeType !== 1 || node.nodeName.toLowerCase() !== tagName.toLowerCase()) {
node = node.nextSibling;
} else {
return node;
}
}
return null;
}
function getChildrenByTagName(parent, tagName) {
var node = parent.firstChild;
var children = [];
while (node) {
if (node.nodeName.toLowerCase() === tagName.toLowerCase()) {
children.push(node);
}
node = node.nextSibling;
}
return children;
}
var gexf = /*#__PURE__*/Object.freeze({
__proto__: null,
parse: parse
});
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
function asc(arr) {
arr.sort(function (a, b) {
return a - b;
});
return arr;
}
function quantile(ascArr, p) {
var H = (ascArr.length - 1) * p + 1;
var h = Math.floor(H);
var v = +ascArr[h - 1];
var e = H - h;
return e ? v + e * (ascArr[h] - v) : v;
}
/**
* See:
* <https://en.wikipedia.org/wiki/Box_plot#cite_note-frigge_hoaglin_iglewicz-2>
* <http://stat.ethz.ch/R-manual/R-devel/library/grDevices/html/boxplot.stats.html>
*
* Helper method for preparing data.
*
* @param {Array.<number>} rawData like
* [
* [12,232,443], (raw data set for the first box)
* [3843,5545,1232], (raw data set for the second box)
* ...
* ]
* @param {Object} [opt]
*
* @param {(number|string)} [opt.boundIQR=1.5] Data less than min bound is outlier.
* default 1.5, means Q1 - 1.5 * (Q3 - Q1).
* If 'none'/0 passed, min bound will not be used.
* @param {(number|string)} [opt.layout='horizontal']
* Box plot layout, can be 'horizontal' or 'vertical'
* @return {Object} {
* boxData: Array.<Array.<number>>
* outliers: Array.<Array.<number>>
* axisData: Array.<string>
* }
*/
function prepareBoxplotData (rawData, opt) {
opt = opt || {};
var boxData = [];
var outliers = [];
var axisData = [];
var boundIQR = opt.boundIQR;
var useExtreme = boundIQR === 'none' || boundIQR === 0;
for (var i = 0; i < rawData.length; i++) {
axisData.push(i + '');
var ascList = asc(rawData[i].slice());
var Q1 = quantile(ascList, 0.25);
var Q2 = quantile(ascList, 0.5);
var Q3 = quantile(ascList, 0.75);
var min = ascList[0];
var max = ascList[ascList.length - 1];
var bound = (boundIQR == null ? 1.5 : boundIQR) * (Q3 - Q1);
var low = useExtreme ? min : Math.max(min, Q1 - bound);
var high = useExtreme ? max : Math.min(max, Q3 + bound);
boxData.push([low, Q1, Q2, Q3, high]);
for (var j = 0; j < ascList.length; j++) {
var dataItem = ascList[j];
if (dataItem < low || dataItem > high) {
var outlier = [i, dataItem];
opt.layout === 'vertical' && outlier.reverse();
outliers.push(outlier);
}
}
}
return {
boxData: boxData,
outliers: outliers,
axisData: axisData
};
}
var version = '1.0.0';
// For backward compatibility, where the namespace `dataTool` will
// be mounted on `echarts` is the extension `dataTool` is imported.
// But the old version of echarts do not have `dataTool` namespace,
// so check it before mounting.
if (echarts.dataTool) {
echarts.dataTool.version = version;
echarts.dataTool.gexf = gexf;
echarts.dataTool.prepareBoxplotData = prepareBoxplotData; // echarts.dataTool.boxplotTransform = boxplotTransform;
}
exports.gexf = gexf;
exports.prepareBoxplotData = prepareBoxplotData;
exports.version = version;
Object.defineProperty(exports, '__esModule', { value: true });
})));
//# sourceMappingURL=dataTool.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,22 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("echarts")):"function"==typeof define&&define.amd?define(["exports","echarts"],t):t((e=e||self).dataTool={},e.echarts)}(this,function(e,t){"use strict";var r=Array.prototype,i=r.slice,l=r.map,o=function(){}.constructor,r=o?o.prototype:null;function a(e,t,r){if(!e)return[];if(!t)return function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return i.apply(e,t)}(e);if(e.map&&e.map===l)return e.map(t,r);for(var o=[],n=0,a=e.length;n<a;n++)o.push(t.call(r,e[n],n,e));return o}r&&"function"==typeof r.bind&&r.call.bind(r.bind);function p(e,t){return e.getAttribute(t)}function c(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 d(e,t){for(var r=e.firstChild,o=[];r;)r.nodeName.toLowerCase()===t.toLowerCase()&&o.push(r),r=r.nextSibling;return o}o=Object.freeze({__proto__:null,parse:function(e){if(!(t="string"==typeof e?(new DOMParser).parseFromString(e,"text/xml"):e)||t.getElementsByTagName("parsererror").length)return null;if(!(e=c(t,"gexf")))return null;for(var f,t=c(e,"graph"),r=(e=c(t,"attributes"))?a(d(e,"attribute"),function(e){return{id:p(e,"id"),title:p(e,"title"),type:p(e,"type")}}):[],o={},n=0;n<r.length;n++)o[r[n].id]=r[n];return{nodes:(e=c(t,"nodes"),f=o,e?a(d(e,"node"),function(e){var t={id:p(e,"id"),name:p(e,"label"),itemStyle:{normal:{}}},r=c(e,"viz:size"),o=c(e,"viz:position"),n=c(e,"viz:color"),e=c(e,"attvalues");if(r&&(t.symbolSize=parseFloat(p(r,"value"))),o&&(t.x=parseFloat(p(o,"x")),t.y=parseFloat(p(o,"y"))),n&&(t.itemStyle.normal.color="rgb("+[0|p(n,"r"),0|p(n,"g"),0|p(n,"b")].join(",")+")"),e){var a=d(e,"attvalue");t.attributes={};for(var i=0;i<a.length;i++){var l=a[i],u=p(l,"for"),s=p(l,"value"),l=f[u];if(l){switch(l.type){case"integer":case"long":s=parseInt(s,10);break;case"float":case"double":s=parseFloat(s);break;case"boolean":s="true"===s.toLowerCase()}t.attributes[u]=s}}}return t}):[]),links:(t=c(t,"edges"))?a(d(t,"edge"),function(e){var t={id:p(e,"id"),name:p(e,"label"),source:p(e,"source"),target:p(e,"target"),lineStyle:{normal:{}}},r=t.lineStyle.normal,o=c(e,"viz:thickness"),e=c(e,"viz:color");return o&&(r.width=parseFloat(o.getAttribute("value"))),e&&(r.color="rgb("+[0|p(e,"r"),0|p(e,"g"),0|p(e,"b")].join(",")+")"),t}):[]}}});function y(e,t){var r=(e.length-1)*t+1,o=Math.floor(r),t=+e[o-1],r=r-o;return r?t+r*(e[o]-t):t}function n(e,t){for(var r=[],o=[],n=[],a=(t=t||{}).boundIQR,i="none"===a||0===a,l=0;l<e.length;l++){n.push(l+"");var u=((g=e[l].slice()).sort(function(e,t){return e-t}),g),s=y(u,.25),f=y(u,.5),p=y(u,.75),c=u[0],d=u[u.length-1],g=(null==a?1.5:a)*(p-s),v=i?c:Math.max(c,s-g),b=i?d:Math.min(d,p+g);r.push([v,s,f,p,b]);for(var h=0;h<u.length;h++){var m=u[h];(m<v||b<m)&&(m=[l,m],"vertical"===t.layout&&m.reverse(),o.push(m))}}return{boxData:r,outliers:o,axisData:n}}r="1.0.0";t.dataTool&&(t.dataTool.version=r,t.dataTool.gexf=o,t.dataTool.prepareBoxplotData=n),e.gexf=o,e.prepareBoxplotData=n,e.version=r,Object.defineProperty(e,"__esModule",{value:!0})});