Skip to content

Commit

Permalink
Default coloring is everything gray, removed DefaultNumericColorProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
midlik committed May 14, 2024
1 parent 7e3da43 commit e060344
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file, following t

- Support for `Heatmap.createEmpty()` and setting data later
- Can manipulate markers via `hm.extensions.marker?.drawMarkers({...})`
- Default coloring is "everything gray", even for numeric values

## [0.9.0] - 2024-04-29

Expand Down
3 changes: 1 addition & 2 deletions src/heatmap-component/extensions/draw.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { clamp, isNil } from 'lodash';
import { Array2D } from '../data/array2d';
import { Color, createColorScale } from '../data/color';
import { Color } from '../data/color';
import { Downsampler } from '../data/downsampling';
import { Image } from '../data/image';
import { HeatmapExtension, HeatmapBehaviorBase } from '../extension';
Expand All @@ -11,7 +11,6 @@ import { Provider } from '../data/data-description';

const DefaultColor = Color.fromString('#888888');
export const DefaultColorProvider = () => DefaultColor;
export const DefaultNumericColorProviderFactory = (min: number, max: number) => createColorScale('YlOrRd', [min, max]);


export interface VisualParams {
Expand Down
10 changes: 2 additions & 8 deletions src/heatmap-component/heatmap.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Array2D } from './data/array2d';
import { Color } from './data/color';
import { DataDescription, Provider } from './data/data-description';
import { Behavior } from './extension';
import { DefaultNumericColorProviderFactory, DrawExtension, DrawExtensionParams, VisualParams } from './extensions/draw';
import { DrawExtension, DrawExtensionParams, VisualParams } from './extensions/draw';
import { MarkerBehavior, MarkerExtension } from './extensions/marker';
import { DefaultTooltipExtensionParams, TooltipExtension, TooltipExtensionParams } from './extensions/tooltip';
import { ZoomExtension, ZoomExtensionParams } from './extensions/zoom';
Expand Down Expand Up @@ -34,14 +33,9 @@ export class Heatmap<TX, TY, TItem> extends HeatmapCore<TX, TY, TItem> {
static create<TX, TY, TItem>(data: DataDescription<TX, TY, TItem>): Heatmap<TX, TY, TItem> {
const heatmap = new this(data);

let colorProvider: Provider<TX, TY, TItem, Color> | undefined = undefined;
if (heatmap.state.dataArray.isNumeric) {
const dataRange = Array2D.getRange(heatmap.state.dataArray as Array2D<number>);
colorProvider = DefaultNumericColorProviderFactory(dataRange.min, dataRange.max) as Provider<TX, TY, TItem, Color>;
}
heatmap.extensions.marker = heatmap.registerExtension(MarkerExtension) as MarkerBehavior;
heatmap.extensions.tooltip = heatmap.registerExtension(TooltipExtension);
heatmap.extensions.draw = heatmap.registerExtension(DrawExtension, { colorProvider });
heatmap.extensions.draw = heatmap.registerExtension(DrawExtension);
heatmap.extensions.zoom = heatmap.registerExtension(ZoomExtension);

return heatmap;
Expand Down

0 comments on commit e060344

Please sign in to comment.