Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@antv/scale

Package Overview
Dependencies
Maintainers
15
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@antv/scale - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

4

esm/base.d.ts

@@ -19,2 +19,6 @@ export declare type ScaleType = 'base' | 'linear' | 'cat' | 'log' | 'pow' | 'identity' | 'time' | 'timeCat';

max: any;
/** min value limitted of the scale */
minLimit?: number;
/** max value limitted of the scale */
maxLimit?: number;
/** 数据字段的显示别名,scale内部不感知,外部注入 */

@@ -21,0 +25,0 @@ alias: string;

10

esm/category.js

@@ -1,2 +0,2 @@

import * as tslib_1 from "tslib";
import { __extends, __spreadArrays } from "tslib";
import * as _ from '@antv/util';

@@ -6,3 +6,3 @@ import Base from './base';

var Category = /** @class */ (function (_super) {
tslib_1.__extends(Category, _super);
__extends(Category, _super);
function Category() {

@@ -42,3 +42,3 @@ return _super !== null && _super.apply(this, arguments) || this;

}
return _super.prototype.getText.apply(this, [v].concat(args));
return _super.prototype.getText.apply(this, __spreadArrays([v], args));
};

@@ -71,5 +71,5 @@ /**

// 简单过滤,部分情况下小数的倍数也可以是整数
var Q = ALL_Q.filter(function (n) { return Number.isInteger(n); });
var Q_1 = ALL_Q.filter(function (n) { return Number.isInteger(n); });
// tslint:disable-next-line: no-shadowed-variable
var ticks_1 = extended(this.min, this.max, this.tickCount, false, Q).ticks;
var ticks_1 = extended(this.min, this.max, this.tickCount, false, Q_1).ticks;
var valid = _.filter(ticks_1, function (tick) { return tick >= _this.min && tick <= _this.max; });

@@ -76,0 +76,0 @@ return valid.map(function (index) { return _this.values[index]; });

@@ -1,2 +0,2 @@

import * as tslib_1 from "tslib";
import { __extends } from "tslib";
import * as _ from '@antv/util';

@@ -10,3 +10,3 @@ import Base from './base';

var Identity = /** @class */ (function (_super) {
tslib_1.__extends(Identity, _super);
__extends(Identity, _super);
function Identity() {

@@ -13,0 +13,0 @@ return _super !== null && _super.apply(this, arguments) || this;

@@ -1,6 +0,6 @@

import * as tslib_1 from "tslib";
import { __extends } from "tslib";
import * as _ from '@antv/util';
import Linear from './linear';
var Log = /** @class */ (function (_super) {
tslib_1.__extends(Log, _super);
__extends(Log, _super);
function Log() {

@@ -7,0 +7,0 @@ return _super !== null && _super.apply(this, arguments) || this;

@@ -1,5 +0,5 @@

import * as tslib_1 from "tslib";
import { __extends } from "tslib";
import Linear from './linear';
var Pow = /** @class */ (function (_super) {
tslib_1.__extends(Pow, _super);
__extends(Pow, _super);
function Pow() {

@@ -6,0 +6,0 @@ return _super !== null && _super.apply(this, arguments) || this;

@@ -8,2 +8,4 @@ import Base, { ScaleConfig, ScaleType } from './base';

max?: ScaleConfig['max'];
minLimit?: ScaleConfig['minLimit'];
maxLimit?: ScaleConfig['maxLimit'];
tickCount?: ScaleConfig['tickCount'];

@@ -10,0 +12,0 @@ minTickInterval?: ScaleConfig['minTickInterval'];

@@ -1,2 +0,2 @@

import * as tslib_1 from "tslib";
import { __extends } from "tslib";
import * as _ from '@antv/util';

@@ -6,3 +6,3 @@ import Base from './base';

var Linear = /** @class */ (function (_super) {
tslib_1.__extends(Linear, _super);
__extends(Linear, _super);
function Linear() {

@@ -67,11 +67,48 @@ return _super !== null && _super.apply(this, arguments) || this;

Linear.prototype._setTicks = function () {
var _a = this._getAlgoParams(), onlyLoose = _a.onlyLoose, Q = _a.Q, w = _a.w, m = _a.m;
var _b = extended(this.min, this.max, m, onlyLoose, Q, w), min = _b.min, max = _b.max, ticks = _b.ticks;
var _a, _b;
var _this = this;
var _c = this._getAlgoParams(), onlyLoose = _c.onlyLoose, Q = _c.Q, w = _c.w, m = _c.m;
var adjustTicks = [];
var minLimit = this.minLimit;
var maxLimit = this.maxLimit;
var tickMin;
var tickMax;
// minLimit/maxLimit相同情况处理
if (!_.isNil(minLimit) && !_.isNil(maxLimit) && minLimit === maxLimit) {
console.error('minLimit should less than maxLimit');
minLimit = minLimit / 2;
if (minLimit === 0) {
maxLimit = 1;
}
}
tickMin = _.isNil(minLimit) ? this.min : this.minLimit;
tickMax = _.isNil(maxLimit) ? this.max : this.maxLimit;
// 最终的min/max校验和处理
if (tickMin > tickMax) {
console.error('minLimit should less than maxLimit');
_a = [tickMax, tickMin], tickMin = _a[0], tickMax = _a[1];
_b = [maxLimit, minLimit], minLimit = _b[0], maxLimit = _b[1];
}
var _d = extended(tickMin, tickMax, m, onlyLoose, Q, w), min = _d.min, max = _d.max, ticks = _d.ticks;
if (this.nice) {
this.min = min;
this.max = max;
return ticks;
}
// todo:区分上层min、max计算和用户输入以简化逻辑
return _.filter(ticks, function (tick) { return tick >= min && tick <= max; });
// 修正min/max
if (!_.isNil(minLimit)) {
this.min = minLimit;
}
if (!_.isNil(maxLimit)) {
this.max = maxLimit;
}
adjustTicks.push(this.min);
_.each(ticks, function (tick) {
if (tick > _this.min && tick < _this.max) {
adjustTicks.push(tick);
}
});
if (adjustTicks[adjustTicks.length - 1] < this.max) {
adjustTicks.push(this.max);
}
return adjustTicks;
};

@@ -78,0 +115,0 @@ Linear.prototype._getAlgoParams = function () {

@@ -1,2 +0,2 @@

import * as tslib_1 from "tslib";
import { __extends } from "tslib";
import * as _ from '@antv/util';

@@ -12,3 +12,3 @@ import * as moment from 'moment';

var Time = /** @class */ (function (_super) {
tslib_1.__extends(Time, _super);
__extends(Time, _super);
function Time() {

@@ -15,0 +15,0 @@ return _super !== null && _super.apply(this, arguments) || this;

@@ -1,2 +0,2 @@

import * as tslib_1 from "tslib";
import { __extends } from "tslib";
import * as _ from '@antv/util';

@@ -6,3 +6,3 @@ import Cat from './category';

var TimeCat = /** @class */ (function (_super) {
tslib_1.__extends(TimeCat, _super);
__extends(TimeCat, _super);
function TimeCat() {

@@ -9,0 +9,0 @@ return _super !== null && _super.apply(this, arguments) || this;

@@ -66,3 +66,3 @@ import * as _ from '@antv/util';

if (w === void 0) { w = [0.25, 0.2, 0.5, 0.05]; }
if (dmin === dmax) {
if (dmin === dmax || m === 1) {
return {

@@ -69,0 +69,0 @@ min: dmin,

@@ -19,2 +19,6 @@ export declare type ScaleType = 'base' | 'linear' | 'cat' | 'log' | 'pow' | 'identity' | 'time' | 'timeCat';

max: any;
/** min value limitted of the scale */
minLimit?: number;
/** max value limitted of the scale */
maxLimit?: number;
/** 数据字段的显示别名,scale内部不感知,外部注入 */

@@ -21,0 +25,0 @@ alias: string;

@@ -43,3 +43,3 @@ "use strict";

}
return _super.prototype.getText.apply(this, [v].concat(args));
return _super.prototype.getText.apply(this, tslib_1.__spreadArrays([v], args));
};

@@ -72,5 +72,5 @@ /**

// 简单过滤,部分情况下小数的倍数也可以是整数
var Q = extended_1.ALL_Q.filter(function (n) { return Number.isInteger(n); });
var Q_1 = extended_1.ALL_Q.filter(function (n) { return Number.isInteger(n); });
// tslint:disable-next-line: no-shadowed-variable
var ticks_1 = extended_1.default(this.min, this.max, this.tickCount, false, Q).ticks;
var ticks_1 = extended_1.default(this.min, this.max, this.tickCount, false, Q_1).ticks;
var valid = _.filter(ticks_1, function (tick) { return tick >= _this.min && tick <= _this.max; });

@@ -77,0 +77,0 @@ return valid.map(function (index) { return _this.values[index]; });

@@ -8,2 +8,4 @@ import Base, { ScaleConfig, ScaleType } from './base';

max?: ScaleConfig['max'];
minLimit?: ScaleConfig['minLimit'];
maxLimit?: ScaleConfig['maxLimit'];
tickCount?: ScaleConfig['tickCount'];

@@ -10,0 +12,0 @@ minTickInterval?: ScaleConfig['minTickInterval'];

@@ -68,11 +68,48 @@ "use strict";

Linear.prototype._setTicks = function () {
var _a = this._getAlgoParams(), onlyLoose = _a.onlyLoose, Q = _a.Q, w = _a.w, m = _a.m;
var _b = extended_1.default(this.min, this.max, m, onlyLoose, Q, w), min = _b.min, max = _b.max, ticks = _b.ticks;
var _a, _b;
var _this = this;
var _c = this._getAlgoParams(), onlyLoose = _c.onlyLoose, Q = _c.Q, w = _c.w, m = _c.m;
var adjustTicks = [];
var minLimit = this.minLimit;
var maxLimit = this.maxLimit;
var tickMin;
var tickMax;
// minLimit/maxLimit相同情况处理
if (!_.isNil(minLimit) && !_.isNil(maxLimit) && minLimit === maxLimit) {
console.error('minLimit should less than maxLimit');
minLimit = minLimit / 2;
if (minLimit === 0) {
maxLimit = 1;
}
}
tickMin = _.isNil(minLimit) ? this.min : this.minLimit;
tickMax = _.isNil(maxLimit) ? this.max : this.maxLimit;
// 最终的min/max校验和处理
if (tickMin > tickMax) {
console.error('minLimit should less than maxLimit');
_a = [tickMax, tickMin], tickMin = _a[0], tickMax = _a[1];
_b = [maxLimit, minLimit], minLimit = _b[0], maxLimit = _b[1];
}
var _d = extended_1.default(tickMin, tickMax, m, onlyLoose, Q, w), min = _d.min, max = _d.max, ticks = _d.ticks;
if (this.nice) {
this.min = min;
this.max = max;
return ticks;
}
// todo:区分上层min、max计算和用户输入以简化逻辑
return _.filter(ticks, function (tick) { return tick >= min && tick <= max; });
// 修正min/max
if (!_.isNil(minLimit)) {
this.min = minLimit;
}
if (!_.isNil(maxLimit)) {
this.max = maxLimit;
}
adjustTicks.push(this.min);
_.each(ticks, function (tick) {
if (tick > _this.min && tick < _this.max) {
adjustTicks.push(tick);
}
});
if (adjustTicks[adjustTicks.length - 1] < this.max) {
adjustTicks.push(this.max);
}
return adjustTicks;
};

@@ -79,0 +116,0 @@ Linear.prototype._getAlgoParams = function () {

@@ -68,3 +68,3 @@ "use strict";

if (w === void 0) { w = [0.25, 0.2, 0.5, 0.05]; }
if (dmin === dmax) {
if (dmin === dmax || m === 1) {
return {

@@ -71,0 +71,0 @@ min: dmin,

{
"name": "@antv/scale",
"version": "0.2.0",
"version": "0.2.1",
"description": "The scale module for G2",

@@ -26,5 +26,3 @@ "author": "https://github.com/orgs/antvis/people",

"lib:esm": "tsc -p tsconfig.json --target ES5 --module ESNext --outDir esm",
"lint": "run-s lint:*",
"lint:tslint": "tslint -c tslint.json 'src/**/*.ts'",
"lint:prettier": "prettier --list-different 'src/**/*.{ts,tsx,js,jsx}'",
"lint": "lint-staged",
"coverage": "exit 0",

@@ -44,2 +42,3 @@ "test": "torch --compile --recursive __tests__",

"husky": "^3.0.4",
"lint-staged": "^9.2.3",
"npm-run-all": "^4.1.5",

@@ -56,3 +55,14 @@ "prettier": "^1.18.2",

"tslib": "^1.10.0"
},
"lint-staged": {
"*.{js,css,json,md}": [
"prettier --write",
"git add"
],
"*.{ts}": [
"tslint -c tslint.json --fix",
"prettier --write",
"git add"
]
}
}

@@ -17,7 +17,2 @@ # `@antv/scale`

## Class Diagram
![](https://intranetproxy.alipay.com/skylark/lark/__puml/65bea83f5029f4d12458eb691ab870e7.svg)
### Attr

@@ -24,0 +19,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc