Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(heatmap): dark mode with theme controls #1406

Merged
merged 14 commits into from
Dec 15, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions integration/tests/heatmap_stories.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Side Public License, v 1.
*/

import { eachTheme } from '../helpers';
import { common } from '../page_objects';

describe('Heatmap stories', () => {
Expand All @@ -16,10 +17,28 @@ describe('Heatmap stories', () => {
{ left: 300, top: 300 },
);
});

eachTheme.describe((_, themeParams) => {
it('should render basic heatmap', async () => {
await common.expectChartAtUrlToMatchScreenshot(
`http://localhost:9001/?path=/story/heatmap-alpha--basic${themeParams}`,
);
});

it('should render correct brush area', async () => {
await common.expectChartWithDragAtUrlToMatchScreenshot(
`http://localhost:9001/?path=/story/heatmap-alpha--basic${themeParams}`,
{ left: 200, top: 100 },
{ left: 400, top: 250 },
);
});
});

it('should maximize the label with an unique fontSize', async () => {
await page.setViewport({ width: 450, height: 600 });
await common.expectChartAtUrlToMatchScreenshot('http://localhost:9001/?path=/story/heatmap-alpha--categorical');
});

it('should maximize the label fontSize', async () => {
await page.setViewport({ width: 420, height: 600 });
await common.expectChartAtUrlToMatchScreenshot(
Expand Down
133 changes: 64 additions & 69 deletions packages/charts/api/charts.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ export function getNodeName(node: ArrayNode): string;
// Warning: (ae-forgotten-export) The symbol "SpecOptionalProps" needs to be exported by the entry point index.d.ts
//
// @alpha (undocumented)
export const Goal: React_2.FunctionComponent<SpecRequiredProps_8 & SpecOptionalProps_8>;
export const Goal: React_2.FunctionComponent<SpecRequiredProps_9 & SpecOptionalProps_9>;

// @alpha (undocumented)
export type GoalLabelAccessor = LabelAccessor<BandFillColorAccessorInput>;
Expand Down Expand Up @@ -907,8 +907,11 @@ export interface GroupBySpec extends Spec {
// @public (undocumented)
export type GroupId = string;

// Warning: (ae-forgotten-export) The symbol "SpecRequiredProps" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "SpecOptionalProps" needs to be exported by the entry point index.d.ts
//
// @alpha (undocumented)
export const Heatmap: React_2.FunctionComponent<Pick<HeatmapSpec, 'id' | 'data' | 'colorScale'> & Partial<Omit<HeatmapSpec, 'chartType' | 'specType' | 'id' | 'data'>>>;
export const Heatmap: React_2.FunctionComponent<SpecRequiredProps_8 & SpecOptionalProps_8>;
Comment on lines +1064 to +1068
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not in this PR but we should find a way to express this in the right way

Copy link
Collaborator Author

@nickofthyme nickofthyme Dec 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you elaborate what you mean here? Would #1421 solve this?


// @alpha (undocumented)
export interface HeatmapBandsColorScale {
Expand All @@ -927,10 +930,58 @@ export type HeatmapBrushEvent = {
};

// @public (undocumented)
export interface HeatmapConfig {
export type HeatmapElementEvent = [Cell, SeriesIdentifier];

// @alpha (undocumented)
export interface HeatmapSpec extends Spec {
// (undocumented)
chartType: typeof ChartType.Heatmap;
// (undocumented)
colorScale: HeatmapBandsColorScale;
// (undocumented)
data: Datum[];
// (undocumented)
highlightedData?: {
x: Array<string | number>;
y: Array<string | number>;
};
// (undocumented)
name?: string;
// (undocumented)
onBrushEnd?: (brushArea: HeatmapBrushEvent) => void;
// (undocumented)
specType: typeof SpecType.Series;
// (undocumented)
timeZone: string;
// (undocumented)
valueAccessor: Accessor | AccessorFn;
// (undocumented)
valueFormatter: (value: number) => string;
// (undocumented)
xAccessor: Accessor | AccessorFn;
// (undocumented)
xAxisLabelFormatter: (value: string | number) => string;
// (undocumented)
xAxisLabelName: string;
// (undocumented)
xScaleType: SeriesScales['xScaleType'];
// (undocumented)
xSortPredicate: Predicate;
// (undocumented)
yAccessor: Accessor | AccessorFn;
// (undocumented)
yAxisLabelFormatter: (value: string | number) => string;
// (undocumented)
yAxisLabelName: string;
// (undocumented)
ySortPredicate: Predicate;
}

// @public (undocumented)
export interface HeatmapStyle {
brushArea: {
visible: boolean;
fill: Color;
fill?: Color;
stroke: Color;
strokeWidth: number;
};
Expand Down Expand Up @@ -959,10 +1010,6 @@ export interface HeatmapConfig {
stroke: Color;
};
};
// Warning: (ae-forgotten-export) The symbol "FontFamily" needs to be exported by the entry point index.d.ts
//
// (undocumented)
fontFamily: FontFamily;
// (undocumented)
grid: {
cellWidth: {
Expand All @@ -979,40 +1026,26 @@ export interface HeatmapConfig {
};
};
// (undocumented)
height: Pixels;
// (undocumented)
margin: {
left: SizeRatio;
right: SizeRatio;
top: SizeRatio;
bottom: SizeRatio;
};
// (undocumented)
maxColumnWidth: Pixels;
// (undocumented)
maxLegendHeight?: number;
// Warning: (ae-forgotten-export) The symbol "Pixels" needs to be exported by the entry point index.d.ts
//
// (undocumented)
maxRowHeight: Pixels;
// (undocumented)
timeZone: string;
// (undocumented)
width: Pixels;
// Warning: (ae-forgotten-export) The symbol "Font" needs to be exported by the entry point index.d.ts
//
// (undocumented)
xAxisLabel: Font & {
name: string;
fontSize: Pixels;
width: Pixels | 'auto';
align: TextAlign;
baseline: TextBaseline;
visible: boolean;
padding: number;
formatter: (value: string | number) => string;
};
// (undocumented)
yAxisLabel: Font & {
name: string;
fontSize: Pixels;
width: Pixels | 'auto' | {
max: Pixels;
Expand All @@ -1025,48 +1058,9 @@ export interface HeatmapConfig {
top?: number;
bottom?: number;
};
formatter: (value: string | number) => string;
};
}

// @public (undocumented)
export type HeatmapElementEvent = [Cell, SeriesIdentifier];

// @alpha (undocumented)
export interface HeatmapSpec extends Spec {
// (undocumented)
chartType: typeof ChartType.Heatmap;
// (undocumented)
colorScale: HeatmapBandsColorScale;
// (undocumented)
config: RecursivePartial<HeatmapConfig>;
// (undocumented)
data: Datum[];
// (undocumented)
highlightedData?: {
x: Array<string | number>;
y: Array<string | number>;
};
// (undocumented)
name?: string;
// (undocumented)
specType: typeof SpecType.Series;
// (undocumented)
valueAccessor: Accessor | AccessorFn;
// (undocumented)
valueFormatter: (value: number) => string;
// (undocumented)
xAccessor: Accessor | AccessorFn;
// (undocumented)
xScaleType: SeriesScales['xScaleType'];
// (undocumented)
xSortPredicate: Predicate;
// (undocumented)
yAccessor: Accessor | AccessorFn;
// (undocumented)
ySortPredicate: Predicate;
}

// @public
export const HIERARCHY_ROOT_KEY: Key;

Expand Down Expand Up @@ -2125,6 +2119,8 @@ export interface Theme {
// (undocumented)
goal: GoalStyles;
// (undocumented)
heatmap: HeatmapStyle;
// (undocumented)
legend: LegendStyle;
lineSeriesStyle: LineSeriesStyle;
markSizeRatio?: number;
Expand Down Expand Up @@ -2297,7 +2293,7 @@ export type WeightFn = $Values<typeof WeightFn>;
// Warning: (ae-forgotten-export) The symbol "SpecOptionalProps" needs to be exported by the entry point index.d.ts
//
// @alpha (undocumented)
export const Wordcloud: React_2.FunctionComponent<SpecRequiredProps_9 & SpecOptionalProps_9>;
export const Wordcloud: React_2.FunctionComponent<SpecRequiredProps_10 & SpecOptionalProps_10>;

// @public (undocumented)
export interface WordcloudConfigs {
Expand Down Expand Up @@ -2423,11 +2419,10 @@ export type YDomainRange = YDomainBase & DomainRange & LogScaleOptions;

// Warnings were encountered during analysis:
//
// src/chart_types/heatmap/layout/types/config_types.ts:19:13 - (ae-forgotten-export) The symbol "SizeRatio" needs to be exported by the entry point index.d.ts
// src/chart_types/heatmap/layout/types/config_types.ts:47:5 - (ae-forgotten-export) The symbol "TextAlign" needs to be exported by the entry point index.d.ts
// src/chart_types/heatmap/layout/types/config_types.ts:48:5 - (ae-forgotten-export) The symbol "TextBaseline" needs to be exported by the entry point index.d.ts
// src/chart_types/partition_chart/layout/types/config_types.ts:137:5 - (ae-forgotten-export) The symbol "TimeMs" needs to be exported by the entry point index.d.ts
// src/chart_types/partition_chart/layout/types/config_types.ts:138:5 - (ae-forgotten-export) The symbol "AnimKeyframe" needs to be exported by the entry point index.d.ts
// src/chart_types/partition_chart/layout/types/config_types.ts:139:5 - (ae-forgotten-export) The symbol "TimeMs" needs to be exported by the entry point index.d.ts
// src/chart_types/partition_chart/layout/types/config_types.ts:140:5 - (ae-forgotten-export) The symbol "AnimKeyframe" needs to be exported by the entry point index.d.ts
// src/utils/themes/theme.ts:214:5 - (ae-forgotten-export) The symbol "TextAlign" needs to be exported by the entry point index.d.ts
// src/utils/themes/theme.ts:215:5 - (ae-forgotten-export) The symbol "TextBaseline" needs to be exported by the entry point index.d.ts

// (No @packageDocumentation comment for this package)

Expand Down
102 changes: 0 additions & 102 deletions packages/charts/src/chart_types/heatmap/layout/config/config.ts

This file was deleted.

Loading