Skip to content

Commit

Permalink
fix: default values, exported type, add name prop
Browse files Browse the repository at this point in the history
  • Loading branch information
darnautov committed Oct 5, 2020
1 parent dc02d3d commit b8081ac
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 14 deletions.
1 change: 1 addition & 0 deletions .playground/playground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export class Playground extends React.Component<any, { highlightedData?: Heatmap
/>
<Heatmap
id="heatmap1"
name="maxAnomalyScore"
ranges={[0, 3, 25, 50, 75]}
colorScale={ScaleType.Threshold}
colors={['#ffffff', '#d2e9f7', '#8bc8fb', '#fdec25', '#fba740', '#fe5050']}
Expand Down
120 changes: 115 additions & 5 deletions api/charts.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ export interface GoalSpec extends Spec {
// Warning: (ae-forgotten-export) The symbol "Config" needs to be exported by the entry point index.d.ts
//
// (undocumented)
config: RecursivePartial<Config_2>;
config: RecursivePartial<Config>;
// (undocumented)
labelMajor: string | BandFillColorAccessor;
// (undocumented)
Expand Down Expand Up @@ -765,11 +765,116 @@ export type GroupId = string;
// @alpha (undocumented)
export const Heatmap: React.FunctionComponent<SpecRequiredProps_8 & SpecOptionalProps_8>;

// Warning: (ae-forgotten-export) The symbol "Config" needs to be exported by the entry point index.d.ts
// Warning: (ae-missing-release-tag) "HeatmapConfig" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
// Warning: (ae-missing-release-tag) "Config" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type HeatmapConfig = RecursivePartial<Config>;
export interface HeatmapConfig {
brushArea: {
visible: boolean;
fill: Color;
stroke: Color;
strokeWidth: number;
};
brushMask: {
visible: boolean;
fill: Color;
};
brushTool: {
visible: boolean;
fill: Color;
};
// (undocumented)
cell: {
maxWidth: Pixels | 'fill';
maxHeight: Pixels | 'fill';
align: 'center';
label: Font & {
fontSize: Pixels;
maxWidth: Pixels | 'fill';
fill: string;
align: TextAlign;
baseline: TextBaseline;
visible: boolean;
};
border: {
strokeWidth: Pixels;
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: {
min: Pixels;
max: Pixels | 'fill';
};
cellHeight: {
min: Pixels;
max: Pixels | 'fill';
};
stroke: {
color: string;
width: number;
};
};
// (undocumented)
height: Pixels;
// (undocumented)
margin: {
left: SizeRatio;
right: SizeRatio;
top: SizeRatio;
bottom: SizeRatio;
};
// (undocumented)
maxColumnWidth: Pixels;
// (undocumented)
maxRowHeight: Pixels;
// Warning: (ae-forgotten-export) The symbol "HeatmapBrushEvent" needs to be exported by the entry point index.d.ts
//
// (undocumented)
onBrushEnd?: (brushArea: HeatmapBrushEvent) => void;
// (undocumented)
timeZone: string;
// Warning: (ae-forgotten-export) The symbol "Pixels" needs to be exported by the entry point index.d.ts
//
// (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;
fill: string;
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;
};
fill: string;
baseline: TextBaseline;
visible: boolean;
padding: number | {
left?: number;
right?: number;
top?: number;
bottom?: number;
};
formatter: (value: string | number) => string;
};
}

// Warning: (ae-forgotten-export) The symbol "Cell" needs to be exported by the entry point index.d.ts
// Warning: (ae-missing-release-tag) "HeatmapElementEvent" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
Expand All @@ -788,7 +893,7 @@ export interface HeatmapSpec extends Spec {
// (undocumented)
colorScale?: HeatmapScaleType;
// (undocumented)
config: RecursivePartial<Config>;
config: RecursivePartial<HeatmapConfig>;
// (undocumented)
data: Datum[];
// (undocumented)
Expand All @@ -797,6 +902,8 @@ export interface HeatmapSpec extends Spec {
y: any[];
};
// (undocumented)
name?: string;
// (undocumented)
ranges?: number[] | [number, number];
// (undocumented)
specType: typeof SpecTypes.Series;
Expand Down Expand Up @@ -1762,6 +1869,9 @@ export type YDomainRange = YDomainBase & DomainRange;

// Warnings were encountered during analysis:
//
// src/chart_types/heatmap/layout/types/config_types.ts:28: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:59: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:60: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:126: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:127:5 - (ae-forgotten-export) The symbol "AnimKeyframe" needs to be exported by the entry point index.d.ts
// src/chart_types/partition_chart/specs/index.ts:48:13 - (ae-forgotten-export) The symbol "NodeColorAccessor" needs to be exported by the entry point index.d.ts
Expand Down
4 changes: 2 additions & 2 deletions src/chart_types/heatmap/layout/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const config: Config = {
timeZone: 'UTC',

xAxisLabel: {
name: '',
name: 'X Value',
visible: true,
fill: 'black',
fontSize: 12,
Expand All @@ -64,7 +64,7 @@ export const config: Config = {
formatter: String,
},
yAxisLabel: {
name: '',
name: 'Y Value',
visible: true,
width: 'auto',
fill: 'black',
Expand Down
4 changes: 1 addition & 3 deletions src/chart_types/heatmap/layout/types/config_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@
* under the License.
*/

import { Color, RecursivePartial } from '../../../../utils/commons';
import { Color } from '../../../../utils/commons';
import { Pixels, SizeRatio } from '../../../partition_chart/layout/types/geometry_types';
import { Font, FontFamily, TextAlign, TextBaseline } from '../../../partition_chart/layout/types/types';
import { Cell } from './viewmodel_types';

export type HeatmapConfig = RecursivePartial<Config>;

export interface Config {
width: Pixels;
height: Pixels;
Expand Down
1 change: 1 addition & 0 deletions src/chart_types/heatmap/specs/heatmap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export interface HeatmapSpec extends Spec {
xScaleType: SeriesScales['xScaleType'];
config: RecursivePartial<Config>;
highlightedData?: { x: any[]; y: any[] };
name?: string;
}

type SpecRequiredProps = Pick<HeatmapSpec, 'id' | 'data'>;
Expand Down
6 changes: 3 additions & 3 deletions src/chart_types/heatmap/state/selectors/tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const getTooltipInfoSelector = createCachedSelector(
// X-axis value
tooltipInfo.values.push({
label: config.xAxisLabel.name,
color: RGBtoString(shape.fill.color),
color: 'transparent',
isHighlighted: false,
isVisible: true,
seriesIdentifier: {
Expand All @@ -65,7 +65,7 @@ export const getTooltipInfoSelector = createCachedSelector(
// Y-axis value
tooltipInfo.values.push({
label: config.yAxisLabel.name,
color: RGBtoString(shape.fill.color),
color: 'transparent',
isHighlighted: false,
isVisible: true,
seriesIdentifier: {
Expand All @@ -78,7 +78,7 @@ export const getTooltipInfoSelector = createCachedSelector(

// Cell value
tooltipInfo.values.push({
label: '',
label: spec.name ?? spec.id,
color: RGBtoString(shape.fill.color),
isHighlighted: false,
isVisible: true,
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export {
FillLabelConfig as PartitionFillLabel,
PartitionLayout,
} from './chart_types/partition_chart/layout/types/config_types';
export { HeatmapConfig } from './chart_types/heatmap/layout/types/config_types';
export { Config as HeatmapConfig } from './chart_types/heatmap/layout/types/config_types';
export { Layer as PartitionLayer } from './chart_types/partition_chart/specs/index';
export * from './chart_types/goal_chart/specs/index';
export {
Expand Down

0 comments on commit b8081ac

Please sign in to comment.