h2o-library 2.2.0 → 2.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/dist/charts/charts/src/bar/chart-bar.d.ts +2 -0
  3. package/dist/charts/charts/src/chart/chart.d.ts +1 -1
  4. package/dist/charts/charts/src/heatmap/chart-heatmap.d.ts +9 -2
  5. package/dist/charts/charts/src/waterfall/chart-waterfall.d.ts +23 -7
  6. package/dist/charts/index.cjs.js +1 -1
  7. package/dist/charts/index.js +1 -1
  8. package/dist/charts/src/bar/chart-bar.d.ts +2 -0
  9. package/dist/charts/src/chart/chart.d.ts +1 -1
  10. package/dist/charts/src/heatmap/chart-heatmap.d.ts +9 -2
  11. package/dist/charts/src/waterfall/chart-waterfall.d.ts +23 -7
  12. package/dist/esm/charts/src/bar/chart-bar.d.ts +2 -0
  13. package/dist/esm/charts/src/chart/chart.d.ts +1 -1
  14. package/dist/esm/charts/src/heatmap/chart-heatmap.d.ts +9 -2
  15. package/dist/esm/charts/src/waterfall/chart-waterfall.d.ts +23 -7
  16. package/dist/hooks/charts/src/bar/chart-bar.d.ts +2 -0
  17. package/dist/hooks/charts/src/chart/chart.d.ts +1 -1
  18. package/dist/hooks/charts/src/heatmap/chart-heatmap.d.ts +9 -2
  19. package/dist/hooks/charts/src/waterfall/chart-waterfall.d.ts +23 -7
  20. package/dist/types/charts/src/bar/chart-bar.d.ts +2 -0
  21. package/dist/types/charts/src/chart/chart.d.ts +1 -1
  22. package/dist/types/charts/src/heatmap/chart-heatmap.d.ts +9 -2
  23. package/dist/types/charts/src/waterfall/chart-waterfall.d.ts +23 -7
  24. package/dist/utils/charts/src/bar/chart-bar.d.ts +2 -0
  25. package/dist/utils/charts/src/chart/chart.d.ts +1 -1
  26. package/dist/utils/charts/src/heatmap/chart-heatmap.d.ts +9 -2
  27. package/dist/utils/charts/src/waterfall/chart-waterfall.d.ts +23 -7
  28. package/package.json +1 -1
@@ -1,9 +1,16 @@
1
1
  import React from "react";
2
2
  import "../../charts.css";
3
+ /**
4
+ * A cell value. A `number` is colored by intensity as usual. A `string` is a
5
+ * final, non-numeric result straight from the backend (e.g. "N/A" for a
6
+ * percentage whose denominator is 0) — it is shown verbatim in a neutral,
7
+ * grayed-out cell and excluded from the color scale.
8
+ */
9
+ export type HeatmapCell = number | string;
3
10
  export interface HeatmapData {
4
11
  rows: string[];
5
12
  columns: string[];
6
- matrix: number[][];
13
+ matrix: HeatmapCell[][];
7
14
  }
8
15
  export interface HeatmapChartProps {
9
16
  data: HeatmapData;
@@ -13,6 +20,6 @@ export interface HeatmapChartProps {
13
20
  className?: string;
14
21
  onRowClick?: (row: string, event: React.MouseEvent<HTMLDivElement>) => void;
15
22
  onColumnClick?: (column: string, event: React.MouseEvent<HTMLDivElement>) => void;
16
- onCellClick?: (row: string, column: string, value: number, event: React.MouseEvent<HTMLDivElement>) => void;
23
+ onCellClick?: (row: string, column: string, value: HeatmapCell, event: React.MouseEvent<HTMLDivElement>) => void;
17
24
  }
18
25
  export declare const HeatmapChart: ({ data, showValue, showPercentage, height, className, onRowClick, onColumnClick, onCellClick, }: HeatmapChartProps) => import("react/jsx-runtime").JSX.Element;
@@ -12,7 +12,27 @@ export interface WaterfallFeature {
12
12
  value?: number | string;
13
13
  contribution: number;
14
14
  }
15
- export type ShapRecord = Record<string, number | string>;
15
+ /** One feature entry inside a {@link ShapExplanation}. */
16
+ export interface ShapFeature {
17
+ name: string;
18
+ prob: number;
19
+ value?: number | string;
20
+ }
21
+ /**
22
+ * The structured SHAP explanation object. Passed straight to
23
+ * {@link WaterfallChartProps.data} with no transform.
24
+ */
25
+ export interface ShapExplanation {
26
+ recordId?: number;
27
+ losRecordId?: number;
28
+ probabilityDischargeNext2Days?: number;
29
+ fx: number;
30
+ efx: number;
31
+ otherFactorsProb?: number;
32
+ otherFactorsValue?: number;
33
+ text?: string;
34
+ features: ShapFeature[];
35
+ }
16
36
  export interface WaterfallColors {
17
37
  positive?: string;
18
38
  negative?: string;
@@ -25,16 +45,12 @@ export interface WaterfallBarDatum {
25
45
  contribution: number;
26
46
  }
27
47
  export interface WaterfallChartProps {
28
- data: WaterfallFeature[] | ShapRecord;
29
- baseValue?: number;
30
- prediction?: number;
48
+ data: ShapExplanation;
31
49
  maxFeatures?: number;
32
50
  colors?: WaterfallColors;
33
51
  compact?: boolean;
34
52
  height?: number;
35
53
  className?: string;
36
- probSuffix?: string;
37
- valueSuffix?: string;
38
54
  onBarClick?: (datum: WaterfallBarDatum, index: number, event: React.MouseEvent<SVGElement>) => void;
39
55
  }
40
- export declare const WaterfallChart: ({ data, baseValue, prediction, maxFeatures, colors, compact, height, className, probSuffix, valueSuffix, onBarClick, }: WaterfallChartProps) => import("react/jsx-runtime").JSX.Element;
56
+ export declare const WaterfallChart: ({ data, maxFeatures, colors, compact, height, className, onBarClick, }: WaterfallChartProps) => import("react/jsx-runtime").JSX.Element;
@@ -10,6 +10,8 @@ export interface BarSeriesConfig {
10
10
  color: string;
11
11
  unit?: string;
12
12
  stackId?: string;
13
+ labelKey?: string;
14
+ labelColor?: string;
13
15
  }
14
16
  export interface BarChartProps {
15
17
  data: BarChartDataPoint[];
@@ -29,7 +29,7 @@ type BarChartSpecificProps = {
29
29
  layout?: "single" | "grouped" | "stacked" | "grouped-stacked";
30
30
  orientation?: "vertical" | "horizontal";
31
31
  };
32
- type WaterfallSpecificProps = Pick<WaterfallChartProps, "baseValue" | "prediction" | "maxFeatures" | "colors" | "compact" | "probSuffix" | "valueSuffix" | "onBarClick">;
32
+ type WaterfallSpecificProps = Pick<WaterfallChartProps, "maxFeatures" | "colors" | "compact" | "onBarClick">;
33
33
  type ChartTypeSpecificProps<T extends ChartType> = T extends "bar" ? BarChartSpecificProps : T extends "waterfall" ? WaterfallSpecificProps : Record<string, never>;
34
34
  export type ChartProps<T extends ChartType> = BaseChartProps & {
35
35
  data: BaseChartData[T];
@@ -1,9 +1,16 @@
1
1
  import React from "react";
2
2
  import "../../charts.css";
3
+ /**
4
+ * A cell value. A `number` is colored by intensity as usual. A `string` is a
5
+ * final, non-numeric result straight from the backend (e.g. "N/A" for a
6
+ * percentage whose denominator is 0) — it is shown verbatim in a neutral,
7
+ * grayed-out cell and excluded from the color scale.
8
+ */
9
+ export type HeatmapCell = number | string;
3
10
  export interface HeatmapData {
4
11
  rows: string[];
5
12
  columns: string[];
6
- matrix: number[][];
13
+ matrix: HeatmapCell[][];
7
14
  }
8
15
  export interface HeatmapChartProps {
9
16
  data: HeatmapData;
@@ -13,6 +20,6 @@ export interface HeatmapChartProps {
13
20
  className?: string;
14
21
  onRowClick?: (row: string, event: React.MouseEvent<HTMLDivElement>) => void;
15
22
  onColumnClick?: (column: string, event: React.MouseEvent<HTMLDivElement>) => void;
16
- onCellClick?: (row: string, column: string, value: number, event: React.MouseEvent<HTMLDivElement>) => void;
23
+ onCellClick?: (row: string, column: string, value: HeatmapCell, event: React.MouseEvent<HTMLDivElement>) => void;
17
24
  }
18
25
  export declare const HeatmapChart: ({ data, showValue, showPercentage, height, className, onRowClick, onColumnClick, onCellClick, }: HeatmapChartProps) => import("react/jsx-runtime").JSX.Element;
@@ -12,7 +12,27 @@ export interface WaterfallFeature {
12
12
  value?: number | string;
13
13
  contribution: number;
14
14
  }
15
- export type ShapRecord = Record<string, number | string>;
15
+ /** One feature entry inside a {@link ShapExplanation}. */
16
+ export interface ShapFeature {
17
+ name: string;
18
+ prob: number;
19
+ value?: number | string;
20
+ }
21
+ /**
22
+ * The structured SHAP explanation object. Passed straight to
23
+ * {@link WaterfallChartProps.data} with no transform.
24
+ */
25
+ export interface ShapExplanation {
26
+ recordId?: number;
27
+ losRecordId?: number;
28
+ probabilityDischargeNext2Days?: number;
29
+ fx: number;
30
+ efx: number;
31
+ otherFactorsProb?: number;
32
+ otherFactorsValue?: number;
33
+ text?: string;
34
+ features: ShapFeature[];
35
+ }
16
36
  export interface WaterfallColors {
17
37
  positive?: string;
18
38
  negative?: string;
@@ -25,16 +45,12 @@ export interface WaterfallBarDatum {
25
45
  contribution: number;
26
46
  }
27
47
  export interface WaterfallChartProps {
28
- data: WaterfallFeature[] | ShapRecord;
29
- baseValue?: number;
30
- prediction?: number;
48
+ data: ShapExplanation;
31
49
  maxFeatures?: number;
32
50
  colors?: WaterfallColors;
33
51
  compact?: boolean;
34
52
  height?: number;
35
53
  className?: string;
36
- probSuffix?: string;
37
- valueSuffix?: string;
38
54
  onBarClick?: (datum: WaterfallBarDatum, index: number, event: React.MouseEvent<SVGElement>) => void;
39
55
  }
40
- export declare const WaterfallChart: ({ data, baseValue, prediction, maxFeatures, colors, compact, height, className, probSuffix, valueSuffix, onBarClick, }: WaterfallChartProps) => import("react/jsx-runtime").JSX.Element;
56
+ export declare const WaterfallChart: ({ data, maxFeatures, colors, compact, height, className, onBarClick, }: WaterfallChartProps) => import("react/jsx-runtime").JSX.Element;
@@ -10,6 +10,8 @@ export interface BarSeriesConfig {
10
10
  color: string;
11
11
  unit?: string;
12
12
  stackId?: string;
13
+ labelKey?: string;
14
+ labelColor?: string;
13
15
  }
14
16
  export interface BarChartProps {
15
17
  data: BarChartDataPoint[];
@@ -29,7 +29,7 @@ type BarChartSpecificProps = {
29
29
  layout?: "single" | "grouped" | "stacked" | "grouped-stacked";
30
30
  orientation?: "vertical" | "horizontal";
31
31
  };
32
- type WaterfallSpecificProps = Pick<WaterfallChartProps, "baseValue" | "prediction" | "maxFeatures" | "colors" | "compact" | "probSuffix" | "valueSuffix" | "onBarClick">;
32
+ type WaterfallSpecificProps = Pick<WaterfallChartProps, "maxFeatures" | "colors" | "compact" | "onBarClick">;
33
33
  type ChartTypeSpecificProps<T extends ChartType> = T extends "bar" ? BarChartSpecificProps : T extends "waterfall" ? WaterfallSpecificProps : Record<string, never>;
34
34
  export type ChartProps<T extends ChartType> = BaseChartProps & {
35
35
  data: BaseChartData[T];
@@ -1,9 +1,16 @@
1
1
  import React from "react";
2
2
  import "../../charts.css";
3
+ /**
4
+ * A cell value. A `number` is colored by intensity as usual. A `string` is a
5
+ * final, non-numeric result straight from the backend (e.g. "N/A" for a
6
+ * percentage whose denominator is 0) — it is shown verbatim in a neutral,
7
+ * grayed-out cell and excluded from the color scale.
8
+ */
9
+ export type HeatmapCell = number | string;
3
10
  export interface HeatmapData {
4
11
  rows: string[];
5
12
  columns: string[];
6
- matrix: number[][];
13
+ matrix: HeatmapCell[][];
7
14
  }
8
15
  export interface HeatmapChartProps {
9
16
  data: HeatmapData;
@@ -13,6 +20,6 @@ export interface HeatmapChartProps {
13
20
  className?: string;
14
21
  onRowClick?: (row: string, event: React.MouseEvent<HTMLDivElement>) => void;
15
22
  onColumnClick?: (column: string, event: React.MouseEvent<HTMLDivElement>) => void;
16
- onCellClick?: (row: string, column: string, value: number, event: React.MouseEvent<HTMLDivElement>) => void;
23
+ onCellClick?: (row: string, column: string, value: HeatmapCell, event: React.MouseEvent<HTMLDivElement>) => void;
17
24
  }
18
25
  export declare const HeatmapChart: ({ data, showValue, showPercentage, height, className, onRowClick, onColumnClick, onCellClick, }: HeatmapChartProps) => import("react/jsx-runtime").JSX.Element;
@@ -12,7 +12,27 @@ export interface WaterfallFeature {
12
12
  value?: number | string;
13
13
  contribution: number;
14
14
  }
15
- export type ShapRecord = Record<string, number | string>;
15
+ /** One feature entry inside a {@link ShapExplanation}. */
16
+ export interface ShapFeature {
17
+ name: string;
18
+ prob: number;
19
+ value?: number | string;
20
+ }
21
+ /**
22
+ * The structured SHAP explanation object. Passed straight to
23
+ * {@link WaterfallChartProps.data} with no transform.
24
+ */
25
+ export interface ShapExplanation {
26
+ recordId?: number;
27
+ losRecordId?: number;
28
+ probabilityDischargeNext2Days?: number;
29
+ fx: number;
30
+ efx: number;
31
+ otherFactorsProb?: number;
32
+ otherFactorsValue?: number;
33
+ text?: string;
34
+ features: ShapFeature[];
35
+ }
16
36
  export interface WaterfallColors {
17
37
  positive?: string;
18
38
  negative?: string;
@@ -25,16 +45,12 @@ export interface WaterfallBarDatum {
25
45
  contribution: number;
26
46
  }
27
47
  export interface WaterfallChartProps {
28
- data: WaterfallFeature[] | ShapRecord;
29
- baseValue?: number;
30
- prediction?: number;
48
+ data: ShapExplanation;
31
49
  maxFeatures?: number;
32
50
  colors?: WaterfallColors;
33
51
  compact?: boolean;
34
52
  height?: number;
35
53
  className?: string;
36
- probSuffix?: string;
37
- valueSuffix?: string;
38
54
  onBarClick?: (datum: WaterfallBarDatum, index: number, event: React.MouseEvent<SVGElement>) => void;
39
55
  }
40
- export declare const WaterfallChart: ({ data, baseValue, prediction, maxFeatures, colors, compact, height, className, probSuffix, valueSuffix, onBarClick, }: WaterfallChartProps) => import("react/jsx-runtime").JSX.Element;
56
+ export declare const WaterfallChart: ({ data, maxFeatures, colors, compact, height, className, onBarClick, }: WaterfallChartProps) => import("react/jsx-runtime").JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "h2o-library",
3
- "version": "2.2.0",
3
+ "version": "2.2.2",
4
4
  "description": "A set of components for H2O Apps development",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/esm/index.js",