Skip to content

Commit

Permalink
isomorphic viz settings computation (metabase#47963)
Browse files Browse the repository at this point in the history
* isomorphic viz settings computation

* stories

* drop duplicated static formatter

* drop formatValue from the renderingContext

* clean up

* stories

* fix static charts stories

* clean up mocked env

* update sunburst formatters

* no longer injecting formatValue

* exclude modules without name

* Update Loki Snapshots

* Update Loki Snapshots

---------

Co-authored-by: Metabase Automation <[email protected]>
  • Loading branch information
alxnddr and github-automation-metabase authored Oct 8, 2024
1 parent 62861cc commit c6b0b2b
Show file tree
Hide file tree
Showing 330 changed files with 694 additions and 993 deletions.
Binary file modified .loki/reference/chrome_laptop_Design_System_colors_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 .loki/reference/chrome_laptop_Inputs_DatePicker_Dates_range.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.
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.
Binary file modified .loki/reference/chrome_laptop_static_viz_ComboChart_Default.png
Binary file modified .loki/reference/chrome_laptop_static_viz_FunnelChart_Default.png
Binary file modified .loki/reference/chrome_laptop_static_viz_Gauge_Default.png
Binary file modified .loki/reference/chrome_laptop_static_viz_Gauge_With_Formatting.png
Binary file modified .loki/reference/chrome_laptop_static_viz_PieChart_All_Negative.png
Binary file modified .loki/reference/chrome_laptop_static_viz_PieChart_All_Settings.png
Binary file modified .loki/reference/chrome_laptop_static_viz_PieChart_Colors.png
Binary file modified .loki/reference/chrome_laptop_static_viz_PieChart_Hide_Legend.png
Binary file modified .loki/reference/chrome_laptop_static_viz_PieChart_Hide_Total.png
Binary file modified .loki/reference/chrome_laptop_static_viz_PieChart_Three_Rings.png
Binary file modified .loki/reference/chrome_laptop_static_viz_PieChart_Two_Rings.png
Binary file modified .loki/reference/chrome_laptop_static_viz_ProgressBar_Default.png
Binary file modified .loki/reference/chrome_laptop_static_viz_RowChart_Default.png
Binary file modified .loki/reference/chrome_laptop_static_viz_ScalarChart_Default.png
Binary file modified .loki/reference/chrome_laptop_static_viz_ScatterPlot_Default.png
Binary file modified .loki/reference/chrome_laptop_static_viz_ScatterPlot_Goal_Line.png
Binary file modified .loki/reference/chrome_laptop_static_viz_SmartScalar_Default.png
Binary file modified .loki/reference/chrome_laptop_static_viz_WaterfallChart_Nulls.png
Binary file modified .loki/reference/chrome_laptop_viz_Funnel_Default.png
Binary file modified .loki/reference/chrome_laptop_viz_PivotTable_Default.png
Binary file modified .loki/reference/chrome_laptop_viz_TableInteractive_Default.png
Binary file modified .loki/reference/chrome_laptop_viz_TableSimple_Default.png
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { StoryFn } from "@storybook/react";

import { color } from "metabase/lib/colors";
import { formatStaticValue } from "metabase/static-viz/lib/format";
import {
measureTextHeight,
measureTextWidth,
Expand All @@ -10,26 +9,25 @@ import { DEFAULT_VISUALIZATION_THEME } from "metabase/visualizations/shared/util
import type { RenderingContext } from "metabase/visualizations/types";

import type { StaticChartProps } from "../StaticVisualization";
import { StaticVisualization } from "../StaticVisualization";

import { ComboChart } from "./ComboChart";
import { data } from "./stories-data";

export default {
title: "static-viz/ComboChart",
component: ComboChart,
component: StaticVisualization,
};

const Template: StoryFn<StaticChartProps> = args => {
return (
<div style={{ border: "1px solid black", display: "inline-block" }}>
<ComboChart {...args} isStorybook />
<StaticVisualization {...args} isStorybook />
</div>
);
};

const renderingContext: RenderingContext = {
getColor: color,
formatValue: formatStaticValue as any,
measureText: (text, style) =>
measureTextWidth(text, Number(style.size), Number(style.weight)),
measureTextHeight: (_, style) => measureTextHeight(Number(style.size)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import { getCartesianChartOption } from "metabase/visualizations/echarts/cartesi
import { Legend } from "../Legend";
import { calculateLegendRows } from "../Legend/utils";

import { computeStaticComboChartSettings } from "./settings";

const WIDTH = 540;
const HEIGHT = 360;
const LEGEND_PADDING = 8;
Expand All @@ -22,6 +20,7 @@ registerEChartsModules();

export const ComboChart = ({
rawSeries,
settings,
renderingContext,
width = WIDTH,
height = HEIGHT,
Expand All @@ -34,20 +33,15 @@ export const ComboChart = ({
height,
});

const computedVisualizationSettings = computeStaticComboChartSettings(
rawSeries,
renderingContext,
);

const chartModel = getCartesianChartModel(
rawSeries,
computedVisualizationSettings,
settings,
[],
renderingContext,
);

const legendItems = getLegendItems(chartModel.seriesModels);
const isReversed = computedVisualizationSettings["legend.is_reversed"];
const isReversed = settings["legend.is_reversed"];
const { height: legendHeight, items: legendLayoutItems } =
calculateLegendRows({
items: legendItems,
Expand All @@ -59,7 +53,7 @@ export const ComboChart = ({

const chartMeasurements = getChartMeasurements(
chartModel,
computedVisualizationSettings,
settings,
false,
width,
height,
Expand All @@ -71,7 +65,7 @@ export const ComboChart = ({
chartMeasurements,
null,
[],
computedVisualizationSettings,
settings,
WIDTH,
false,
renderingContext,
Expand Down
Loading

0 comments on commit c6b0b2b

Please sign in to comment.