Skip to content

Commit

Permalink
refactor: update types.d.ts generation
Browse files Browse the repository at this point in the history
  • Loading branch information
hkang1 committed Feb 15, 2022
1 parent df657ee commit 13cacad
Show file tree
Hide file tree
Showing 8 changed files with 341 additions and 27 deletions.
48 changes: 48 additions & 0 deletions dist/defaults.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import * as t from './types';
/**
* Invalid defaults.
*/
export declare const INVALID_VALUE: number;
export declare const INVALID_POINT: {
x: number;
y: number;
};
export declare const INVALID_RECT: {
h: number;
w: number;
x: number;
y: number;
};
export declare const INVALID_ACTION: {
dimIndex: number;
p0: {
x: number;
y: number;
};
p1: {
x: number;
y: number;
};
type: t.ActionType;
};
/**
* Style defaults.
*/
export declare const BEZIER_FACTOR = 0.3;
export declare const DIRECTION: CanvasDirection;
export declare const FILL_STYLE = "black";
export declare const FONT = "normal 12px san-serif";
export declare const LINE_CAP: CanvasLineCap;
export declare const LINE_DASH_OFFSET = 0;
export declare const LINE_JOIN: CanvasLineJoin;
export declare const LINE_WIDTH = 1;
export declare const MITER_LIMIT = 10;
export declare const STROKE_STYLE = "black";
export declare const TEXT_ALIGN = "left";
export declare const TEXT_BASELINE = "middle";
/**
* Framework options defaults.
*/
export declare const HERMES_OPTIONS: t.HermesOptions;
export declare const FILTER: t.Filter;
export declare const IX: t.IX;
10 changes: 5 additions & 5 deletions dist/hermes.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -1182,11 +1182,11 @@ const generateData = (dimensions, count) => {
}
else if (axis.type === AxisType.Linear) {
const range = dimensionRanges[dimension.key];
return axis.range ? randomNumber(range[1], range[0]) : INVALID_VALUE;
return range ? randomNumber(range[1], range[0]) : INVALID_VALUE;
}
else if (axis.type === AxisType.Logarithmic) {
const range = dimensionRanges[dimension.key];
return axis.range && axis.logBase
return range && axis.logBase
? randomLogNumber(axis.logBase, range[1], range[0]) : INVALID_VALUE;
}
return INVALID_VALUE;
Expand Down Expand Up @@ -1306,12 +1306,12 @@ class Hermes {
const key = dimension.key;
const data = this.data[key] || [];
if ([AxisType.Linear, AxisType.Logarithmic].includes(_da.type)) {
_da.range = getDataRange(data);
const range = getDataRange(data);
if (_da.type === AxisType.Linear) {
_da.scale = new LinearScale(_da.range[0], _da.range[1], _da.dataOnEdge);
_da.scale = new LinearScale(range[0], range[1], _da.dataOnEdge);
}
else if (_da.type === AxisType.Logarithmic) {
_da.scale = new LogScale(_da.range[0], _da.range[1], _da.logBase, _da.dataOnEdge);
_da.scale = new LogScale(range[0], range[1], _da.logBase, _da.dataOnEdge);
}
}
else if (_da.type === AxisType.Categorical) {
Expand Down
10 changes: 5 additions & 5 deletions dist/hermes.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -1180,11 +1180,11 @@ const generateData = (dimensions, count) => {
}
else if (axis.type === AxisType.Linear) {
const range = dimensionRanges[dimension.key];
return axis.range ? randomNumber(range[1], range[0]) : INVALID_VALUE;
return range ? randomNumber(range[1], range[0]) : INVALID_VALUE;
}
else if (axis.type === AxisType.Logarithmic) {
const range = dimensionRanges[dimension.key];
return axis.range && axis.logBase
return range && axis.logBase
? randomLogNumber(axis.logBase, range[1], range[0]) : INVALID_VALUE;
}
return INVALID_VALUE;
Expand Down Expand Up @@ -1304,12 +1304,12 @@ class Hermes {
const key = dimension.key;
const data = this.data[key] || [];
if ([AxisType.Linear, AxisType.Logarithmic].includes(_da.type)) {
_da.range = getDataRange(data);
const range = getDataRange(data);
if (_da.type === AxisType.Linear) {
_da.scale = new LinearScale(_da.range[0], _da.range[1], _da.dataOnEdge);
_da.scale = new LinearScale(range[0], range[1], _da.dataOnEdge);
}
else if (_da.type === AxisType.Logarithmic) {
_da.scale = new LogScale(_da.range[0], _da.range[1], _da.logBase, _da.dataOnEdge);
_da.scale = new LogScale(range[0], range[1], _da.logBase, _da.dataOnEdge);
}
}
else if (_da.type === AxisType.Categorical) {
Expand Down
10 changes: 5 additions & 5 deletions dist/hermes.iife.js
Original file line number Diff line number Diff line change
Expand Up @@ -1183,11 +1183,11 @@ var Hermes = (function () {
}
else if (axis.type === AxisType.Linear) {
const range = dimensionRanges[dimension.key];
return axis.range ? randomNumber(range[1], range[0]) : INVALID_VALUE;
return range ? randomNumber(range[1], range[0]) : INVALID_VALUE;
}
else if (axis.type === AxisType.Logarithmic) {
const range = dimensionRanges[dimension.key];
return axis.range && axis.logBase
return range && axis.logBase
? randomLogNumber(axis.logBase, range[1], range[0]) : INVALID_VALUE;
}
return INVALID_VALUE;
Expand Down Expand Up @@ -1307,12 +1307,12 @@ var Hermes = (function () {
const key = dimension.key;
const data = this.data[key] || [];
if ([AxisType.Linear, AxisType.Logarithmic].includes(_da.type)) {
_da.range = getDataRange(data);
const range = getDataRange(data);
if (_da.type === AxisType.Linear) {
_da.scale = new LinearScale(_da.range[0], _da.range[1], _da.dataOnEdge);
_da.scale = new LinearScale(range[0], range[1], _da.dataOnEdge);
}
else if (_da.type === AxisType.Logarithmic) {
_da.scale = new LogScale(_da.range[0], _da.range[1], _da.logBase, _da.dataOnEdge);
_da.scale = new LogScale(range[0], range[1], _da.logBase, _da.dataOnEdge);
}
}
else if (_da.type === AxisType.Categorical) {
Expand Down
Loading

0 comments on commit 13cacad

Please sign in to comment.