逐步完成前后端服务器
This commit is contained in:
267
frontend/node_modules/echarts/lib/scale/Interval.js
generated
vendored
Normal file
267
frontend/node_modules/echarts/lib/scale/Interval.js
generated
vendored
Normal file
@ -0,0 +1,267 @@
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
import { __extends } from "tslib";
|
||||
import * as numberUtil from '../util/number.js';
|
||||
import * as formatUtil from '../util/format.js';
|
||||
import Scale from './Scale.js';
|
||||
import * as helper from './helper.js';
|
||||
var roundNumber = numberUtil.round;
|
||||
var IntervalScale = /** @class */function (_super) {
|
||||
__extends(IntervalScale, _super);
|
||||
function IntervalScale() {
|
||||
var _this = _super !== null && _super.apply(this, arguments) || this;
|
||||
_this.type = 'interval';
|
||||
// Step is calculated in adjustExtent.
|
||||
_this._interval = 0;
|
||||
_this._intervalPrecision = 2;
|
||||
return _this;
|
||||
}
|
||||
IntervalScale.prototype.parse = function (val) {
|
||||
return val;
|
||||
};
|
||||
IntervalScale.prototype.contain = function (val) {
|
||||
return helper.contain(val, this._extent);
|
||||
};
|
||||
IntervalScale.prototype.normalize = function (val) {
|
||||
return helper.normalize(val, this._extent);
|
||||
};
|
||||
IntervalScale.prototype.scale = function (val) {
|
||||
return helper.scale(val, this._extent);
|
||||
};
|
||||
IntervalScale.prototype.setExtent = function (start, end) {
|
||||
var thisExtent = this._extent;
|
||||
// start,end may be a Number like '25',so...
|
||||
if (!isNaN(start)) {
|
||||
thisExtent[0] = parseFloat(start);
|
||||
}
|
||||
if (!isNaN(end)) {
|
||||
thisExtent[1] = parseFloat(end);
|
||||
}
|
||||
};
|
||||
IntervalScale.prototype.unionExtent = function (other) {
|
||||
var extent = this._extent;
|
||||
other[0] < extent[0] && (extent[0] = other[0]);
|
||||
other[1] > extent[1] && (extent[1] = other[1]);
|
||||
// unionExtent may called by it's sub classes
|
||||
this.setExtent(extent[0], extent[1]);
|
||||
};
|
||||
IntervalScale.prototype.getInterval = function () {
|
||||
return this._interval;
|
||||
};
|
||||
IntervalScale.prototype.setInterval = function (interval) {
|
||||
this._interval = interval;
|
||||
// Dropped auto calculated niceExtent and use user-set extent.
|
||||
// We assume user wants to set both interval, min, max to get a better result.
|
||||
this._niceExtent = this._extent.slice();
|
||||
this._intervalPrecision = helper.getIntervalPrecision(interval);
|
||||
};
|
||||
/**
|
||||
* @param expandToNicedExtent Whether expand the ticks to niced extent.
|
||||
*/
|
||||
IntervalScale.prototype.getTicks = function (expandToNicedExtent) {
|
||||
var interval = this._interval;
|
||||
var extent = this._extent;
|
||||
var niceTickExtent = this._niceExtent;
|
||||
var intervalPrecision = this._intervalPrecision;
|
||||
var ticks = [];
|
||||
// If interval is 0, return [];
|
||||
if (!interval) {
|
||||
return ticks;
|
||||
}
|
||||
// Consider this case: using dataZoom toolbox, zoom and zoom.
|
||||
var safeLimit = 10000;
|
||||
if (extent[0] < niceTickExtent[0]) {
|
||||
if (expandToNicedExtent) {
|
||||
ticks.push({
|
||||
value: roundNumber(niceTickExtent[0] - interval, intervalPrecision)
|
||||
});
|
||||
} else {
|
||||
ticks.push({
|
||||
value: extent[0]
|
||||
});
|
||||
}
|
||||
}
|
||||
var tick = niceTickExtent[0];
|
||||
while (tick <= niceTickExtent[1]) {
|
||||
ticks.push({
|
||||
value: tick
|
||||
});
|
||||
// Avoid rounding error
|
||||
tick = roundNumber(tick + interval, intervalPrecision);
|
||||
if (tick === ticks[ticks.length - 1].value) {
|
||||
// Consider out of safe float point, e.g.,
|
||||
// -3711126.9907707 + 2e-10 === -3711126.9907707
|
||||
break;
|
||||
}
|
||||
if (ticks.length > safeLimit) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
// Consider this case: the last item of ticks is smaller
|
||||
// than niceTickExtent[1] and niceTickExtent[1] === extent[1].
|
||||
var lastNiceTick = ticks.length ? ticks[ticks.length - 1].value : niceTickExtent[1];
|
||||
if (extent[1] > lastNiceTick) {
|
||||
if (expandToNicedExtent) {
|
||||
ticks.push({
|
||||
value: roundNumber(lastNiceTick + interval, intervalPrecision)
|
||||
});
|
||||
} else {
|
||||
ticks.push({
|
||||
value: extent[1]
|
||||
});
|
||||
}
|
||||
}
|
||||
return ticks;
|
||||
};
|
||||
IntervalScale.prototype.getMinorTicks = function (splitNumber) {
|
||||
var ticks = this.getTicks(true);
|
||||
var minorTicks = [];
|
||||
var extent = this.getExtent();
|
||||
for (var i = 1; i < ticks.length; i++) {
|
||||
var nextTick = ticks[i];
|
||||
var prevTick = ticks[i - 1];
|
||||
var count = 0;
|
||||
var minorTicksGroup = [];
|
||||
var interval = nextTick.value - prevTick.value;
|
||||
var minorInterval = interval / splitNumber;
|
||||
while (count < splitNumber - 1) {
|
||||
var minorTick = roundNumber(prevTick.value + (count + 1) * minorInterval);
|
||||
// For the first and last interval. The count may be less than splitNumber.
|
||||
if (minorTick > extent[0] && minorTick < extent[1]) {
|
||||
minorTicksGroup.push(minorTick);
|
||||
}
|
||||
count++;
|
||||
}
|
||||
minorTicks.push(minorTicksGroup);
|
||||
}
|
||||
return minorTicks;
|
||||
};
|
||||
/**
|
||||
* @param opt.precision If 'auto', use nice presision.
|
||||
* @param opt.pad returns 1.50 but not 1.5 if precision is 2.
|
||||
*/
|
||||
IntervalScale.prototype.getLabel = function (data, opt) {
|
||||
if (data == null) {
|
||||
return '';
|
||||
}
|
||||
var precision = opt && opt.precision;
|
||||
if (precision == null) {
|
||||
precision = numberUtil.getPrecision(data.value) || 0;
|
||||
} else if (precision === 'auto') {
|
||||
// Should be more precise then tick.
|
||||
precision = this._intervalPrecision;
|
||||
}
|
||||
// (1) If `precision` is set, 12.005 should be display as '12.00500'.
|
||||
// (2) Use roundNumber (toFixed) to avoid scientific notation like '3.5e-7'.
|
||||
var dataNum = roundNumber(data.value, precision, true);
|
||||
return formatUtil.addCommas(dataNum);
|
||||
};
|
||||
/**
|
||||
* @param splitNumber By default `5`.
|
||||
*/
|
||||
IntervalScale.prototype.calcNiceTicks = function (splitNumber, minInterval, maxInterval) {
|
||||
splitNumber = splitNumber || 5;
|
||||
var extent = this._extent;
|
||||
var span = extent[1] - extent[0];
|
||||
if (!isFinite(span)) {
|
||||
return;
|
||||
}
|
||||
// User may set axis min 0 and data are all negative
|
||||
// FIXME If it needs to reverse ?
|
||||
if (span < 0) {
|
||||
span = -span;
|
||||
extent.reverse();
|
||||
}
|
||||
var result = helper.intervalScaleNiceTicks(extent, splitNumber, minInterval, maxInterval);
|
||||
this._intervalPrecision = result.intervalPrecision;
|
||||
this._interval = result.interval;
|
||||
this._niceExtent = result.niceTickExtent;
|
||||
};
|
||||
IntervalScale.prototype.calcNiceExtent = function (opt) {
|
||||
var extent = this._extent;
|
||||
// If extent start and end are same, expand them
|
||||
if (extent[0] === extent[1]) {
|
||||
if (extent[0] !== 0) {
|
||||
// Expand extent
|
||||
// Note that extents can be both negative. See #13154
|
||||
var expandSize = Math.abs(extent[0]);
|
||||
// In the fowllowing case
|
||||
// Axis has been fixed max 100
|
||||
// Plus data are all 100 and axis extent are [100, 100].
|
||||
// Extend to the both side will cause expanded max is larger than fixed max.
|
||||
// So only expand to the smaller side.
|
||||
if (!opt.fixMax) {
|
||||
extent[1] += expandSize / 2;
|
||||
extent[0] -= expandSize / 2;
|
||||
} else {
|
||||
extent[0] -= expandSize / 2;
|
||||
}
|
||||
} else {
|
||||
extent[1] = 1;
|
||||
}
|
||||
}
|
||||
var span = extent[1] - extent[0];
|
||||
// If there are no data and extent are [Infinity, -Infinity]
|
||||
if (!isFinite(span)) {
|
||||
extent[0] = 0;
|
||||
extent[1] = 1;
|
||||
}
|
||||
this.calcNiceTicks(opt.splitNumber, opt.minInterval, opt.maxInterval);
|
||||
// let extent = this._extent;
|
||||
var interval = this._interval;
|
||||
if (!opt.fixMin) {
|
||||
extent[0] = roundNumber(Math.floor(extent[0] / interval) * interval);
|
||||
}
|
||||
if (!opt.fixMax) {
|
||||
extent[1] = roundNumber(Math.ceil(extent[1] / interval) * interval);
|
||||
}
|
||||
};
|
||||
IntervalScale.prototype.setNiceExtent = function (min, max) {
|
||||
this._niceExtent = [min, max];
|
||||
};
|
||||
IntervalScale.type = 'interval';
|
||||
return IntervalScale;
|
||||
}(Scale);
|
||||
Scale.registerClass(IntervalScale);
|
||||
export default IntervalScale;
|
178
frontend/node_modules/echarts/lib/scale/Log.js
generated
vendored
Normal file
178
frontend/node_modules/echarts/lib/scale/Log.js
generated
vendored
Normal file
@ -0,0 +1,178 @@
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
import { __extends } from "tslib";
|
||||
import * as zrUtil from 'zrender/lib/core/util.js';
|
||||
import Scale from './Scale.js';
|
||||
import * as numberUtil from '../util/number.js';
|
||||
import * as scaleHelper from './helper.js';
|
||||
// Use some method of IntervalScale
|
||||
import IntervalScale from './Interval.js';
|
||||
var scaleProto = Scale.prototype;
|
||||
// FIXME:TS refactor: not good to call it directly with `this`?
|
||||
var intervalScaleProto = IntervalScale.prototype;
|
||||
var roundingErrorFix = numberUtil.round;
|
||||
var mathFloor = Math.floor;
|
||||
var mathCeil = Math.ceil;
|
||||
var mathPow = Math.pow;
|
||||
var mathLog = Math.log;
|
||||
var LogScale = /** @class */function (_super) {
|
||||
__extends(LogScale, _super);
|
||||
function LogScale() {
|
||||
var _this = _super !== null && _super.apply(this, arguments) || this;
|
||||
_this.type = 'log';
|
||||
_this.base = 10;
|
||||
_this._originalScale = new IntervalScale();
|
||||
// FIXME:TS actually used by `IntervalScale`
|
||||
_this._interval = 0;
|
||||
return _this;
|
||||
}
|
||||
/**
|
||||
* @param Whether expand the ticks to niced extent.
|
||||
*/
|
||||
LogScale.prototype.getTicks = function (expandToNicedExtent) {
|
||||
var originalScale = this._originalScale;
|
||||
var extent = this._extent;
|
||||
var originalExtent = originalScale.getExtent();
|
||||
var ticks = intervalScaleProto.getTicks.call(this, expandToNicedExtent);
|
||||
return zrUtil.map(ticks, function (tick) {
|
||||
var val = tick.value;
|
||||
var powVal = numberUtil.round(mathPow(this.base, val));
|
||||
// Fix #4158
|
||||
powVal = val === extent[0] && this._fixMin ? fixRoundingError(powVal, originalExtent[0]) : powVal;
|
||||
powVal = val === extent[1] && this._fixMax ? fixRoundingError(powVal, originalExtent[1]) : powVal;
|
||||
return {
|
||||
value: powVal
|
||||
};
|
||||
}, this);
|
||||
};
|
||||
LogScale.prototype.setExtent = function (start, end) {
|
||||
var base = mathLog(this.base);
|
||||
// log(-Infinity) is NaN, so safe guard here
|
||||
start = mathLog(Math.max(0, start)) / base;
|
||||
end = mathLog(Math.max(0, end)) / base;
|
||||
intervalScaleProto.setExtent.call(this, start, end);
|
||||
};
|
||||
/**
|
||||
* @return {number} end
|
||||
*/
|
||||
LogScale.prototype.getExtent = function () {
|
||||
var base = this.base;
|
||||
var extent = scaleProto.getExtent.call(this);
|
||||
extent[0] = mathPow(base, extent[0]);
|
||||
extent[1] = mathPow(base, extent[1]);
|
||||
// Fix #4158
|
||||
var originalScale = this._originalScale;
|
||||
var originalExtent = originalScale.getExtent();
|
||||
this._fixMin && (extent[0] = fixRoundingError(extent[0], originalExtent[0]));
|
||||
this._fixMax && (extent[1] = fixRoundingError(extent[1], originalExtent[1]));
|
||||
return extent;
|
||||
};
|
||||
LogScale.prototype.unionExtent = function (extent) {
|
||||
this._originalScale.unionExtent(extent);
|
||||
var base = this.base;
|
||||
extent[0] = mathLog(extent[0]) / mathLog(base);
|
||||
extent[1] = mathLog(extent[1]) / mathLog(base);
|
||||
scaleProto.unionExtent.call(this, extent);
|
||||
};
|
||||
LogScale.prototype.unionExtentFromData = function (data, dim) {
|
||||
// TODO
|
||||
// filter value that <= 0
|
||||
this.unionExtent(data.getApproximateExtent(dim));
|
||||
};
|
||||
/**
|
||||
* Update interval and extent of intervals for nice ticks
|
||||
* @param approxTickNum default 10 Given approx tick number
|
||||
*/
|
||||
LogScale.prototype.calcNiceTicks = function (approxTickNum) {
|
||||
approxTickNum = approxTickNum || 10;
|
||||
var extent = this._extent;
|
||||
var span = extent[1] - extent[0];
|
||||
if (span === Infinity || span <= 0) {
|
||||
return;
|
||||
}
|
||||
var interval = numberUtil.quantity(span);
|
||||
var err = approxTickNum / span * interval;
|
||||
// Filter ticks to get closer to the desired count.
|
||||
if (err <= 0.5) {
|
||||
interval *= 10;
|
||||
}
|
||||
// Interval should be integer
|
||||
while (!isNaN(interval) && Math.abs(interval) < 1 && Math.abs(interval) > 0) {
|
||||
interval *= 10;
|
||||
}
|
||||
var niceExtent = [numberUtil.round(mathCeil(extent[0] / interval) * interval), numberUtil.round(mathFloor(extent[1] / interval) * interval)];
|
||||
this._interval = interval;
|
||||
this._niceExtent = niceExtent;
|
||||
};
|
||||
LogScale.prototype.calcNiceExtent = function (opt) {
|
||||
intervalScaleProto.calcNiceExtent.call(this, opt);
|
||||
this._fixMin = opt.fixMin;
|
||||
this._fixMax = opt.fixMax;
|
||||
};
|
||||
LogScale.prototype.parse = function (val) {
|
||||
return val;
|
||||
};
|
||||
LogScale.prototype.contain = function (val) {
|
||||
val = mathLog(val) / mathLog(this.base);
|
||||
return scaleHelper.contain(val, this._extent);
|
||||
};
|
||||
LogScale.prototype.normalize = function (val) {
|
||||
val = mathLog(val) / mathLog(this.base);
|
||||
return scaleHelper.normalize(val, this._extent);
|
||||
};
|
||||
LogScale.prototype.scale = function (val) {
|
||||
val = scaleHelper.scale(val, this._extent);
|
||||
return mathPow(this.base, val);
|
||||
};
|
||||
LogScale.type = 'log';
|
||||
return LogScale;
|
||||
}(Scale);
|
||||
var proto = LogScale.prototype;
|
||||
proto.getMinorTicks = intervalScaleProto.getMinorTicks;
|
||||
proto.getLabel = intervalScaleProto.getLabel;
|
||||
function fixRoundingError(val, originalVal) {
|
||||
return roundingErrorFix(val, numberUtil.getPrecision(originalVal));
|
||||
}
|
||||
Scale.registerClass(LogScale);
|
||||
export default LogScale;
|
214
frontend/node_modules/echarts/lib/scale/Ordinal.js
generated
vendored
Normal file
214
frontend/node_modules/echarts/lib/scale/Ordinal.js
generated
vendored
Normal file
@ -0,0 +1,214 @@
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
import { __extends } from "tslib";
|
||||
/**
|
||||
* Linear continuous scale
|
||||
* http://en.wikipedia.org/wiki/Level_of_measurement
|
||||
*/
|
||||
// FIXME only one data
|
||||
import Scale from './Scale.js';
|
||||
import OrdinalMeta from '../data/OrdinalMeta.js';
|
||||
import * as scaleHelper from './helper.js';
|
||||
import { isArray, map, isObject, isString } from 'zrender/lib/core/util.js';
|
||||
var OrdinalScale = /** @class */function (_super) {
|
||||
__extends(OrdinalScale, _super);
|
||||
function OrdinalScale(setting) {
|
||||
var _this = _super.call(this, setting) || this;
|
||||
_this.type = 'ordinal';
|
||||
var ordinalMeta = _this.getSetting('ordinalMeta');
|
||||
// Caution: Should not use instanceof, consider ec-extensions using
|
||||
// import approach to get OrdinalMeta class.
|
||||
if (!ordinalMeta) {
|
||||
ordinalMeta = new OrdinalMeta({});
|
||||
}
|
||||
if (isArray(ordinalMeta)) {
|
||||
ordinalMeta = new OrdinalMeta({
|
||||
categories: map(ordinalMeta, function (item) {
|
||||
return isObject(item) ? item.value : item;
|
||||
})
|
||||
});
|
||||
}
|
||||
_this._ordinalMeta = ordinalMeta;
|
||||
_this._extent = _this.getSetting('extent') || [0, ordinalMeta.categories.length - 1];
|
||||
return _this;
|
||||
}
|
||||
OrdinalScale.prototype.parse = function (val) {
|
||||
// Caution: Math.round(null) will return `0` rather than `NaN`
|
||||
if (val == null) {
|
||||
return NaN;
|
||||
}
|
||||
return isString(val) ? this._ordinalMeta.getOrdinal(val)
|
||||
// val might be float.
|
||||
: Math.round(val);
|
||||
};
|
||||
OrdinalScale.prototype.contain = function (rank) {
|
||||
rank = this.parse(rank);
|
||||
return scaleHelper.contain(rank, this._extent) && this._ordinalMeta.categories[rank] != null;
|
||||
};
|
||||
/**
|
||||
* Normalize given rank or name to linear [0, 1]
|
||||
* @param val raw ordinal number.
|
||||
* @return normalized value in [0, 1].
|
||||
*/
|
||||
OrdinalScale.prototype.normalize = function (val) {
|
||||
val = this._getTickNumber(this.parse(val));
|
||||
return scaleHelper.normalize(val, this._extent);
|
||||
};
|
||||
/**
|
||||
* @param val normalized value in [0, 1].
|
||||
* @return raw ordinal number.
|
||||
*/
|
||||
OrdinalScale.prototype.scale = function (val) {
|
||||
val = Math.round(scaleHelper.scale(val, this._extent));
|
||||
return this.getRawOrdinalNumber(val);
|
||||
};
|
||||
OrdinalScale.prototype.getTicks = function () {
|
||||
var ticks = [];
|
||||
var extent = this._extent;
|
||||
var rank = extent[0];
|
||||
while (rank <= extent[1]) {
|
||||
ticks.push({
|
||||
value: rank
|
||||
});
|
||||
rank++;
|
||||
}
|
||||
return ticks;
|
||||
};
|
||||
OrdinalScale.prototype.getMinorTicks = function (splitNumber) {
|
||||
// Not support.
|
||||
return;
|
||||
};
|
||||
/**
|
||||
* @see `Ordinal['_ordinalNumbersByTick']`
|
||||
*/
|
||||
OrdinalScale.prototype.setSortInfo = function (info) {
|
||||
if (info == null) {
|
||||
this._ordinalNumbersByTick = this._ticksByOrdinalNumber = null;
|
||||
return;
|
||||
}
|
||||
var infoOrdinalNumbers = info.ordinalNumbers;
|
||||
var ordinalsByTick = this._ordinalNumbersByTick = [];
|
||||
var ticksByOrdinal = this._ticksByOrdinalNumber = [];
|
||||
// Unnecessary support negative tick in `realtimeSort`.
|
||||
var tickNum = 0;
|
||||
var allCategoryLen = this._ordinalMeta.categories.length;
|
||||
for (var len = Math.min(allCategoryLen, infoOrdinalNumbers.length); tickNum < len; ++tickNum) {
|
||||
var ordinalNumber = infoOrdinalNumbers[tickNum];
|
||||
ordinalsByTick[tickNum] = ordinalNumber;
|
||||
ticksByOrdinal[ordinalNumber] = tickNum;
|
||||
}
|
||||
// Handle that `series.data` only covers part of the `axis.category.data`.
|
||||
var unusedOrdinal = 0;
|
||||
for (; tickNum < allCategoryLen; ++tickNum) {
|
||||
while (ticksByOrdinal[unusedOrdinal] != null) {
|
||||
unusedOrdinal++;
|
||||
}
|
||||
;
|
||||
ordinalsByTick.push(unusedOrdinal);
|
||||
ticksByOrdinal[unusedOrdinal] = tickNum;
|
||||
}
|
||||
};
|
||||
OrdinalScale.prototype._getTickNumber = function (ordinal) {
|
||||
var ticksByOrdinalNumber = this._ticksByOrdinalNumber;
|
||||
// also support ordinal out of range of `ordinalMeta.categories.length`,
|
||||
// where ordinal numbers are used as tick value directly.
|
||||
return ticksByOrdinalNumber && ordinal >= 0 && ordinal < ticksByOrdinalNumber.length ? ticksByOrdinalNumber[ordinal] : ordinal;
|
||||
};
|
||||
/**
|
||||
* @usage
|
||||
* ```js
|
||||
* const ordinalNumber = ordinalScale.getRawOrdinalNumber(tickVal);
|
||||
*
|
||||
* // case0
|
||||
* const rawOrdinalValue = axisModel.getCategories()[ordinalNumber];
|
||||
* // case1
|
||||
* const rawOrdinalValue = this._ordinalMeta.categories[ordinalNumber];
|
||||
* // case2
|
||||
* const coord = axis.dataToCoord(ordinalNumber);
|
||||
* ```
|
||||
*
|
||||
* @param {OrdinalNumber} tickNumber index of display
|
||||
*/
|
||||
OrdinalScale.prototype.getRawOrdinalNumber = function (tickNumber) {
|
||||
var ordinalNumbersByTick = this._ordinalNumbersByTick;
|
||||
// tickNumber may be out of range, e.g., when axis max is larger than `ordinalMeta.categories.length`.,
|
||||
// where ordinal numbers are used as tick value directly.
|
||||
return ordinalNumbersByTick && tickNumber >= 0 && tickNumber < ordinalNumbersByTick.length ? ordinalNumbersByTick[tickNumber] : tickNumber;
|
||||
};
|
||||
/**
|
||||
* Get item on tick
|
||||
*/
|
||||
OrdinalScale.prototype.getLabel = function (tick) {
|
||||
if (!this.isBlank()) {
|
||||
var ordinalNumber = this.getRawOrdinalNumber(tick.value);
|
||||
var cateogry = this._ordinalMeta.categories[ordinalNumber];
|
||||
// Note that if no data, ordinalMeta.categories is an empty array.
|
||||
// Return empty if it's not exist.
|
||||
return cateogry == null ? '' : cateogry + '';
|
||||
}
|
||||
};
|
||||
OrdinalScale.prototype.count = function () {
|
||||
return this._extent[1] - this._extent[0] + 1;
|
||||
};
|
||||
OrdinalScale.prototype.unionExtentFromData = function (data, dim) {
|
||||
this.unionExtent(data.getApproximateExtent(dim));
|
||||
};
|
||||
/**
|
||||
* @override
|
||||
* If value is in extent range
|
||||
*/
|
||||
OrdinalScale.prototype.isInExtentRange = function (value) {
|
||||
value = this._getTickNumber(value);
|
||||
return this._extent[0] <= value && this._extent[1] >= value;
|
||||
};
|
||||
OrdinalScale.prototype.getOrdinalMeta = function () {
|
||||
return this._ordinalMeta;
|
||||
};
|
||||
OrdinalScale.prototype.calcNiceTicks = function () {};
|
||||
OrdinalScale.prototype.calcNiceExtent = function () {};
|
||||
OrdinalScale.type = 'ordinal';
|
||||
return OrdinalScale;
|
||||
}(Scale);
|
||||
Scale.registerClass(OrdinalScale);
|
||||
export default OrdinalScale;
|
112
frontend/node_modules/echarts/lib/scale/Scale.js
generated
vendored
Normal file
112
frontend/node_modules/echarts/lib/scale/Scale.js
generated
vendored
Normal file
@ -0,0 +1,112 @@
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
import * as clazzUtil from '../util/clazz.js';
|
||||
var Scale = /** @class */function () {
|
||||
function Scale(setting) {
|
||||
this._setting = setting || {};
|
||||
this._extent = [Infinity, -Infinity];
|
||||
}
|
||||
Scale.prototype.getSetting = function (name) {
|
||||
return this._setting[name];
|
||||
};
|
||||
/**
|
||||
* Set extent from data
|
||||
*/
|
||||
Scale.prototype.unionExtent = function (other) {
|
||||
var extent = this._extent;
|
||||
other[0] < extent[0] && (extent[0] = other[0]);
|
||||
other[1] > extent[1] && (extent[1] = other[1]);
|
||||
// not setExtent because in log axis it may transformed to power
|
||||
// this.setExtent(extent[0], extent[1]);
|
||||
};
|
||||
/**
|
||||
* Set extent from data
|
||||
*/
|
||||
Scale.prototype.unionExtentFromData = function (data, dim) {
|
||||
this.unionExtent(data.getApproximateExtent(dim));
|
||||
};
|
||||
/**
|
||||
* Get extent
|
||||
*
|
||||
* Extent is always in increase order.
|
||||
*/
|
||||
Scale.prototype.getExtent = function () {
|
||||
return this._extent.slice();
|
||||
};
|
||||
/**
|
||||
* Set extent
|
||||
*/
|
||||
Scale.prototype.setExtent = function (start, end) {
|
||||
var thisExtent = this._extent;
|
||||
if (!isNaN(start)) {
|
||||
thisExtent[0] = start;
|
||||
}
|
||||
if (!isNaN(end)) {
|
||||
thisExtent[1] = end;
|
||||
}
|
||||
};
|
||||
/**
|
||||
* If value is in extent range
|
||||
*/
|
||||
Scale.prototype.isInExtentRange = function (value) {
|
||||
return this._extent[0] <= value && this._extent[1] >= value;
|
||||
};
|
||||
/**
|
||||
* When axis extent depends on data and no data exists,
|
||||
* axis ticks should not be drawn, which is named 'blank'.
|
||||
*/
|
||||
Scale.prototype.isBlank = function () {
|
||||
return this._isBlank;
|
||||
};
|
||||
/**
|
||||
* When axis extent depends on data and no data exists,
|
||||
* axis ticks should not be drawn, which is named 'blank'.
|
||||
*/
|
||||
Scale.prototype.setBlank = function (isBlank) {
|
||||
this._isBlank = isBlank;
|
||||
};
|
||||
return Scale;
|
||||
}();
|
||||
clazzUtil.enableClassManagement(Scale);
|
||||
export default Scale;
|
509
frontend/node_modules/echarts/lib/scale/Time.js
generated
vendored
Normal file
509
frontend/node_modules/echarts/lib/scale/Time.js
generated
vendored
Normal file
@ -0,0 +1,509 @@
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
import { __extends } from "tslib";
|
||||
/*
|
||||
* A third-party license is embedded for some of the code in this file:
|
||||
* The "scaleLevels" was originally copied from "d3.js" with some
|
||||
* modifications made for this project.
|
||||
* (See more details in the comment on the definition of "scaleLevels" below.)
|
||||
* The use of the source code of this file is also subject to the terms
|
||||
* and consitions of the license of "d3.js" (BSD-3Clause, see
|
||||
* </licenses/LICENSE-d3>).
|
||||
*/
|
||||
// [About UTC and local time zone]:
|
||||
// In most cases, `number.parseDate` will treat input data string as local time
|
||||
// (except time zone is specified in time string). And `format.formateTime` returns
|
||||
// local time by default. option.useUTC is false by default. This design has
|
||||
// considered these common cases:
|
||||
// (1) Time that is persistent in server is in UTC, but it is needed to be displayed
|
||||
// in local time by default.
|
||||
// (2) By default, the input data string (e.g., '2011-01-02') should be displayed
|
||||
// as its original time, without any time difference.
|
||||
import * as numberUtil from '../util/number.js';
|
||||
import { ONE_SECOND, ONE_MINUTE, ONE_HOUR, ONE_DAY, ONE_YEAR, format, leveledFormat, getUnitValue, timeUnits, fullLeveledFormatter, getPrimaryTimeUnit, isPrimaryTimeUnit, getDefaultFormatPrecisionOfInterval, fullYearGetterName, monthSetterName, fullYearSetterName, dateSetterName, hoursGetterName, hoursSetterName, minutesSetterName, secondsSetterName, millisecondsSetterName, monthGetterName, dateGetterName, minutesGetterName, secondsGetterName, millisecondsGetterName } from '../util/time.js';
|
||||
import * as scaleHelper from './helper.js';
|
||||
import IntervalScale from './Interval.js';
|
||||
import Scale from './Scale.js';
|
||||
import { warn } from '../util/log.js';
|
||||
import { filter, isNumber, map } from 'zrender/lib/core/util.js';
|
||||
// FIXME 公用?
|
||||
var bisect = function (a, x, lo, hi) {
|
||||
while (lo < hi) {
|
||||
var mid = lo + hi >>> 1;
|
||||
if (a[mid][1] < x) {
|
||||
lo = mid + 1;
|
||||
} else {
|
||||
hi = mid;
|
||||
}
|
||||
}
|
||||
return lo;
|
||||
};
|
||||
var TimeScale = /** @class */function (_super) {
|
||||
__extends(TimeScale, _super);
|
||||
function TimeScale(settings) {
|
||||
var _this = _super.call(this, settings) || this;
|
||||
_this.type = 'time';
|
||||
return _this;
|
||||
}
|
||||
/**
|
||||
* Get label is mainly for other components like dataZoom, tooltip.
|
||||
*/
|
||||
TimeScale.prototype.getLabel = function (tick) {
|
||||
var useUTC = this.getSetting('useUTC');
|
||||
return format(tick.value, fullLeveledFormatter[getDefaultFormatPrecisionOfInterval(getPrimaryTimeUnit(this._minLevelUnit))] || fullLeveledFormatter.second, useUTC, this.getSetting('locale'));
|
||||
};
|
||||
TimeScale.prototype.getFormattedLabel = function (tick, idx, labelFormatter) {
|
||||
var isUTC = this.getSetting('useUTC');
|
||||
var lang = this.getSetting('locale');
|
||||
return leveledFormat(tick, idx, labelFormatter, lang, isUTC);
|
||||
};
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
TimeScale.prototype.getTicks = function () {
|
||||
var interval = this._interval;
|
||||
var extent = this._extent;
|
||||
var ticks = [];
|
||||
// If interval is 0, return [];
|
||||
if (!interval) {
|
||||
return ticks;
|
||||
}
|
||||
ticks.push({
|
||||
value: extent[0],
|
||||
level: 0
|
||||
});
|
||||
var useUTC = this.getSetting('useUTC');
|
||||
var innerTicks = getIntervalTicks(this._minLevelUnit, this._approxInterval, useUTC, extent);
|
||||
ticks = ticks.concat(innerTicks);
|
||||
ticks.push({
|
||||
value: extent[1],
|
||||
level: 0
|
||||
});
|
||||
return ticks;
|
||||
};
|
||||
TimeScale.prototype.calcNiceExtent = function (opt) {
|
||||
var extent = this._extent;
|
||||
// If extent start and end are same, expand them
|
||||
if (extent[0] === extent[1]) {
|
||||
// Expand extent
|
||||
extent[0] -= ONE_DAY;
|
||||
extent[1] += ONE_DAY;
|
||||
}
|
||||
// If there are no data and extent are [Infinity, -Infinity]
|
||||
if (extent[1] === -Infinity && extent[0] === Infinity) {
|
||||
var d = new Date();
|
||||
extent[1] = +new Date(d.getFullYear(), d.getMonth(), d.getDate());
|
||||
extent[0] = extent[1] - ONE_DAY;
|
||||
}
|
||||
this.calcNiceTicks(opt.splitNumber, opt.minInterval, opt.maxInterval);
|
||||
};
|
||||
TimeScale.prototype.calcNiceTicks = function (approxTickNum, minInterval, maxInterval) {
|
||||
approxTickNum = approxTickNum || 10;
|
||||
var extent = this._extent;
|
||||
var span = extent[1] - extent[0];
|
||||
this._approxInterval = span / approxTickNum;
|
||||
if (minInterval != null && this._approxInterval < minInterval) {
|
||||
this._approxInterval = minInterval;
|
||||
}
|
||||
if (maxInterval != null && this._approxInterval > maxInterval) {
|
||||
this._approxInterval = maxInterval;
|
||||
}
|
||||
var scaleIntervalsLen = scaleIntervals.length;
|
||||
var idx = Math.min(bisect(scaleIntervals, this._approxInterval, 0, scaleIntervalsLen), scaleIntervalsLen - 1);
|
||||
// Interval that can be used to calculate ticks
|
||||
this._interval = scaleIntervals[idx][1];
|
||||
// Min level used when picking ticks from top down.
|
||||
// We check one more level to avoid the ticks are to sparse in some case.
|
||||
this._minLevelUnit = scaleIntervals[Math.max(idx - 1, 0)][0];
|
||||
};
|
||||
TimeScale.prototype.parse = function (val) {
|
||||
// val might be float.
|
||||
return isNumber(val) ? val : +numberUtil.parseDate(val);
|
||||
};
|
||||
TimeScale.prototype.contain = function (val) {
|
||||
return scaleHelper.contain(this.parse(val), this._extent);
|
||||
};
|
||||
TimeScale.prototype.normalize = function (val) {
|
||||
return scaleHelper.normalize(this.parse(val), this._extent);
|
||||
};
|
||||
TimeScale.prototype.scale = function (val) {
|
||||
return scaleHelper.scale(val, this._extent);
|
||||
};
|
||||
TimeScale.type = 'time';
|
||||
return TimeScale;
|
||||
}(IntervalScale);
|
||||
/**
|
||||
* This implementation was originally copied from "d3.js"
|
||||
* <https://github.com/d3/d3/blob/b516d77fb8566b576088e73410437494717ada26/src/time/scale.js>
|
||||
* with some modifications made for this program.
|
||||
* See the license statement at the head of this file.
|
||||
*/
|
||||
var scaleIntervals = [
|
||||
// Format interval
|
||||
['second', ONE_SECOND], ['minute', ONE_MINUTE], ['hour', ONE_HOUR], ['quarter-day', ONE_HOUR * 6], ['half-day', ONE_HOUR * 12], ['day', ONE_DAY * 1.2], ['half-week', ONE_DAY * 3.5], ['week', ONE_DAY * 7], ['month', ONE_DAY * 31], ['quarter', ONE_DAY * 95], ['half-year', ONE_YEAR / 2], ['year', ONE_YEAR] // 1Y
|
||||
];
|
||||
function isUnitValueSame(unit, valueA, valueB, isUTC) {
|
||||
var dateA = numberUtil.parseDate(valueA);
|
||||
var dateB = numberUtil.parseDate(valueB);
|
||||
var isSame = function (unit) {
|
||||
return getUnitValue(dateA, unit, isUTC) === getUnitValue(dateB, unit, isUTC);
|
||||
};
|
||||
var isSameYear = function () {
|
||||
return isSame('year');
|
||||
};
|
||||
// const isSameHalfYear = () => isSameYear() && isSame('half-year');
|
||||
// const isSameQuater = () => isSameYear() && isSame('quarter');
|
||||
var isSameMonth = function () {
|
||||
return isSameYear() && isSame('month');
|
||||
};
|
||||
var isSameDay = function () {
|
||||
return isSameMonth() && isSame('day');
|
||||
};
|
||||
// const isSameHalfDay = () => isSameDay() && isSame('half-day');
|
||||
var isSameHour = function () {
|
||||
return isSameDay() && isSame('hour');
|
||||
};
|
||||
var isSameMinute = function () {
|
||||
return isSameHour() && isSame('minute');
|
||||
};
|
||||
var isSameSecond = function () {
|
||||
return isSameMinute() && isSame('second');
|
||||
};
|
||||
var isSameMilliSecond = function () {
|
||||
return isSameSecond() && isSame('millisecond');
|
||||
};
|
||||
switch (unit) {
|
||||
case 'year':
|
||||
return isSameYear();
|
||||
case 'month':
|
||||
return isSameMonth();
|
||||
case 'day':
|
||||
return isSameDay();
|
||||
case 'hour':
|
||||
return isSameHour();
|
||||
case 'minute':
|
||||
return isSameMinute();
|
||||
case 'second':
|
||||
return isSameSecond();
|
||||
case 'millisecond':
|
||||
return isSameMilliSecond();
|
||||
}
|
||||
}
|
||||
// const primaryUnitGetters = {
|
||||
// year: fullYearGetterName(),
|
||||
// month: monthGetterName(),
|
||||
// day: dateGetterName(),
|
||||
// hour: hoursGetterName(),
|
||||
// minute: minutesGetterName(),
|
||||
// second: secondsGetterName(),
|
||||
// millisecond: millisecondsGetterName()
|
||||
// };
|
||||
// const primaryUnitUTCGetters = {
|
||||
// year: fullYearGetterName(true),
|
||||
// month: monthGetterName(true),
|
||||
// day: dateGetterName(true),
|
||||
// hour: hoursGetterName(true),
|
||||
// minute: minutesGetterName(true),
|
||||
// second: secondsGetterName(true),
|
||||
// millisecond: millisecondsGetterName(true)
|
||||
// };
|
||||
// function moveTick(date: Date, unitName: TimeUnit, step: number, isUTC: boolean) {
|
||||
// step = step || 1;
|
||||
// switch (getPrimaryTimeUnit(unitName)) {
|
||||
// case 'year':
|
||||
// date[fullYearSetterName(isUTC)](date[fullYearGetterName(isUTC)]() + step);
|
||||
// break;
|
||||
// case 'month':
|
||||
// date[monthSetterName(isUTC)](date[monthGetterName(isUTC)]() + step);
|
||||
// break;
|
||||
// case 'day':
|
||||
// date[dateSetterName(isUTC)](date[dateGetterName(isUTC)]() + step);
|
||||
// break;
|
||||
// case 'hour':
|
||||
// date[hoursSetterName(isUTC)](date[hoursGetterName(isUTC)]() + step);
|
||||
// break;
|
||||
// case 'minute':
|
||||
// date[minutesSetterName(isUTC)](date[minutesGetterName(isUTC)]() + step);
|
||||
// break;
|
||||
// case 'second':
|
||||
// date[secondsSetterName(isUTC)](date[secondsGetterName(isUTC)]() + step);
|
||||
// break;
|
||||
// case 'millisecond':
|
||||
// date[millisecondsSetterName(isUTC)](date[millisecondsGetterName(isUTC)]() + step);
|
||||
// break;
|
||||
// }
|
||||
// return date.getTime();
|
||||
// }
|
||||
// const DATE_INTERVALS = [[8, 7.5], [4, 3.5], [2, 1.5]];
|
||||
// const MONTH_INTERVALS = [[6, 5.5], [3, 2.5], [2, 1.5]];
|
||||
// const MINUTES_SECONDS_INTERVALS = [[30, 30], [20, 20], [15, 15], [10, 10], [5, 5], [2, 2]];
|
||||
function getDateInterval(approxInterval, daysInMonth) {
|
||||
approxInterval /= ONE_DAY;
|
||||
return approxInterval > 16 ? 16
|
||||
// Math.floor(daysInMonth / 2) + 1 // In this case we only want one tick between two months.
|
||||
: approxInterval > 7.5 ? 7 // TODO week 7 or day 8?
|
||||
: approxInterval > 3.5 ? 4 : approxInterval > 1.5 ? 2 : 1;
|
||||
}
|
||||
function getMonthInterval(approxInterval) {
|
||||
var APPROX_ONE_MONTH = 30 * ONE_DAY;
|
||||
approxInterval /= APPROX_ONE_MONTH;
|
||||
return approxInterval > 6 ? 6 : approxInterval > 3 ? 3 : approxInterval > 2 ? 2 : 1;
|
||||
}
|
||||
function getHourInterval(approxInterval) {
|
||||
approxInterval /= ONE_HOUR;
|
||||
return approxInterval > 12 ? 12 : approxInterval > 6 ? 6 : approxInterval > 3.5 ? 4 : approxInterval > 2 ? 2 : 1;
|
||||
}
|
||||
function getMinutesAndSecondsInterval(approxInterval, isMinutes) {
|
||||
approxInterval /= isMinutes ? ONE_MINUTE : ONE_SECOND;
|
||||
return approxInterval > 30 ? 30 : approxInterval > 20 ? 20 : approxInterval > 15 ? 15 : approxInterval > 10 ? 10 : approxInterval > 5 ? 5 : approxInterval > 2 ? 2 : 1;
|
||||
}
|
||||
function getMillisecondsInterval(approxInterval) {
|
||||
return numberUtil.nice(approxInterval, true);
|
||||
}
|
||||
function getFirstTimestampOfUnit(date, unitName, isUTC) {
|
||||
var outDate = new Date(date);
|
||||
switch (getPrimaryTimeUnit(unitName)) {
|
||||
case 'year':
|
||||
case 'month':
|
||||
outDate[monthSetterName(isUTC)](0);
|
||||
case 'day':
|
||||
outDate[dateSetterName(isUTC)](1);
|
||||
case 'hour':
|
||||
outDate[hoursSetterName(isUTC)](0);
|
||||
case 'minute':
|
||||
outDate[minutesSetterName(isUTC)](0);
|
||||
case 'second':
|
||||
outDate[secondsSetterName(isUTC)](0);
|
||||
outDate[millisecondsSetterName(isUTC)](0);
|
||||
}
|
||||
return outDate.getTime();
|
||||
}
|
||||
function getIntervalTicks(bottomUnitName, approxInterval, isUTC, extent) {
|
||||
var safeLimit = 10000;
|
||||
var unitNames = timeUnits;
|
||||
var iter = 0;
|
||||
function addTicksInSpan(interval, minTimestamp, maxTimestamp, getMethodName, setMethodName, isDate, out) {
|
||||
var date = new Date(minTimestamp);
|
||||
var dateTime = minTimestamp;
|
||||
var d = date[getMethodName]();
|
||||
// if (isDate) {
|
||||
// d -= 1; // Starts with 0; PENDING
|
||||
// }
|
||||
while (dateTime < maxTimestamp && dateTime <= extent[1]) {
|
||||
out.push({
|
||||
value: dateTime
|
||||
});
|
||||
d += interval;
|
||||
date[setMethodName](d);
|
||||
dateTime = date.getTime();
|
||||
}
|
||||
// This extra tick is for calcuating ticks of next level. Will not been added to the final result
|
||||
out.push({
|
||||
value: dateTime,
|
||||
notAdd: true
|
||||
});
|
||||
}
|
||||
function addLevelTicks(unitName, lastLevelTicks, levelTicks) {
|
||||
var newAddedTicks = [];
|
||||
var isFirstLevel = !lastLevelTicks.length;
|
||||
if (isUnitValueSame(getPrimaryTimeUnit(unitName), extent[0], extent[1], isUTC)) {
|
||||
return;
|
||||
}
|
||||
if (isFirstLevel) {
|
||||
lastLevelTicks = [{
|
||||
// TODO Optimize. Not include so may ticks.
|
||||
value: getFirstTimestampOfUnit(new Date(extent[0]), unitName, isUTC)
|
||||
}, {
|
||||
value: extent[1]
|
||||
}];
|
||||
}
|
||||
for (var i = 0; i < lastLevelTicks.length - 1; i++) {
|
||||
var startTick = lastLevelTicks[i].value;
|
||||
var endTick = lastLevelTicks[i + 1].value;
|
||||
if (startTick === endTick) {
|
||||
continue;
|
||||
}
|
||||
var interval = void 0;
|
||||
var getterName = void 0;
|
||||
var setterName = void 0;
|
||||
var isDate = false;
|
||||
switch (unitName) {
|
||||
case 'year':
|
||||
interval = Math.max(1, Math.round(approxInterval / ONE_DAY / 365));
|
||||
getterName = fullYearGetterName(isUTC);
|
||||
setterName = fullYearSetterName(isUTC);
|
||||
break;
|
||||
case 'half-year':
|
||||
case 'quarter':
|
||||
case 'month':
|
||||
interval = getMonthInterval(approxInterval);
|
||||
getterName = monthGetterName(isUTC);
|
||||
setterName = monthSetterName(isUTC);
|
||||
break;
|
||||
case 'week': // PENDING If week is added. Ignore day.
|
||||
case 'half-week':
|
||||
case 'day':
|
||||
interval = getDateInterval(approxInterval, 31); // Use 32 days and let interval been 16
|
||||
getterName = dateGetterName(isUTC);
|
||||
setterName = dateSetterName(isUTC);
|
||||
isDate = true;
|
||||
break;
|
||||
case 'half-day':
|
||||
case 'quarter-day':
|
||||
case 'hour':
|
||||
interval = getHourInterval(approxInterval);
|
||||
getterName = hoursGetterName(isUTC);
|
||||
setterName = hoursSetterName(isUTC);
|
||||
break;
|
||||
case 'minute':
|
||||
interval = getMinutesAndSecondsInterval(approxInterval, true);
|
||||
getterName = minutesGetterName(isUTC);
|
||||
setterName = minutesSetterName(isUTC);
|
||||
break;
|
||||
case 'second':
|
||||
interval = getMinutesAndSecondsInterval(approxInterval, false);
|
||||
getterName = secondsGetterName(isUTC);
|
||||
setterName = secondsSetterName(isUTC);
|
||||
break;
|
||||
case 'millisecond':
|
||||
interval = getMillisecondsInterval(approxInterval);
|
||||
getterName = millisecondsGetterName(isUTC);
|
||||
setterName = millisecondsSetterName(isUTC);
|
||||
break;
|
||||
}
|
||||
addTicksInSpan(interval, startTick, endTick, getterName, setterName, isDate, newAddedTicks);
|
||||
if (unitName === 'year' && levelTicks.length > 1 && i === 0) {
|
||||
// Add nearest years to the left extent.
|
||||
levelTicks.unshift({
|
||||
value: levelTicks[0].value - interval
|
||||
});
|
||||
}
|
||||
}
|
||||
for (var i = 0; i < newAddedTicks.length; i++) {
|
||||
levelTicks.push(newAddedTicks[i]);
|
||||
}
|
||||
// newAddedTicks.length && console.log(unitName, newAddedTicks);
|
||||
return newAddedTicks;
|
||||
}
|
||||
var levelsTicks = [];
|
||||
var currentLevelTicks = [];
|
||||
var tickCount = 0;
|
||||
var lastLevelTickCount = 0;
|
||||
for (var i = 0; i < unitNames.length && iter++ < safeLimit; ++i) {
|
||||
var primaryTimeUnit = getPrimaryTimeUnit(unitNames[i]);
|
||||
if (!isPrimaryTimeUnit(unitNames[i])) {
|
||||
// TODO
|
||||
continue;
|
||||
}
|
||||
addLevelTicks(unitNames[i], levelsTicks[levelsTicks.length - 1] || [], currentLevelTicks);
|
||||
var nextPrimaryTimeUnit = unitNames[i + 1] ? getPrimaryTimeUnit(unitNames[i + 1]) : null;
|
||||
if (primaryTimeUnit !== nextPrimaryTimeUnit) {
|
||||
if (currentLevelTicks.length) {
|
||||
lastLevelTickCount = tickCount;
|
||||
// Remove the duplicate so the tick count can be precisely.
|
||||
currentLevelTicks.sort(function (a, b) {
|
||||
return a.value - b.value;
|
||||
});
|
||||
var levelTicksRemoveDuplicated = [];
|
||||
for (var i_1 = 0; i_1 < currentLevelTicks.length; ++i_1) {
|
||||
var tickValue = currentLevelTicks[i_1].value;
|
||||
if (i_1 === 0 || currentLevelTicks[i_1 - 1].value !== tickValue) {
|
||||
levelTicksRemoveDuplicated.push(currentLevelTicks[i_1]);
|
||||
if (tickValue >= extent[0] && tickValue <= extent[1]) {
|
||||
tickCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
var targetTickNum = (extent[1] - extent[0]) / approxInterval;
|
||||
// Added too much in this level and not too less in last level
|
||||
if (tickCount > targetTickNum * 1.5 && lastLevelTickCount > targetTickNum / 1.5) {
|
||||
break;
|
||||
}
|
||||
// Only treat primary time unit as one level.
|
||||
levelsTicks.push(levelTicksRemoveDuplicated);
|
||||
if (tickCount > targetTickNum || bottomUnitName === unitNames[i]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Reset if next unitName is primary
|
||||
currentLevelTicks = [];
|
||||
}
|
||||
}
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (iter >= safeLimit) {
|
||||
warn('Exceed safe limit.');
|
||||
}
|
||||
}
|
||||
var levelsTicksInExtent = filter(map(levelsTicks, function (levelTicks) {
|
||||
return filter(levelTicks, function (tick) {
|
||||
return tick.value >= extent[0] && tick.value <= extent[1] && !tick.notAdd;
|
||||
});
|
||||
}), function (levelTicks) {
|
||||
return levelTicks.length > 0;
|
||||
});
|
||||
var ticks = [];
|
||||
var maxLevel = levelsTicksInExtent.length - 1;
|
||||
for (var i = 0; i < levelsTicksInExtent.length; ++i) {
|
||||
var levelTicks = levelsTicksInExtent[i];
|
||||
for (var k = 0; k < levelTicks.length; ++k) {
|
||||
ticks.push({
|
||||
value: levelTicks[k].value,
|
||||
level: maxLevel - i
|
||||
});
|
||||
}
|
||||
}
|
||||
ticks.sort(function (a, b) {
|
||||
return a.value - b.value;
|
||||
});
|
||||
// Remove duplicates
|
||||
var result = [];
|
||||
for (var i = 0; i < ticks.length; ++i) {
|
||||
if (i === 0 || ticks[i].value !== ticks[i - 1].value) {
|
||||
result.push(ticks[i]);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
Scale.registerClass(TimeScale);
|
||||
export default TimeScale;
|
122
frontend/node_modules/echarts/lib/scale/helper.js
generated
vendored
Normal file
122
frontend/node_modules/echarts/lib/scale/helper.js
generated
vendored
Normal file
@ -0,0 +1,122 @@
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
import { getPrecision, round, nice, quantityExponent } from '../util/number.js';
|
||||
export function isValueNice(val) {
|
||||
var exp10 = Math.pow(10, quantityExponent(Math.abs(val)));
|
||||
var f = Math.abs(val / exp10);
|
||||
return f === 0 || f === 1 || f === 2 || f === 3 || f === 5;
|
||||
}
|
||||
export function isIntervalOrLogScale(scale) {
|
||||
return scale.type === 'interval' || scale.type === 'log';
|
||||
}
|
||||
/**
|
||||
* @param extent Both extent[0] and extent[1] should be valid number.
|
||||
* Should be extent[0] < extent[1].
|
||||
* @param splitNumber splitNumber should be >= 1.
|
||||
*/
|
||||
export function intervalScaleNiceTicks(extent, splitNumber, minInterval, maxInterval) {
|
||||
var result = {};
|
||||
var span = extent[1] - extent[0];
|
||||
var interval = result.interval = nice(span / splitNumber, true);
|
||||
if (minInterval != null && interval < minInterval) {
|
||||
interval = result.interval = minInterval;
|
||||
}
|
||||
if (maxInterval != null && interval > maxInterval) {
|
||||
interval = result.interval = maxInterval;
|
||||
}
|
||||
// Tow more digital for tick.
|
||||
var precision = result.intervalPrecision = getIntervalPrecision(interval);
|
||||
// Niced extent inside original extent
|
||||
var niceTickExtent = result.niceTickExtent = [round(Math.ceil(extent[0] / interval) * interval, precision), round(Math.floor(extent[1] / interval) * interval, precision)];
|
||||
fixExtent(niceTickExtent, extent);
|
||||
return result;
|
||||
}
|
||||
export function increaseInterval(interval) {
|
||||
var exp10 = Math.pow(10, quantityExponent(interval));
|
||||
// Increase interval
|
||||
var f = interval / exp10;
|
||||
if (!f) {
|
||||
f = 1;
|
||||
} else if (f === 2) {
|
||||
f = 3;
|
||||
} else if (f === 3) {
|
||||
f = 5;
|
||||
} else {
|
||||
// f is 1 or 5
|
||||
f *= 2;
|
||||
}
|
||||
return round(f * exp10);
|
||||
}
|
||||
/**
|
||||
* @return interval precision
|
||||
*/
|
||||
export function getIntervalPrecision(interval) {
|
||||
// Tow more digital for tick.
|
||||
return getPrecision(interval) + 2;
|
||||
}
|
||||
function clamp(niceTickExtent, idx, extent) {
|
||||
niceTickExtent[idx] = Math.max(Math.min(niceTickExtent[idx], extent[1]), extent[0]);
|
||||
}
|
||||
// In some cases (e.g., splitNumber is 1), niceTickExtent may be out of extent.
|
||||
export function fixExtent(niceTickExtent, extent) {
|
||||
!isFinite(niceTickExtent[0]) && (niceTickExtent[0] = extent[0]);
|
||||
!isFinite(niceTickExtent[1]) && (niceTickExtent[1] = extent[1]);
|
||||
clamp(niceTickExtent, 0, extent);
|
||||
clamp(niceTickExtent, 1, extent);
|
||||
if (niceTickExtent[0] > niceTickExtent[1]) {
|
||||
niceTickExtent[0] = niceTickExtent[1];
|
||||
}
|
||||
}
|
||||
export function contain(val, extent) {
|
||||
return val >= extent[0] && val <= extent[1];
|
||||
}
|
||||
export function normalize(val, extent) {
|
||||
if (extent[1] === extent[0]) {
|
||||
return 0.5;
|
||||
}
|
||||
return (val - extent[0]) / (extent[1] - extent[0]);
|
||||
}
|
||||
export function scale(val, extent) {
|
||||
return val * (extent[1] - extent[0]) + extent[0];
|
||||
}
|
Reference in New Issue
Block a user