Skip to content

Commit

Permalink
tune exports to avoid warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
sgratzl committed Dec 24, 2018
1 parent 8f8becd commit 49639fb
Show file tree
Hide file tree
Showing 19 changed files with 155 additions and 153 deletions.
31 changes: 31 additions & 0 deletions src/builder/DataBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,34 @@ export default class DataBuilder extends LineUpBuilder {
export function builder(arr: object[]) {
return new DataBuilder(arr);
}


/**
* build a new Taggle instance in the given node for the given data
* @param {HTMLElement} node DOM node to attach to
* @param {any[]} data data to visualize
* @param {string[]} columns optional enforced column order
* @returns {Taggle}
*/
export function asTaggle(node: HTMLElement, data: any[], ...columns: string[]): Taggle {
return builder(data)
.deriveColumns(columns)
.deriveColors()
.defaultRanking()
.buildTaggle(node);
}

/**
* build a new LineUp instance in the given node for the given data
* @param {HTMLElement} node DOM node to attach to
* @param {any[]} data data to visualize
* @param {string[]} columns optional enforced column order
* @returns {LineUp}
*/
export function asLineUp(node: HTMLElement, data: any[], ...columns: string[]): LineUp {
return builder(data)
.deriveColumns(columns)
.deriveColors()
.defaultRanking()
.build(node);
}
33 changes: 0 additions & 33 deletions src/builder/index.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,4 @@
import {Taggle, LineUp} from '../ui';
import {builder} from './DataBuilder';

export * from './DataBuilder';
export * from './column';
export * from './RankingBuilder';
export * from './adapter';

/**
* build a new Taggle instance in the given node for the given data
* @param {HTMLElement} node DOM node to attach to
* @param {any[]} data data to visualize
* @param {string[]} columns optional enforced column order
* @returns {Taggle}
*/
export function asTaggle(node: HTMLElement, data: any[], ...columns: string[]): Taggle {
return builder(data)
.deriveColumns(columns)
.deriveColors()
.defaultRanking()
.buildTaggle(node);
}

/**
* build a new LineUp instance in the given node for the given data
* @param {HTMLElement} node DOM node to attach to
* @param {any[]} data data to visualize
* @param {string[]} columns optional enforced column order
* @returns {LineUp}
*/
export function asLineUp(node: HTMLElement, data: any[], ...columns: string[]): LineUp {
return builder(data)
.deriveColumns(columns)
.deriveColors()
.defaultRanking()
.build(node);
}
18 changes: 18 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@ import {ITaggleOptions} from './interfaces';
import {renderers} from './renderer/internal';
import {toolbarActions} from './ui';

/**
* number of bins before switching to dense mode
* @internal
*/
export const DENSE_HISTOGRAM = 19;
/**
* minimal witdh of a column to show the label in the header
* @internal
*/
export const MIN_LABEL_WIDTH = 30;
/**
* number of milliseconds to wait before a hovered canvas row will be replaced with a DOM one
* @type {number}
* @internal
*/
export const HOVER_DELAY_SHOW_DETAIL = 500;


export function defaultOptions(): ITaggleOptions {
return {
toolbar: Object.assign({}, toolbarActions),
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import {LineUp, ILineUpOptions, Taggle, ITaggleOptions} from './ui';

export * from './builder';
export {defaultOptions} from './config';
export {IDynamicHeight, ILineUpFlags, ILineUpLike, ILineUpOptions, ITaggleOptions} from './interfaces';
export {IAdvancedBoxPlotData, IBoxPlotData, ICategoricalBin, ICategoricalStatistics, INumberBin, IStatistics} from './internal';
export * from './interfaces';
export * from './internal/mathInterfaces';
export * from './model';
export * from './provider';
export * from './renderer';
Expand Down
18 changes: 0 additions & 18 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,6 @@ import {IDataProvider} from './provider';
import {ICellRendererFactory, ERenderMode} from './renderer';
import {IToolbarAction, IToolbarDialogAddon} from './ui';


/**
* number of bins before switching to dense mode
* @internal
*/
export const DENSE_HISTOGRAM = 19;
/**
* minimal witdh of a column to show the label in the header
* @internal
*/
export const MIN_LABEL_WIDTH = 30;
/**
* number of milliseconds to wait before a hovered canvas row will be replaced with a DOM one
* @type {number}
* @internal
*/
export const HOVER_DELAY_SHOW_DETAIL = 500;

/**
* custom height implementation logic
*/
Expand Down
1 change: 1 addition & 0 deletions src/internal/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export * from './dnd';
export * from './drag';
export * from './interable';
export * from './math';
export * from './mathInterfaces';
export {default as merge} from './merge';
export {default as OrderedSet} from './OrderedSet';
export * from './utils';
Expand Down
92 changes: 6 additions & 86 deletions src/internal/math.ts
Original file line number Diff line number Diff line change
@@ -1,88 +1,8 @@
import {ICategory, IndicesArray, UIntTypedArray} from '../model';
import {IForEachAble, ISequence, isIndicesAble} from './interable';
import {createWorkerCodeBlob, IPoorManWorkerScope, toFunctionBody} from './worker';
import {IAdvancedBoxPlotData, IStatistics, INumberBin, IDateBin, IDateStatistics, ICategoricalStatistics, ICategoricalBin, IDateHistGranularity} from './mathInterfaces';

export interface INumberBin {
/**
* bin start
*/
x0: number;
/**
* bin end
*/
x1: number;
/**
* bin count
*/
count: number;
}

export interface IBoxPlotData {
readonly min: number;
readonly max: number;
readonly median: number;
readonly q1: number;
readonly q3: number;
readonly outlier?: number[];
readonly whiskerLow?: number;
readonly whiskerHigh?: number;
}

export interface IAdvancedBoxPlotData extends IBoxPlotData {
readonly mean: number;

readonly missing: number;
readonly count: number;
}

export interface IStatistics {
readonly mean: number;
readonly min: number;
readonly max: number;

readonly missing: number;
readonly count: number;

readonly maxBin: number;
readonly hist: ReadonlyArray<INumberBin>;
}

export interface ICategoricalBin {
cat: string;
count: number;
}

export interface IDateBin {
x0: Date;
x1: Date;
count: number;
}

export interface ICategoricalStatistics {
readonly missing: number;
readonly count: number;

readonly maxBin: number;
readonly hist: ReadonlyArray<ICategoricalBin>;
}

export enum EDateHistogramGranularity {
YEAR = 'year',
MONTH = 'month',
DAY = 'day'
}

export interface IDateStatistics {
readonly min: Date | null;
readonly max: Date | null;

readonly missing: number;
readonly count: number;

readonly maxBin: number;
readonly histGranularity: EDateHistogramGranularity;
readonly hist: ReadonlyArray<IDateBin>;
}

/**
* computes the optimal number of bins for a given array length
Expand Down Expand Up @@ -466,9 +386,9 @@ export function normalizedStatsBuilder(numberOfBins: number): IBuilder<number, I
/**
* guesses the histogram granularity to use based on min and max date
*/
function computeGranularity(min: Date | null, max: Date | null) {
function computeGranularity(min: Date | null, max: Date | null): {histGranularity: IDateHistGranularity, hist: IDateBin[]} {
if (min == null || max == null) {
return {histGranularity: EDateHistogramGranularity.YEAR, hist: []};
return {histGranularity: 'year', hist: []};
}
const hist: IDateBin[] = [];

Expand All @@ -483,7 +403,7 @@ function computeGranularity(min: Date | null, max: Date | null) {
count: 0
});
}
return {hist, histGranularity: EDateHistogramGranularity.YEAR};
return {hist, histGranularity: 'year'};
}

if ((max.getTime() - min.getTime()) <= 1000 * 60 * 60 * 24 * 31) {
Expand All @@ -499,7 +419,7 @@ function computeGranularity(min: Date | null, max: Date | null) {
});
x0 = x1;
}
return {hist, histGranularity: EDateHistogramGranularity.DAY};
return {hist, histGranularity: 'day'};
}

// by month
Expand All @@ -514,7 +434,7 @@ function computeGranularity(min: Date | null, max: Date | null) {
});
x0 = x1;
}
return {hist, histGranularity: EDateHistogramGranularity.MONTH};
return {hist, histGranularity: 'month'};
}

function pushDateHist(hist: IDateBin[], v: Date, count: number = 1) {
Expand Down
78 changes: 78 additions & 0 deletions src/internal/mathInterfaces.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@

export interface INumberBin {
/**
* bin start
*/
x0: number;
/**
* bin end
*/
x1: number;
/**
* bin count
*/
count: number;
}

export interface IBoxPlotData {
readonly min: number;
readonly max: number;
readonly median: number;
readonly q1: number;
readonly q3: number;
readonly outlier?: number[];
readonly whiskerLow?: number;
readonly whiskerHigh?: number;
}

export interface IAdvancedBoxPlotData extends IBoxPlotData {
readonly mean: number;

readonly missing: number;
readonly count: number;
}

export interface IStatistics {
readonly mean: number;
readonly min: number;
readonly max: number;

readonly missing: number;
readonly count: number;

readonly maxBin: number;
readonly hist: ReadonlyArray<INumberBin>;
}

export interface ICategoricalBin {
cat: string;
count: number;
}

export interface IDateBin {
x0: Date;
x1: Date;
count: number;
}

export interface ICategoricalStatistics {
readonly missing: number;
readonly count: number;

readonly maxBin: number;
readonly hist: ReadonlyArray<ICategoricalBin>;
}

export declare type IDateHistGranularity = 'year' | 'month' | 'day';

export interface IDateStatistics {
readonly min: Date | null;
readonly max: Date | null;

readonly missing: number;
readonly count: number;

readonly maxBin: number;
readonly histGranularity: IDateHistGranularity;
readonly hist: ReadonlyArray<IDateBin>;
}
2 changes: 1 addition & 1 deletion src/model/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Column from './Column';
import ValueColumn, {IValueColumnDesc} from './ValueColumn';

export {isSupportType, Category, SupportType, SortByDefault, Categories, toolbar, dialogAddons, categoryOfDesc, categoryOf, IColumnCategory, getSortType, isSortingAscByDefault} from './annotations';
export * from './annotations';
export {isMissingValue, isUnknown, FIRST_IS_NAN, FIRST_IS_MISSING, missingGroup} from './missing';
export * from './interfaces';
export * from './ICategoricalColumn';
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/CategoricalCellRenderer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {DENSE_HISTOGRAM} from '../interfaces';
import {DENSE_HISTOGRAM} from '../config';
import {ICategoricalStatistics, round} from '../internal';
import {OrdinalColumn, isCategoricalColumn, isCategoricalLikeColumn, ICategoricalLikeColumn, ICategory, Column, CategoricalColumn, ICategoricalColumn, IDataRow, IOrderedGroup, SetColumn} from '../model';
import {CANVAS_HEIGHT, cssClass, FILTERED_OPACITY} from '../styles';
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/HistogramCellRenderer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {DENSE_HISTOGRAM} from '../interfaces';
import {DENSE_HISTOGRAM} from '../config';
import {dragHandle, IDragHandleOptions, normalizedStatsBuilder, INumberBin, IStatistics, round, getNumberOfBins} from '../internal';
import {Column, IDataRow, IOrderedGroup, INumberColumn, INumbersColumn, isNumberColumn, isNumbersColumn, IMapAbleColumn, isMapAbleColumn} from '../model';
import InputNumberDialog from '../ui/dialogs/InputNumberDialog';
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {MIN_LABEL_WIDTH} from '../interfaces';
import {MIN_LABEL_WIDTH} from '../config';
import {Column, IArrayColumn, IDataRow, ICategoricalLikeColumn, isMapAbleColumn} from '../model';
import {hsl} from 'd3-color';
import {cssClass} from '../styles';
Expand Down
3 changes: 2 additions & 1 deletion src/ui/EngineRanking.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {ACellTableSection, GridStyleManager, IAbortAblePromise, ICellRenderContext, IExceptionContext, isAbortAble, isAsyncUpdate, isLoadingCell, ITableSection, nonUniformContext, PrefetchMixin, tableIds, uniformContext} from 'lineupengine';
import {HOVER_DELAY_SHOW_DETAIL, ILineUpFlags} from '../interfaces';
import {ILineUpFlags} from '../interfaces';
import {HOVER_DELAY_SHOW_DETAIL} from '../config';
import {AEventDispatcher, clear, debounce, IEventContext, IEventHandler, IEventListener} from '../internal';
import {Column, defaultGroup, IGroupData, IGroupItem, IGroupMeta, IOrderedGroup, isGroup, isMultiLevelColumn, Ranking, StackColumn} from '../model';
import {IImposer, IRenderCallback, IRenderContext} from '../renderer';
Expand Down
3 changes: 2 additions & 1 deletion src/ui/dialogs/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export {IDialogOptions, default as ADialog, IDialogContext} from './ADialog';
export {default as ADialog} from './ADialog';
export * from './ADialog';
2 changes: 1 addition & 1 deletion src/ui/header.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {MIN_LABEL_WIDTH} from '../interfaces';
import {MIN_LABEL_WIDTH} from '../config';
import {equalArrays, dragAble, dropAble, hasDnDType, IDropResult} from '../internal';
import {categoryOf, getSortType} from '../model';
import {createNestedDesc, createReduceDesc, createStackDesc, IColumnDesc, isArrayColumn, isBoxPlotColumn, isCategoricalColumn, isMapColumn, isNumberColumn, isNumbersColumn, Column, ImpositionCompositeColumn, ImpositionCompositesColumn, createImpositionDesc, createImpositionsDesc, ImpositionBoxPlotColumn, createImpositionBoxPlotDesc, CompositeColumn, IMultiLevelColumn, isMultiLevelColumn} from '../model';
Expand Down
Loading

0 comments on commit 49639fb

Please sign in to comment.