Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
467a3d9
feat: add axis titles for heatmap
rshen91 Nov 23, 2021
1ce8069
chore: update chart api
rshen91 Nov 23, 2021
a04178c
refactor: add titles to spec vs config
rshen91 Nov 24, 2021
b854dd0
refactor: update story knobs
rshen91 Nov 24, 2021
a83e676
Merge remote-tracking branch 'upstream/master' into heatmap-titles
rshen91 Nov 29, 2021
e324ed4
refactor: pull from chart theme vs config for axes titles
rshen91 Nov 29, 2021
dd3a34d
test: add vrt test
rshen91 Nov 29, 2021
6ca4ed5
Merge remote-tracking branch 'upstream/master' into heatmap-titles
rshen91 Dec 1, 2021
7672988
fix: initial code review
rshen91 Dec 1, 2021
eb9c5ab
refactor: code review changes
rshen91 Dec 2, 2021
7e4384e
test: update stories w padding changes
rshen91 Dec 2, 2021
199c656
fix: centering based on axes not chart
rshen91 Dec 2, 2021
0ba6e13
refactor: axis title position computations
rshen91 Dec 6, 2021
a2d59ce
Remove unused theme
markov00 Dec 9, 2021
f5e2006
Add title view model and render title with that
markov00 Dec 10, 2021
15621e2
Move scenegraph file outside selectors
markov00 Dec 10, 2021
3d5a867
Deprecate width, height, margin Config properties
markov00 Dec 10, 2021
2851dbf
Renamed default config to DEFAULT_CONFIG and align the deprecation of…
markov00 Dec 10, 2021
df4de3e
Refactor dimensions calculation and label positioning
markov00 Dec 10, 2021
139b719
Merge branch 'master' into pr/1503
markov00 Dec 20, 2021
8cd19eb
Move axisTitle style to theme
markov00 Dec 20, 2021
2a10f44
Add correct title prop
markov00 Dec 20, 2021
578eaa6
Remove console log
markov00 Dec 20, 2021
14056ab
Reintroduce padding for x ticks
markov00 Dec 20, 2021
75e2a08
Update VRTs
markov00 Dec 20, 2021
9d82293
Rename ChartDims to ChartElementSizes
markov00 Dec 21, 2021
a97d47a
Reuse theme.axes.axisTitle
markov00 Dec 21, 2021
5e56096
Remove axisTitle style from API report
markov00 Dec 21, 2021
6b12cac
DRY padding calc
markov00 Dec 21, 2021
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.
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.
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.
6 changes: 6 additions & 0 deletions integration/tests/heatmap_stories.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,10 @@ describe('Heatmap stories', () => {
`http://localhost:9001/?path=/story/heatmap-alpha--time-snap&globals=theme:light&knob-dataset=${dataset}`,
);
});

it('should show x and y axis titles', async () => {
await common.expectChartAtUrlToMatchScreenshot(
'http://localhost:9001/?path=/story/heatmap-alpha--basic&knob-Show%20x%20axis%20title=true&knob-Show%20y%20axis%20title=true',
);
});
});
17 changes: 8 additions & 9 deletions packages/charts/api/charts.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1120,6 +1120,8 @@ export interface HeatmapSpec extends Spec {
// (undocumented)
xAxisLabelName: string;
// (undocumented)
xAxisTitle: string;
// (undocumented)
xScale: RasterTimeScale | OrdinalScale | LinearScale;
// (undocumented)
xSortPredicate: Predicate;
Expand All @@ -1130,6 +1132,8 @@ export interface HeatmapSpec extends Spec {
// (undocumented)
yAxisLabelName: string;
// (undocumented)
yAxisTitle: string;
// (undocumented)
ySortPredicate: Predicate;
}

Expand Down Expand Up @@ -1196,7 +1200,7 @@ export interface HeatmapStyle {
align: TextAlign;
baseline: TextBaseline;
visible: boolean;
padding: number;
padding: Pixels | Padding;
};
// (undocumented)
yAxisLabel: Font & {
Expand All @@ -1206,12 +1210,7 @@ export interface HeatmapStyle {
};
baseline: TextBaseline;
visible: boolean;
padding: number | {
left?: number;
right?: number;
top?: number;
bottom?: number;
};
padding: Pixels | Padding;
};
}

Expand Down Expand Up @@ -2132,9 +2131,9 @@ export type ShowAccessor = (value: PrimitiveValue) => boolean;
// @public
export interface SimplePadding {
// (undocumented)
inner: number;
inner: Pixels;
// (undocumented)
outer: number;
outer: Pixels;
}

// @alpha (undocumented)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,15 @@
import { ChartType } from '../../..';
import { Color, Colors } from '../../../../common/colors';
import { Pixels } from '../../../../common/geometry';
import { Box } from '../../../../common/text_utils';
import { Box, Font } from '../../../../common/text_utils';
import { Fill, Line, Rect, Stroke } from '../../../../geoms/types';
import { HeatmapBrushEvent } from '../../../../specs/settings';
import { Point } from '../../../../utils/point';
import { LIGHT_THEME } from '../../../../utils/themes/light_theme';
import { HeatmapStyle } from '../../../../utils/themes/theme';
import { Visible, HeatmapStyle } from '../../../../utils/themes/theme';
import { PrimitiveValue } from '../../../partition_chart/layout/utils/group_by_rollup';
import { HeatmapCellDatum } from '../viewmodel/viewmodel';

/** @internal */
export interface Value {
order: number;
value: string | number;
formatted: string;
}

/** @public */
export interface Cell {
x: number;
Expand Down Expand Up @@ -65,6 +58,15 @@ export interface HeatmapViewModel {
xValues: Array<TextBox>;
yValues: Array<TextBox>;
pageSize: number;
titles: Array<
Font &
Visible & {
fontSize: number;
text: string;
origin: Point;
rotation: 0 | -90;
}
>;
}

/** @internal */
Expand Down Expand Up @@ -122,6 +124,7 @@ export const nullHeatmapViewModel: HeatmapViewModel = {
yValues: [],
pageSize: 0,
cellFontSize: () => 0,
titles: [],
};

/** @internal */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,26 @@
*/

import { measureText } from '../../../../common/text_utils';
import { Dimensions } from '../../../../utils/dimensions';
import { Theme } from '../../../../utils/themes/theme';
import { ShapeViewModel, nullShapeViewModel } from '../../layout/types/viewmodel_types';
import { shapeViewModel } from '../../layout/viewmodel/viewmodel';
import { HeatmapSpec } from '../../specs';
import { HeatmapTable } from './compute_chart_dimensions';
import { ColorScale } from './get_color_scale';
import { GridHeightParams } from './get_grid_full_height';
import { ChartElementSizes, HeatmapTable } from '../../state/selectors/compute_chart_dimensions';
import { ColorScale } from '../../state/selectors/get_color_scale';

/** @internal */
export function render(
spec: HeatmapSpec,
chartDimensions: Dimensions,
elementSizes: ChartElementSizes,
heatmapTable: HeatmapTable,
colorScale: ColorScale,
bandsToHide: Array<[number, number]>,
gridHeightParams: GridHeightParams,
theme: Theme,
): ShapeViewModel {
const textMeasurer = document.createElement('canvas');
const textMeasurerCtx = textMeasurer.getContext('2d');
if (!textMeasurerCtx) {
return nullShapeViewModel();
}
return shapeViewModel(
measureText(textMeasurerCtx),
spec,
theme,
chartDimensions,
heatmapTable,
colorScale,
bandsToHide,
gridHeightParams,
);
return shapeViewModel(measureText(textMeasurerCtx), spec, theme, elementSizes, heatmapTable, colorScale, bandsToHide);
}
Loading