1
0
mirror of https://gitlab.com/JKANetwork/CheckServer.git synced 2026-04-03 17:22:01 +02:00

Start again

This commit is contained in:
2020-10-04 17:14:00 +02:00
parent c0d3912413
commit 091f119048
4382 changed files with 1762543 additions and 9606 deletions

View File

@@ -0,0 +1,36 @@
define(function(require) {
'use strict';
var zrUtil = require('zrender/core/util');
var Axis = require('../Axis');
function AngleAxis(scale, angleExtent) {
angleExtent = angleExtent || [0, 360];
Axis.call(this, 'angle', scale, angleExtent);
/**
* Axis type
* - 'category'
* - 'value'
* - 'time'
* - 'log'
* @type {string}
*/
this.type = 'category';
}
AngleAxis.prototype = {
constructor: AngleAxis,
dataToAngle: Axis.prototype.dataToCoord,
angleToData: Axis.prototype.coordToData
};
zrUtil.inherits(AngleAxis, Axis);
return AngleAxis;
});

View File

@@ -0,0 +1,48 @@
define(function(require) {
'use strict';
var zrUtil = require('zrender/core/util');
var ComponentModel = require('../../model/Component');
var axisModelCreator = require('../axisModelCreator');
var PolarAxisModel = ComponentModel.extend({
type: 'polarAxis',
/**
* @type {module:echarts/coord/polar/AngleAxis|module:echarts/coord/polar/RadiusAxis}
*/
axis: null
});
zrUtil.merge(PolarAxisModel.prototype, require('../axisModelCommonMixin'));
var polarAxisDefaultExtendedOption = {
angle: {
polarIndex: 0,
startAngle: 90,
clockwise: true,
splitNumber: 12,
axisLabel: {
rotate: false
}
},
radius: {
polarIndex: 0,
splitNumber: 5
}
};
function getAxisType(axisDim, option) {
// Default axis with data is category axis
return option.type || (option.data ? 'category' : 'value');
}
axisModelCreator('angle', PolarAxisModel, getAxisType, polarAxisDefaultExtendedOption.angle);
axisModelCreator('radius', PolarAxisModel, getAxisType, polarAxisDefaultExtendedOption.radius);
});

229
vendors/echarts/src/coord/polar/Polar.js vendored Normal file
View File

@@ -0,0 +1,229 @@
/**
* @module echarts/coord/polar/Polar
*/
define(function(require) {
'use strict';
var RadiusAxis = require('./RadiusAxis');
var AngleAxis = require('./AngleAxis');
/**
* @alias {module:echarts/coord/polar/Polar}
* @constructor
* @param {string} name
*/
var Polar = function (name) {
/**
* @type {string}
*/
this.name = name || '';
/**
* x of polar center
* @type {number}
*/
this.cx = 0;
/**
* y of polar center
* @type {number}
*/
this.cy = 0;
/**
* @type {module:echarts/coord/polar/RadiusAxis}
* @private
*/
this._radiusAxis = new RadiusAxis();
/**
* @type {module:echarts/coord/polar/AngleAxis}
* @private
*/
this._angleAxis = new AngleAxis();
};
Polar.prototype = {
constructor: Polar,
type: 'polar',
/**
* @param {Array.<string>}
* @readOnly
*/
dimensions: ['radius', 'angle'],
/**
* If contain coord
* @param {Array.<number>} point
* @return {boolean}
*/
containPoint: function (point) {
var coord = this.pointToCoord(point);
return this._radiusAxis.contain(coord[0])
&& this._angleAxis.contain(coord[1]);
},
/**
* If contain data
* @param {Array.<number>} data
* @return {boolean}
*/
containData: function (data) {
return this._radiusAxis.containData(data[0])
&& this._angleAxis.containData(data[1]);
},
/**
* @param {string} axisType
* @return {module:echarts/coord/polar/AngleAxis|module:echarts/coord/polar/RadiusAxis}
*/
getAxis: function (axisType) {
return this['_' + axisType + 'Axis'];
},
/**
* Get axes by type of scale
* @param {string} scaleType
* @return {module:echarts/coord/polar/AngleAxis|module:echarts/coord/polar/RadiusAxis}
*/
getAxesByScale: function (scaleType) {
var axes = [];
var angleAxis = this._angleAxis;
var radiusAxis = this._radiusAxis;
angleAxis.scale.type === scaleType && axes.push(angleAxis);
radiusAxis.scale.type === scaleType && axes.push(radiusAxis);
return axes;
},
/**
* @return {module:echarts/coord/polar/AngleAxis}
*/
getAngleAxis: function () {
return this._angleAxis;
},
/**
* @return {module:echarts/coord/polar/RadiusAxis}
*/
getRadiusAxis: function () {
return this._radiusAxis;
},
/**
* @param {module:echarts/coord/polar/Axis}
* @return {module:echarts/coord/polar/Axis}
*/
getOtherAxis: function (axis) {
var angleAxis = this._angleAxis;
return axis === angleAxis ? this._radiusAxis : angleAxis;
},
/**
* Base axis will be used on stacking.
*
* @return {module:echarts/coord/polar/Axis}
*/
getBaseAxis: function () {
return this.getAxesByScale('ordinal')[0]
|| this.getAxesByScale('time')[0]
|| this.getAngleAxis();
},
/**
* Convert series data to a list of (x, y) points
* @param {module:echarts/data/List} data
* @return {Array}
* Return list of coordinates. For example:
* `[[10, 10], [20, 20], [30, 30]]`
*/
dataToPoints: function (data) {
return data.mapArray(this.dimensions, function (radius, angle) {
return this.dataToPoint([radius, angle]);
}, this);
},
/**
* Convert a single data item to (x, y) point.
* Parameter data is an array which the first element is radius and the second is angle
* @param {Array.<number>} data
* @param {boolean} [clamp=false]
* @return {Array.<number>}
*/
dataToPoint: function (data, clamp) {
return this.coordToPoint([
this._radiusAxis.dataToRadius(data[0], clamp),
this._angleAxis.dataToAngle(data[1], clamp)
]);
},
/**
* Convert a (x, y) point to data
* @param {Array.<number>} point
* @param {boolean} [clamp=false]
* @return {Array.<number>}
*/
pointToData: function (point, clamp) {
var coord = this.pointToCoord(point);
return [
this._radiusAxis.radiusToData(coord[0], clamp),
this._angleAxis.angleToData(coord[1], clamp)
];
},
/**
* Convert a (x, y) point to (radius, angle) coord
* @param {Array.<number>} point
* @return {Array.<number>}
*/
pointToCoord: function (point) {
var dx = point[0] - this.cx;
var dy = point[1] - this.cy;
var angleAxis = this.getAngleAxis();
var extent = angleAxis.getExtent();
var minAngle = Math.min(extent[0], extent[1]);
var maxAngle = Math.max(extent[0], extent[1]);
// Fix fixed extent in polarCreator
// FIXME
angleAxis.inverse
? (minAngle = maxAngle - 360)
: (maxAngle = minAngle + 360);
var radius = Math.sqrt(dx * dx + dy * dy);
dx /= radius;
dy /= radius;
var radian = Math.atan2(-dy, dx) / Math.PI * 180;
// move to angleExtent
var dir = radian < minAngle ? 1 : -1;
while (radian < minAngle || radian > maxAngle) {
radian += dir * 360;
}
return [radius, radian];
},
/**
* Convert a (radius, angle) coord to (x, y) point
* @param {Array.<number>} coord
* @return {Array.<number>}
*/
coordToPoint: function (coord) {
var radius = coord[0];
var radian = coord[1] / 180 * Math.PI;
var x = Math.cos(radian) * radius + this.cx;
// Inverse the y
var y = -Math.sin(radian) * radius + this.cy;
return [x, y];
}
};
return Polar;
});

View File

@@ -0,0 +1,46 @@
define(function (require) {
'use strict';
require('./AxisModel');
require('../../echarts').extendComponentModel({
type: 'polar',
dependencies: ['polarAxis', 'angleAxis'],
/**
* @type {module:echarts/coord/polar/Polar}
*/
coordinateSystem: null,
/**
* @param {string} axisType
* @return {module:echarts/coord/polar/AxisModel}
*/
findAxisModel: function (axisType) {
var angleAxisModel;
var ecModel = this.ecModel;
ecModel.eachComponent(axisType, function (axisModel) {
if (ecModel.getComponent(
'polar', axisModel.getShallow('polarIndex')
) === this) {
angleAxisModel = axisModel;
}
}, this);
return angleAxisModel;
},
defaultOption: {
zlevel: 0,
z: 0,
center: ['50%', '50%'],
radius: '80%'
}
});
});

View File

@@ -0,0 +1,34 @@
define(function (require) {
'use strict';
var zrUtil = require('zrender/core/util');
var Axis = require('../Axis');
function RadiusAxis(scale, radiusExtent) {
Axis.call(this, 'radius', scale, radiusExtent);
/**
* Axis type
* - 'category'
* - 'value'
* - 'time'
* - 'log'
* @type {string}
*/
this.type = 'category';
}
RadiusAxis.prototype = {
constructor: RadiusAxis,
dataToRadius: Axis.prototype.dataToCoord,
radiusToData: Axis.prototype.coordToData
};
zrUtil.inherits(RadiusAxis, Axis);
return RadiusAxis;
});

View File

@@ -0,0 +1,131 @@
// TODO Axis scale
define(function (require) {
var Polar = require('./Polar');
var numberUtil = require('../../util/number');
var axisHelper = require('../../coord/axisHelper');
var niceScaleExtent = axisHelper.niceScaleExtent;
// 依赖 PolarModel 做预处理
require('./PolarModel');
/**
* Resize method bound to the polar
* @param {module:echarts/coord/polar/PolarModel} polarModel
* @param {module:echarts/ExtensionAPI} api
*/
function resizePolar(polarModel, api) {
var center = polarModel.get('center');
var radius = polarModel.get('radius');
var width = api.getWidth();
var height = api.getHeight();
var parsePercent = numberUtil.parsePercent;
this.cx = parsePercent(center[0], width);
this.cy = parsePercent(center[1], height);
var radiusAxis = this.getRadiusAxis();
var size = Math.min(width, height) / 2;
// var idx = radiusAxis.inverse ? 1 : 0;
radiusAxis.setExtent(0, parsePercent(radius, size));
}
/**
* Update polar
*/
function updatePolarScale(ecModel, api) {
var polar = this;
var angleAxis = polar.getAngleAxis();
var radiusAxis = polar.getRadiusAxis();
// Reset scale
angleAxis.scale.setExtent(Infinity, -Infinity);
radiusAxis.scale.setExtent(Infinity, -Infinity);
ecModel.eachSeries(function (seriesModel) {
if (seriesModel.coordinateSystem === polar) {
var data = seriesModel.getData();
radiusAxis.scale.unionExtent(
data.getDataExtent('radius', radiusAxis.type !== 'category')
);
angleAxis.scale.unionExtent(
data.getDataExtent('angle', angleAxis.type !== 'category')
);
}
});
niceScaleExtent(angleAxis, angleAxis.model);
niceScaleExtent(radiusAxis, radiusAxis.model);
// Fix extent of category angle axis
if (angleAxis.type === 'category' && !angleAxis.onBand) {
var extent = angleAxis.getExtent();
var diff = 360 / angleAxis.scale.count();
angleAxis.inverse ? (extent[1] += diff) : (extent[1] -= diff);
angleAxis.setExtent(extent[0], extent[1]);
}
}
/**
* Set common axis properties
* @param {module:echarts/coord/polar/AngleAxis|module:echarts/coord/polar/RadiusAxis}
* @param {module:echarts/coord/polar/AxisModel}
* @inner
*/
function setAxis(axis, axisModel) {
axis.type = axisModel.get('type');
axis.scale = axisHelper.createScaleByModel(axisModel);
axis.onBand = axisModel.get('boundaryGap') && axis.type === 'category';
// FIXME Radius axis not support inverse axis
if (axisModel.mainType === 'angleAxis') {
var startAngle = axisModel.get('startAngle');
axis.inverse = axisModel.get('inverse') ^ axisModel.get('clockwise');
axis.setExtent(startAngle, startAngle + (axis.inverse ? -360 : 360));
}
// Inject axis instance
axisModel.axis = axis;
axis.model = axisModel;
}
var polarCreator = {
dimensions: Polar.prototype.dimensions,
create: function (ecModel, api) {
var polarList = [];
ecModel.eachComponent('polar', function (polarModel, idx) {
var polar = new Polar(idx);
// Inject resize and update method
polar.resize = resizePolar;
polar.update = updatePolarScale;
var radiusAxis = polar.getRadiusAxis();
var angleAxis = polar.getAngleAxis();
var radiusAxisModel = polarModel.findAxisModel('radiusAxis');
var angleAxisModel = polarModel.findAxisModel('angleAxis');
setAxis(radiusAxis, radiusAxisModel);
setAxis(angleAxis, angleAxisModel);
polar.resize(polarModel, api);
polarList.push(polar);
polarModel.coordinateSystem = polar;
});
// Inject coordinateSystem to series
ecModel.eachSeries(function (seriesModel) {
if (seriesModel.get('coordinateSystem') === 'polar') {
seriesModel.coordinateSystem = polarList[seriesModel.get('polarIndex')];
}
});
return polarList;
}
};
require('../../CoordinateSystem').register('polar', polarCreator);
});