Skip to content

Commit

Permalink
feat: export more types
Browse files Browse the repository at this point in the history
  • Loading branch information
kristw committed Jul 27, 2020
1 parent b8a7a6c commit 6ccefb0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 28 deletions.
14 changes: 14 additions & 0 deletions packages/vx-scale/src/types/ScaleConfig.ts
Expand Up @@ -137,8 +137,22 @@ export interface ScaleTypeToScaleConfig<
band: BandScaleConfig<DiscreteInput>;
}

/** All scale types */
export type ScaleType = keyof ScaleTypeToScaleConfig;

/** Scales that take time as domains */
export type TimeScaleType = 'time' | 'utc';

/** Scales that take continuous domains and return continuous ranges */
export type ContinuousRangeScaleType = 'linear' | 'log' | 'pow' | 'sqrt' | 'symlog' | TimeScaleType;
/** Scales that convert continuous domains to discrete ranges */
export type DiscretizingScaleType = 'quantile' | 'quantize' | 'threshold';
/** Scales that take discrete domains and return discrete ranges */
export type DiscreteScaleType = 'ordinal' | 'point' | 'band';

/** Scales that take continuous domains */
export type ContinuousDomainScaleType = ContinuousRangeScaleType | DiscretizingScaleType;

export type PickScaleConfig<
T extends ScaleType,
Output = DefaultOutput,
Expand Down
16 changes: 2 additions & 14 deletions packages/vx-stats/src/BoxPlot.tsx
@@ -1,7 +1,7 @@
import React from 'react';
import classnames from 'classnames';
import { Group } from '@vx/group';
import { PickD3Scale } from '@vx/scale';
import { PickD3Scale, ContinuousDomainScaleType } from '@vx/scale';
import { SharedProps, ChildRenderProps, LineCoords } from './types';

function verticalToHorizontal({ x1, x2, y1, y2 }: LineCoords) {
Expand All @@ -17,19 +17,7 @@ type ScaleInput = number;

export type BoxPlotProps = SharedProps & {
/** Scale for converting ScaleInput values to pixel offsets. */
valueScale: PickD3Scale<
| 'linear'
| 'log'
| 'pow'
| 'symlog'
| 'sqrt'
| 'time'
| 'utc'
| 'quantize'
| 'quantile'
| 'threshold',
number
>;
valueScale: PickD3Scale<ContinuousDomainScaleType, number>;
/** Maximum BoxPlot value. */
max?: number;
/** Minimum BoxPlot value. */
Expand Down
16 changes: 2 additions & 14 deletions packages/vx-stats/src/ViolinPlot.tsx
@@ -1,24 +1,12 @@
import React from 'react';
import cx from 'classnames';
import { scaleLinear, PickD3Scale } from '@vx/scale';
import { scaleLinear, PickD3Scale, ContinuousDomainScaleType } from '@vx/scale';
import { line, curveCardinal } from 'd3-shape';
import { BinDatum, SharedProps } from './types';

export type ViolinPlotProps<ScaleInput> = SharedProps & {
/** Scale for converting values to pixel offsets. */
valueScale: PickD3Scale<
| 'linear'
| 'log'
| 'pow'
| 'symlog'
| 'sqrt'
| 'time'
| 'utc'
| 'quantize'
| 'quantile'
| 'threshold',
number
>;
valueScale: PickD3Scale<ContinuousDomainScaleType, number>;
/** Data used to draw the violin plot glyph. Violin plot values and counts should be able to be derived from data. */
data: ScaleInput[];
/** Given an ScaleInput datum, returns the count for it. */
Expand Down

0 comments on commit 6ccefb0

Please sign in to comment.