Skip to content

Commit

Permalink
rename V to Value
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfauquette committed Apr 5, 2024
1 parent ac713e6 commit 29a9dcd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
10 changes: 5 additions & 5 deletions packages/x-charts/src/internals/colorScale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {
OrdinalColorConfig,
} from '../models/colorMapping';

export function getSequentialColorScale<V extends number | Date>(
config: ContinuousColorConfig<V> | PiecewiseColorConfig<V>,
export function getSequentialColorScale<Value extends number | Date>(
config: ContinuousColorConfig<Value> | PiecewiseColorConfig<Value>,
) {
if (config.type === 'piecewise') {
return scaleThreshold(config.thresholds, config.colors);
Expand All @@ -15,9 +15,9 @@ export function getSequentialColorScale<V extends number | Date>(
return scaleSequential([config.min ?? 0, config.max ?? 100], config.color);
}

export function getOrdinalColorScale<V extends number | Date | string>(
config: OrdinalColorConfig<V>,
): ScaleOrdinal<V, string, null | string> | ScaleOrdinal<number, string, null | string> {
export function getOrdinalColorScale<Value extends number | Date | string>(
config: OrdinalColorConfig<Value>,
): ScaleOrdinal<Value, string, null | string> | ScaleOrdinal<number, string, null | string> {
if (config.values) {
return scaleOrdinal(config.values, config.colors).unknown(config.unknownColor ?? null);
}
Expand Down
14 changes: 7 additions & 7 deletions packages/x-charts/src/models/colorMapping.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
export interface ContinuousColorConfig<V = number | Date> {
export interface ContinuousColorConfig<Value = number | Date> {
type: 'continuous';
/**
* The minimal value of the color scale.
* @default 0
*/
min?: V;
min?: Value;
/**
* The maximal value of the color scale.
* @default 100
*/
max?: V;
max?: Value;
/**
* The colors to render. Can either be and array with the extrem colors, or an interpolation function.
*/
color: [string, string] | ((t: number) => string);
}

export interface PiecewiseColorConfig<V = number | Date> {
export interface PiecewiseColorConfig<Value = number | Date> {
type: 'piecewise';
/**
* The thresholds where color should change from one category to another.
*/
thresholds: V[];
thresholds: Value[];
/**
* The colors used for each band defined by `thresholds`.
* Should contain N+1 colors with N the number of thresholds.
*/
colors: string[];
}

export interface OrdinalColorConfig<V = number | Date | string> {
export interface OrdinalColorConfig<Value = number | Date | string> {
type: 'ordinal';
/**
* The value to map.
* If undefined, it will be integers from 0 to the number of colors.
*/
values?: V[];
values?: Value[];
/**
* The color palette.
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/x-charts/src/models/seriesType/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export type CommonSeriesType<TValue> = {
* @param {TValue} value The series' value to render.
* @returns {string} The string to dispaly.
*/
valueFormatter?: <V extends TValue>(value: V) => string;
valueFormatter?: <Value extends TValue>(value: Value) => string;
highlightScope?: Partial<HighlightScope>;
};

Expand Down

0 comments on commit 29a9dcd

Please sign in to comment.