Skip to content

Commit

Permalink
#26271 [UI] Text in experiment data results needs be aligned (#26578)
Browse files Browse the repository at this point in the history
* reduce decimals in graphic labels

* test

* keep two decimlas
  • Loading branch information
hmoreras authored and dsolistorres committed Nov 6, 2023
1 parent 1ae3334 commit bca23e7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export const generateDotExperimentLineChartJsOptions = ({
tooltip: {
callbacks: {
title: function (context) {
return Number(context[0].label) * 100 + '%';
return Math.round(context[0].label * 100) + '%';
},
label: function (context) {
const label = context.dataset.label || '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,8 @@ describe('DotExperimentsReportsStore', () => {
it('should has a label and data properly parsed for each dataset', (done) => {
// First data is added manually when we parse the data
const expectedDataByDataset = [
[0, 90.555, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15.25],
[0, 15.25, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 90.555]
[0, 90.56, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15.25],
[0, 15.25, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 90.56]
];
const expectedLabel = [
EXPERIMENT_MOCK_RESULTS.goals.primary.variants.DEFAULT.variantDescription,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const orderVariants = (arrayToOrder: Array<string>): Array<string> => {
* @return {number[]} - An array of conversion Rate values.
*/
export const getParsedChartData = (data: Record<string, DotResultDate>): number[] => {
return [0, ...Object.values(data).map((day) => day.conversionRate)];
return [0, ...Object.values(data).map((day) => Math.round(day.conversionRate * 100) / 100)];
};

export const getPropertyColors = (index: number): LineChartColorsProperties => {
Expand Down Expand Up @@ -212,9 +212,9 @@ const generateProbabilityDensityData = (
// Loop through the x values from 0 to 1.
for (let i = 0; i <= 1; i += step) {
// Set the x value to the current value of i.
const x = i;
const x = Number(i.toFixed(2));
// Set the y value to the value of the pdf at the current value of i.
const y = betaDist.pdf(x);
const y = Number(betaDist.pdf(x).toFixed(2));

if (!isFinite(y)) {
continue;
Expand Down

0 comments on commit bca23e7

Please sign in to comment.