Skip to content

Commit 49c35ce

Browse files
authored
fix(heatmap): improve legend item (#1317)
This fixed duplicated legend items in the heatmap legend, refactoring the current API and logic for handling color bands
1 parent 6e78d0a commit 49c35ce

20 files changed

Lines changed: 152 additions & 197 deletions
Loading
Loading
Loading
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

integration/tests/heatmap.test.ts

Lines changed: 0 additions & 33 deletions
This file was deleted.

packages/charts/api/charts.api.md

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,14 @@ export function childrenAccessor(n: ArrayEntry): HierarchyOfArrays;
435435
// @public (undocumented)
436436
export type Color = string;
437437

438+
// @alpha (undocumented)
439+
export type ColorBand = {
440+
start: number;
441+
end: number;
442+
color: Color;
443+
label?: string;
444+
};
445+
438446
// @public (undocumented)
439447
export interface ColorConfig {
440448
// (undocumented)
@@ -873,7 +881,16 @@ export interface GroupBySpec extends Spec {
873881
export type GroupId = string;
874882

875883
// @alpha (undocumented)
876-
export const Heatmap: React_2.FunctionComponent<Pick<HeatmapSpec, 'id' | 'data'> & Partial<Omit<HeatmapSpec, 'chartType' | 'specType' | 'id' | 'data'>>>;
884+
export const Heatmap: React_2.FunctionComponent<Pick<HeatmapSpec, 'id' | 'data' | 'colorScale'> & Partial<Omit<HeatmapSpec, 'chartType' | 'specType' | 'id' | 'data'>>>;
885+
886+
// @alpha (undocumented)
887+
export interface HeatmapBandsColorScale {
888+
// (undocumented)
889+
bands: Array<ColorBand>;
890+
labelFormatter?: (start: number, end: number) => string;
891+
// (undocumented)
892+
type: 'bands';
893+
}
877894

878895
// @public (undocumented)
879896
export type HeatmapBrushEvent = {
@@ -997,11 +1014,7 @@ export interface HeatmapSpec extends Spec {
9971014
// (undocumented)
9981015
chartType: typeof ChartType.Heatmap;
9991016
// (undocumented)
1000-
colors: Color[];
1001-
// Warning: (ae-forgotten-export) The symbol "HeatmapScaleType" needs to be exported by the entry point index.d.ts
1002-
//
1003-
// (undocumented)
1004-
colorScale?: HeatmapScaleType;
1017+
colorScale: HeatmapBandsColorScale;
10051018
// (undocumented)
10061019
config: RecursivePartial<HeatmapConfig>;
10071020
// (undocumented)
@@ -1014,8 +1027,6 @@ export interface HeatmapSpec extends Spec {
10141027
// (undocumented)
10151028
name?: string;
10161029
// (undocumented)
1017-
ranges?: number[] | [number, number];
1018-
// (undocumented)
10191030
specType: typeof SpecType.Series;
10201031
// (undocumented)
10211032
valueAccessor: Accessor | AccessorFn;

packages/charts/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
"d3-interpolate": "^1.4.0",
4343
"d3-scale": "^1.0.7",
4444
"d3-shape": "^1.3.4",
45-
"newtype-ts": "^0.2.4",
4645
"prop-types": "^15.7.2",
4746
"re-reselect": "^3.4.0",
4847
"react-redux": "^7.1.0",

0 commit comments

Comments
 (0)