forked from metabase/metabase
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sankey chart visual tests (metabase#49457)
* sankey visual specs, polish * Update Loki Snapshots * improve type --------- Co-authored-by: Metabase Automation <github-automation@metabase.com>
- Loading branch information
1 parent
25bab86
commit 095f1a1
Showing
35 changed files
with
3,477 additions
and
19 deletions.
There are no files selected for viewing
Binary file modified
BIN
-8 Bytes
(100%)
...bed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Month_Year.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+0 Bytes
(100%)
...rEmbeddedDashboardView_filters_Dark_Theme_Date_Filter_Quarter_Year_Dropdown.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+136 Bytes
(100%)
...p_embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Range.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-38 Bytes
(100%)
...mbed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Date_Filter_Relative.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-115 Bytes
(99%)
...ference/chrome_laptop_embed_PublicOrEmbeddedQuestionView_Dark_Theme_Default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-78 Bytes
(100%)
...erence/chrome_laptop_embed_PublicOrEmbeddedQuestionView_Light_Theme_Default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+80 Bytes
(100%)
.../chrome_laptop_embed_PublicOrEmbeddedQuestionView_Transparent_Theme_Default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+14.3 KB
.loki/reference/chrome_laptop_viz_SankeyChart_Sankey_Disconnected_Graphs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+31.2 KB
.loki/reference/chrome_laptop_viz_SankeyChart_Sankey_Edge_Labels_Auto.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+32 KB
.loki/reference/chrome_laptop_viz_SankeyChart_Sankey_Edge_Labels_Compact.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+30.8 KB
.loki/reference/chrome_laptop_viz_SankeyChart_Sankey_Edge_Labels_Full.png
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.
Binary file added
BIN
+94.6 KB
.loki/reference/chrome_laptop_viz_SankeyChart_Sankey_Node_Align_Justify.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+87.4 KB
.loki/reference/chrome_laptop_viz_SankeyChart_Sankey_Node_Align_Left.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+87.6 KB
.loki/reference/chrome_laptop_viz_SankeyChart_Sankey_Node_Align_Right.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+86.2 KB
.loki/reference/chrome_laptop_viz_SankeyChart_Sankey_Target_Color_Edges.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+12.9 KB
.loki/reference/chrome_laptop_viz_SankeyChart_Sankey_Unaggregated_Data.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+86.5 KB
.loki/reference/chrome_laptop_viz_SankeyChart_Sankey_With_Edges_Labels.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import type { ColorPalette } from "metabase/lib/colors/types"; | ||
import { DEFAULT_VISUALIZATION_THEME } from "metabase/visualizations/shared/utils/theme"; | ||
import type { RenderingContext } from "metabase/visualizations/types"; | ||
|
||
import { createColorGetter } from "../lib/colors"; | ||
|
||
import { measureTextHeight, measureTextWidth } from "./text"; | ||
|
||
export const createStaticRenderingContext = ( | ||
colors?: ColorPalette, | ||
): RenderingContext => { | ||
const getColor = createColorGetter(colors); | ||
|
||
return { | ||
getColor, | ||
measureText: (text, style) => { | ||
const size = | ||
typeof style.size === "number" ? style.size : parseInt(style.size); | ||
const weight = | ||
typeof style.weight === "number" | ||
? style.weight | ||
: parseInt(style.weight); | ||
|
||
if (!isFinite(size) || !isFinite(weight)) { | ||
throw new Error( | ||
`Incompatible for static rendering font style: ${JSON.stringify( | ||
style, | ||
)} `, | ||
); | ||
} | ||
return measureTextWidth(text, size, weight); | ||
}, | ||
measureTextHeight: (_, style) => | ||
measureTextHeight( | ||
typeof style.size === "number" ? style.size : parseInt(style.size), | ||
), | ||
fontFamily: "Lato, 'Helvetica Neue', Helvetica, Arial, sans-serif", | ||
theme: DEFAULT_VISUALIZATION_THEME, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
frontend/src/metabase/visualizations/visualizations/SankeyChart/SankeyChart.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import type { StoryFn } from "@storybook/react"; | ||
|
||
import { IsomorphicVisualizationStory } from "__support__/storybook"; | ||
import type { StaticChartProps } from "metabase/static-viz/components/StaticVisualization"; | ||
|
||
import * as data from "./stories-data"; | ||
|
||
export default { | ||
title: "viz/SankeyChart", | ||
component: IsomorphicVisualizationStory, | ||
}; | ||
|
||
const Template: StoryFn<StaticChartProps> = args => { | ||
return <IsomorphicVisualizationStory {...args} />; | ||
}; | ||
|
||
export const SankeyUnaggregatedData = { | ||
render: Template, | ||
args: { | ||
rawSeries: data.sankeyUnaggregatedData, | ||
}, | ||
}; | ||
|
||
export const SankeyWithEdgesLabels = { | ||
render: Template, | ||
args: { | ||
rawSeries: data.sankeyWithEdgesLabels, | ||
}, | ||
}; | ||
|
||
export const SankeyNodeAlignJustify = { | ||
render: Template, | ||
args: { | ||
rawSeries: data.sankeyNodeAlignJustify, | ||
}, | ||
}; | ||
|
||
export const SankeyNodeAlignLeft = { | ||
render: Template, | ||
args: { | ||
rawSeries: data.sankeyNodeAlignLeft, | ||
}, | ||
}; | ||
|
||
export const SankeyNodeAlignRight = { | ||
render: Template, | ||
args: { | ||
rawSeries: data.sankeyNodeAlignRight, | ||
}, | ||
}; | ||
|
||
export const SankeyDisconnectedGraphs = { | ||
render: Template, | ||
args: { | ||
rawSeries: data.sankeyDisconnectedGraphs, | ||
}, | ||
}; | ||
|
||
export const SankeyGrayEdges = { | ||
render: Template, | ||
args: { | ||
rawSeries: data.sankeyGrayEdges, | ||
}, | ||
}; | ||
|
||
export const SankeyTargetColorEdges = { | ||
render: Template, | ||
args: { | ||
rawSeries: data.sankeyTargetColorEdges, | ||
}, | ||
}; | ||
|
||
export const SankeyEdgeLabelsAuto = { | ||
render: Template, | ||
args: { | ||
rawSeries: data.sankeyEdgeLabelsAuto, | ||
}, | ||
}; | ||
|
||
export const SankeyEdgeLabelsFull = { | ||
render: Template, | ||
args: { | ||
rawSeries: data.sankeyEdgeLabelsFull, | ||
}, | ||
}; | ||
|
||
export const SankeyEdgeLabelsCompact = { | ||
render: Template, | ||
args: { | ||
rawSeries: data.sankeyEdgeLabelsCompact, | ||
}, | ||
}; |
25 changes: 25 additions & 0 deletions
25
frontend/src/metabase/visualizations/visualizations/SankeyChart/stories-data/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import sankeyDisconnectedGraphs from "./sankey-disconnected-graphs.json"; | ||
import sankeyEdgeLabelsAuto from "./sankey-edge-labels-auto.json"; | ||
import sankeyEdgeLabelsCompact from "./sankey-edge-labels-compact.json"; | ||
import sankeyEdgeLabelsFull from "./sankey-edge-labels-full.json"; | ||
import sankeyGrayEdges from "./sankey-gray-edges.json"; | ||
import sankeyNodeAlignJustify from "./sankey-node-align-justify.json"; | ||
import sankeyNodeAlignLeft from "./sankey-node-align-left.json"; | ||
import sankeyNodeAlignRight from "./sankey-node-align-right.json"; | ||
import sankeyTargetColorEdges from "./sankey-target-color-edges.json"; | ||
import sankeyUnaggregatedData from "./sankey-unaggregated-data.json"; | ||
import sankeyWithEdgesLabels from "./sankey-with-edges-labels.json"; | ||
|
||
export { | ||
sankeyDisconnectedGraphs, | ||
sankeyEdgeLabelsAuto, | ||
sankeyEdgeLabelsCompact, | ||
sankeyEdgeLabelsFull, | ||
sankeyGrayEdges, | ||
sankeyNodeAlignJustify, | ||
sankeyNodeAlignLeft, | ||
sankeyNodeAlignRight, | ||
sankeyTargetColorEdges, | ||
sankeyUnaggregatedData, | ||
sankeyWithEdgesLabels, | ||
}; |
Oops, something went wrong.