Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix column scaling ("Multiply by a number") bugs #43668

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
7547960
return empty string so non-empty labels do not get hidden by empty la…
JesseSDevaney Jun 3, 2024
4c0e992
fix function name
JesseSDevaney Jun 3, 2024
27b8b68
apply scaling in transformed dataset
JesseSDevaney Jun 3, 2024
2f4234e
add missing option to OptionsType
JesseSDevaney Jun 3, 2024
a21fe9d
fix double scaling
JesseSDevaney Jun 3, 2024
3baf109
add column scaling to waterfall transformed dataset
JesseSDevaney Jun 3, 2024
0b05127
add column value scaling to dataset transform
JesseSDevaney Jun 3, 2024
b314191
fix stacked bar segment labels not responding to column scaling
JesseSDevaney Jun 3, 2024
64ed96a
fix tooltip values displayed
JesseSDevaney Jun 3, 2024
693e377
since scaling as added to transformedDataset, use transformedDataset …
JesseSDevaney Jun 4, 2024
573202a
revert changes to display percentage instead of absolute value
JesseSDevaney Jun 4, 2024
1792925
fix stacked data labels
JesseSDevaney Jun 4, 2024
efa8727
add loki variant for custom y-axis range with column scaling
JesseSDevaney Jun 4, 2024
b3e9988
fix stack segmented label formatters compact calculation
JesseSDevaney Jun 4, 2024
71eddee
scale original dataset and use that instead of modifying transformedD…
JesseSDevaney Jun 4, 2024
6d368ca
update loki snapshots
JesseSDevaney Jun 4, 2024
90960ca
fix scatter plot dataset scaling
JesseSDevaney Jun 4, 2024
cb58da6
fix tooltip values being double scaled
JesseSDevaney Jun 4, 2024
f326be4
add E2E test to validate behavior
JesseSDevaney Jun 4, 2024
26f1907
add helper for not duplicating the column scaling
JesseSDevaney Jun 4, 2024
73a8d70
port multiple y-axis metrics with column scaling fixes to RowChart
JesseSDevaney Jun 5, 2024
bab167b
add waterfall and scatterplot loki variants
JesseSDevaney Jun 5, 2024
8ca0847
fix type errors and failing unit tests
JesseSDevaney Jun 5, 2024
c735c86
fix failing unit tests
JesseSDevaney Jun 5, 2024
8888d47
update loki snapshots
JesseSDevaney Jun 5, 2024
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.
Binary file modified .loki/reference/chrome_laptop_static_viz_ScatterPlot_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_static_viz_ScatterPlot_Goal_Line.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.
62 changes: 62 additions & 0 deletions e2e/test/scenarios/visualizations-charts/bar_chart.cy.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {
chartPathWithFillColor,
echartsContainer,
getValueLabels,
createQuestion,
chartPathsWithFillColors,
} from "e2e/support/helpers";

const { ORDERS, ORDERS_ID, PEOPLE, PRODUCTS, PRODUCTS_ID } = SAMPLE_DATABASE;
Expand Down Expand Up @@ -561,4 +563,64 @@ describe("scenarios > visualizations > bar chart", () => {
cy.get(".axis.yr").should("not.exist");
});
});

it("should correctly handle bar sizes and tool-tips for multiple y-axis metrics with column scaling (#43536)", () => {
cy.signInAsAdmin();

const column_settings = { '["name","sum"]': { scale: 0.5 } };
const multiMetric = {
name: "Should split",
type: "query",
query: {
"source-table": ORDERS_ID,
aggregation: [
["sum", ["field", ORDERS.TOTAL]],
["sum", ["field", ORDERS.TOTAL]],
],
breakout: [["field", ORDERS.CREATED_AT, { "temporal-unit": "year" }]],
},
display: "bar",
visualization_settings: {
column_settings,
"graph.show_values": true,
"graph.stackable.stack_type": "stacked",
series_settings: {
sum_2: {
axis: "left",
},
sum: {
axis: "left",
},
},
},
};

createQuestion(multiMetric, { visitQuestion: true });

const [firstMetric, secondMetric] = chartPathsWithFillColors([
"#88BF4D",
"#98D9D9",
]);
firstMetric.then($metricOne => {
const { height: heightMetricOne } = $metricOne[0].getBoundingClientRect();
secondMetric.then($metricTwo => {
const { height: heightMetricTwo } =
$metricTwo[0].getBoundingClientRect();

// since the first metric is scaled to be half of the second metric
// the first bar should be half the size of the first bar
// within a given tolerance
expect(heightMetricOne - heightMetricTwo / 2).to.be.lessThan(0.1);
});
});

chartPathWithFillColor("#88BF4D").first().realHover();
popover().within(() => {
cy.contains("Sum of Total");
// half of the unscaled metric
cy.contains("21,078.43");
// full value of the unscale metric
cy.contains("42,156.87");
});
});
});
1 change: 1 addition & 0 deletions frontend/src/metabase/lib/formatting/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export interface OptionsType extends TimeOnlyOptions {
removeDay?: boolean;
removeYear?: boolean;
rich?: boolean;
scale?: number;
show_mini_bar?: boolean;
suffix?: string;
type?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@ LineCustomYAxisRangeEqualsExtents.args = {
renderingContext,
};

export const CustomYAxisRangeWithColumnScaling = Template.bind({});
CustomYAxisRangeWithColumnScaling.args = {
rawSeries: data.customYAxisRangeWithColumnScaling as any,
dashcardSettings: {},
renderingContext,
};

export const LineFullyNullDimension37902 = Template.bind({});
LineFullyNullDimension37902.args = {
rawSeries: data.lineFullyNullDimension37902 as any,
Expand Down
Loading
Loading