Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
47148ce7
Unverified
Commit
47148ce7
authored
10 months ago
by
Emmad Usmani
Committed by
GitHub
10 months ago
Browse files
Options
Downloads
Patches
Plain Diff
add + symbol to percent change tooltip (#42614)
parent
09022267
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
e2e/test/scenarios/visualizations-charts/line-bar-tooltips.cy.spec.js
+10
-10
10 additions, 10 deletions
...narios/visualizations-charts/line-bar-tooltips.cy.spec.js
frontend/src/metabase/lib/formatting/numbers.tsx
+10
-6
10 additions, 6 deletions
frontend/src/metabase/lib/formatting/numbers.tsx
with
20 additions
and
16 deletions
e2e/test/scenarios/visualizations-charts/line-bar-tooltips.cy.spec.js
+
10
−
10
View file @
47148ce7
...
...
@@ -35,7 +35,7 @@ function testSumTotalChange(tooltipSelector = showTooltipForCircleInSeries) {
testTooltipText
([
[
"
Created At
"
,
"
2023
"
],
[
"
Sum of Total
"
,
"
205,256.02
"
],
[
"
Compared to previous year
"
,
"
386.89%
"
],
[
"
Compared to previous year
"
,
"
+
386.89%
"
],
]);
}
...
...
@@ -106,7 +106,7 @@ function testAvgTotalChange(tooltipSelector = showTooltipForCircleInSeries) {
testTooltipText
([
[
"
Created At
"
,
"
2023
"
],
[
"
Average of Total
"
,
"
56.86
"
],
[
"
Compared to previous year
"
,
"
0.34%
"
],
[
"
Compared to previous year
"
,
"
+
0.34%
"
],
]);
}
...
...
@@ -140,7 +140,7 @@ function testCumSumChange(testFirstTooltip = true) {
testTooltipText
([
[
"
Created At
"
,
"
2023
"
],
[
"
Cumulative sum of Quantity
"
,
"
17,587
"
],
[
"
Compared to previous year
"
,
"
443.48%
"
],
[
"
Compared to previous year
"
,
"
+
443.48%
"
],
]);
}
...
...
@@ -169,7 +169,7 @@ function testAvgDiscountChange() {
testTooltipText
([
[
"
Created At
"
,
"
2023
"
],
[
"
Average of Discount
"
,
"
5.41
"
],
[
"
Compared to previous year
"
,
"
7.54%
"
],
[
"
Compared to previous year
"
,
"
+
7.54%
"
],
]);
}
...
...
@@ -185,7 +185,7 @@ function testSumDiscountChange() {
testTooltipText
([
[
"
Created At
"
,
"
2023
"
],
[
"
Sum of Discount
"
,
"
1,953.08
"
],
[
"
Compared to previous year
"
,
"
470.93%
"
],
[
"
Compared to previous year
"
,
"
+
470.93%
"
],
]);
}
...
...
@@ -531,7 +531,7 @@ describe("scenarios > visualizations > line/bar chart > tooltips", () => {
testTooltipText
([
[
"
Created At
"
,
"
May 2022
"
],
[
"
Sum of Total
"
,
"
1,265.72
"
],
[
"
Compared to previous month
"
,
"
2,299.19%
"
],
[
"
Compared to previous month
"
,
"
+
2,299.19%
"
],
]);
});
...
...
@@ -560,7 +560,7 @@ describe("scenarios > visualizations > line/bar chart > tooltips", () => {
testTooltipText
([
[
"
Created At
"
,
"
July 2022
"
],
[
"
Sum of Total
"
,
"
3,734.69
"
],
[
"
Compared to previous month
"
,
"
80.16%
"
],
[
"
Compared to previous month
"
,
"
+
80.16%
"
],
]);
showTooltipForCircleInSeries
(
"
#88BF4D
"
);
...
...
@@ -611,7 +611,7 @@ describe("scenarios > visualizations > line/bar chart > tooltips", () => {
display
:
"
line
"
,
};
const
APRIL_CHANGES
=
[
null
,
"
-10.89%
"
,
"
11.1%
"
,
"
-2.89%
"
];
const
APRIL_CHANGES
=
[
null
,
"
-10.89%
"
,
"
+
11.1%
"
,
"
-2.89%
"
];
const
SUM_OF_TOTAL_DST_WEEK
=
{
name
:
"
Q1
"
,
...
...
@@ -629,7 +629,7 @@ describe("scenarios > visualizations > line/bar chart > tooltips", () => {
display
:
"
line
"
,
};
const
DST_WEEK_CHANGES
=
[
null
,
"
191.48%
"
,
"
4.76%
"
,
"
-2.36%
"
];
const
DST_WEEK_CHANGES
=
[
null
,
"
+
191.48%
"
,
"
+
4.76%
"
,
"
-2.36%
"
];
const
SUM_OF_TOTAL_DST_DAY
=
{
name
:
"
Q1
"
,
...
...
@@ -647,7 +647,7 @@ describe("scenarios > visualizations > line/bar chart > tooltips", () => {
display
:
"
line
"
,
};
const
DST_DAY_CHANGES
=
[
null
,
"
27.5%
"
,
"
-26.16%
"
];
const
DST_DAY_CHANGES
=
[
null
,
"
+
27.5%
"
,
"
-26.16%
"
];
it
(
"
should not omit percent change on April
"
,
()
=>
{
setup
({
question
:
SUM_OF_TOTAL_APRIL
}).
then
(
dashboardId
=>
{
...
...
This diff is collapsed.
Click to expand it.
frontend/src/metabase/lib/formatting/numbers.tsx
+
10
−
6
View file @
47148ce7
...
...
@@ -151,12 +151,16 @@ export function formatChangeWithSign(
change
:
number
,
{
maximumFractionDigits
=
2
}
=
{},
):
string
{
return
change
===
Infinity
?
"
∞%
"
:
formatNumber
(
change
,
{
number_style
:
"
percent
"
,
maximumFractionDigits
,
});
if
(
change
===
Infinity
)
{
return
"
+∞%
"
;
}
const
formattedNumber
=
formatNumber
(
change
,
{
number_style
:
"
percent
"
,
maximumFractionDigits
,
});
return
change
>
0
?
`+
${
formattedNumber
}
`
:
formattedNumber
;
}
export
function
numberFormatterForOptions
(
options
:
FormatNumberOptionsType
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment