Skip to content

Commit

Permalink
Dashboard: Fix charts with lots of zeros (#2105)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre-Gilles authored Aug 5, 2024
1 parent 399c1f5 commit 98c81f0
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
9 changes: 8 additions & 1 deletion front/src/components/boxs/chart/ApexChartAreaOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,14 @@ const getApexChartAreaOptions = ({ displayAxes, height, series, colors, locales,
},
yaxis: {
labels: {
padding: 4
padding: 4,
formatter: function(value) {

Check warning on line 55 in front/src/components/boxs/chart/ApexChartAreaOptions.js

View workflow job for this annotation

GitHub Actions / Front test

Expected method shorthand
if (Math.abs(value) < 1) {
return value; // For very low values, like crypto prices, use the normal value
} else {

Check warning on line 58 in front/src/components/boxs/chart/ApexChartAreaOptions.js

View workflow job for this annotation

GitHub Actions / Front test

Unnecessary 'else' after 'return'
return value.toFixed(2); // 2 decimal places for other values
}
}
}
},
colors,
Expand Down
9 changes: 8 additions & 1 deletion front/src/components/boxs/chart/ApexChartBarOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,14 @@ const getApexChartBarOptions = ({ displayAxes, series, colors, locales, defaultL
},
yaxis: {
labels: {
padding: 4
padding: 4,
formatter: function(value) {

Check warning on line 63 in front/src/components/boxs/chart/ApexChartBarOptions.js

View workflow job for this annotation

GitHub Actions / Front test

Expected method shorthand
if (Math.abs(value) < 1) {
return value; // For very low values, like crypto prices, use the normal value
} else {

Check warning on line 66 in front/src/components/boxs/chart/ApexChartBarOptions.js

View workflow job for this annotation

GitHub Actions / Front test

Unnecessary 'else' after 'return'
return value.toFixed(2); // 2 decimal places for other values
}
}
}
},
colors,
Expand Down
9 changes: 8 additions & 1 deletion front/src/components/boxs/chart/ApexChartLineOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,14 @@ const getApexChartLineOptions = ({ height, displayAxes, series, colors, locales,
},
yaxis: {
labels: {
padding: 4
padding: 4,
formatter: function(value) {
if (Math.abs(value) < 1) {
return value; // For very low values, like crypto prices, use the normal value
} else {
return value.toFixed(2); // 2 decimal places for other values
}
}
}
},
colors,
Expand Down
9 changes: 8 additions & 1 deletion front/src/components/boxs/chart/ApexChartStepLineOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,14 @@ const getApexChartStepLineOptions = ({ height, displayAxes, series, colors, loca
},
yaxis: {
labels: {
padding: 4
padding: 4,
formatter: function(value) {
if (Math.abs(value) < 1) {
return value; // For very low values, like crypto prices, use the normal value
} else {
return value.toFixed(2); // 2 decimal places for other values
}
}
}
},
colors,
Expand Down

0 comments on commit 98c81f0

Please sign in to comment.