From 08ab4cf78c945421e92b44707fc5026bf802fe68 Mon Sep 17 00:00:00 2001 From: CD Cabrera Date: Wed, 10 Nov 2021 15:58:07 -0500 Subject: [PATCH] fix(graphCardHelpers): ent-4510 allow product custom axes --- .../graphCardHelpers.test.js.snap | 371 +++++++++--------- .../__tests__/graphCardHelpers.test.js | 4 +- src/components/graphCard/graphCardHelpers.js | 38 +- .../__snapshots__/product.rhosak.test.js.snap | 194 +++++++++ src/config/__tests__/product.rhosak.test.js | 16 + src/config/product.rhosak.js | 11 +- 6 files changed, 433 insertions(+), 201 deletions(-) diff --git a/src/components/graphCard/__tests__/__snapshots__/graphCardHelpers.test.js.snap b/src/components/graphCard/__tests__/__snapshots__/graphCardHelpers.test.js.snap index c6220a652..b3dc19620 100644 --- a/src/components/graphCard/__tests__/__snapshots__/graphCardHelpers.test.js.snap +++ b/src/components/graphCard/__tests__/__snapshots__/graphCardHelpers.test.js.snap @@ -165,188 +165,193 @@ Object { exports[`GraphCardHelpers yAxisTickFormat should produce consistent y axis tick values: y axis tick values 1`] = ` Object { - "1": "1", - "10": "10", - "100": "100", - "1000": "1K", - "10000": "10K", - "100000": "100K", - "1000000": "1M", - "10000000": "10M", - "100000000": "100M", - "1000000000": "1B", - "10000000000": "10B", - "100000000000": "100B", - "1000000000000": "1T", - "10000000000000": "10T", - "11": "11", - "110": "110", - "1100": "1.1K", - "11000": "11K", - "110000": "110K", - "1100000": "1.1M", - "11000000": "11M", - "110000000": "110M", - "1100000000": "1.1B", - "11000000000": "11B", - "110000000000": "110B", - "1100000000000": "1.1T", - "11000000000000": "11T", - "12": "12", - "120": "120", - "1200": "1.2K", - "12000": "12K", - "120000": "120K", - "1200000": "1.2M", - "12000000": "12M", - "120000000": "120M", - "1200000000": "1.2B", - "12000000000": "12B", - "120000000000": "120B", - "1200000000000": "1.2T", - "12000000000000": "12T", - "13": "13", - "130": "130", - "1300": "1.3K", - "13000": "13K", - "130000": "130K", - "1300000": "1.3M", - "13000000": "13M", - "130000000": "130M", - "1300000000": "1.3B", - "13000000000": "13B", - "130000000000": "130B", - "1300000000000": "1.3T", - "13000000000000": "13T", - "14": "14", - "140": "140", - "1400": "1.4K", - "14000": "14K", - "140000": "140K", - "1400000": "1.4M", - "14000000": "14M", - "140000000": "140M", - "1400000000": "1.4B", - "14000000000": "14B", - "140000000000": "140B", - "1400000000000": "1.4T", - "14000000000000": "14T", - "15": "15", - "150": "150", - "1500": "1.5K", - "15000": "15K", - "150000": "150K", - "1500000": "1.5M", - "15000000": "15M", - "150000000": "150M", - "1500000000": "1.5B", - "15000000000": "15B", - "150000000000": "150B", - "1500000000000": "1.5T", - "15000000000000": "15T", - "2": "2", - "20": "20", - "200": "200", - "2000": "2K", - "20000": "20K", - "200000": "200K", - "2000000": "2M", - "20000000": "20M", - "200000000": "200M", - "2000000000": "2B", - "20000000000": "20B", - "200000000000": "200B", - "2000000000000": "2T", - "3": "3", - "30": "30", - "300": "300", - "3000": "3K", - "30000": "30K", - "300000": "300K", - "3000000": "3M", - "30000000": "30M", - "300000000": "300M", - "3000000000": "3B", - "30000000000": "30B", - "300000000000": "300B", - "3000000000000": "3T", - "4": "4", - "40": "40", - "400": "400", - "4000": "4K", - "40000": "40K", - "400000": "400K", - "4000000": "4M", - "40000000": "40M", - "400000000": "400M", - "4000000000": "4B", - "40000000000": "40B", - "400000000000": "400B", - "4000000000000": "4T", - "5": "5", - "50": "50", - "500": "500", - "5000": "5K", - "50000": "50K", - "500000": "500K", - "5000000": "5M", - "50000000": "50M", - "500000000": "500M", - "5000000000": "5B", - "50000000000": "50B", - "500000000000": "500B", - "5000000000000": "5T", - "6": "6", - "60": "60", - "600": "600", - "6000": "6K", - "60000": "60K", - "600000": "600K", - "6000000": "6M", - "60000000": "60M", - "600000000": "600M", - "6000000000": "6B", - "60000000000": "60B", - "600000000000": "600B", - "6000000000000": "6T", - "7": "7", - "70": "70", - "700": "700", - "7000": "7K", - "70000": "70K", - "700000": "700K", - "7000000": "7M", - "70000000": "70M", - "700000000": "700M", - "7000000000": "7B", - "70000000000": "70B", - "700000000000": "700B", - "7000000000000": "7T", - "8": "8", - "80": "80", - "800": "800", - "8000": "8K", - "80000": "80K", - "800000": "800K", - "8000000": "8M", - "80000000": "80M", - "800000000": "800M", - "8000000000": "8B", - "80000000000": "80B", - "800000000000": "800B", - "8000000000000": "8T", - "9": "9", - "90": "90", - "900": "900", - "9000": "9K", - "90000": "90K", - "900000": "900K", - "9000000": "9M", - "90000000": "90M", - "900000000": "900M", - "9000000000": "9B", - "90000000000": "90B", - "900000000000": "900B", - "9000000000000": "9T", + "0.00001345": "0", + "0.0000269": "0", + "0.00004035": "0", + "0.0000538": "0", + "0.00006725": "0", + "0.0000807": "0", + "0.00009415": "0", + "0.0001076": "0", + "0.00012105": "0", + "0.0001345": "0", + "0.00014795": "0", + "0.0001614": "0", + "0.00017485": "0", + "0.0001883": "0", + "0.00020175": "0", + "10.00030970249069": "10", + "100.0030970249069": "100", + "1000.0309702490689": "1K", + "1000.030970249069": "1K", + "10000.30970249069": "10K", + "100003.09702490689": "100K", + "1000030.9702490689": "1M", + "10000309.70249069": "10M", + "100003097.02490689": "100M", + "100003097.02490711": "100M", + "1000030970.249071": "1B", + "1000030970.2490711": "1B", + "10000309702.49071": "10B", + "10000309702.490711": "10B", + "100003097024.9071": "100B", + "1000030970249.071": "1T", + "10000309702490.71": "10T", + "110.00340672739759": "110", + "1100.0340672739758": "1.1K", + "11000.34067273976": "11K", + "110003.40672739758": "110K", + "1100034.0672739758": "1.1M", + "11000340.67273976": "11M", + "110003406.72739758": "110M", + "1100034067.2739782": "1.1B", + "11000340672.73978": "11B", + "110003406727.39783": "110B", + "1100034067273.978": "1.1T", + "11000340672739.781": "11T", + "120.00371642988827": "120", + "1200.0371642988828": "1.2K", + "12000.371642988828": "12K", + "120003.71642988827": "120K", + "1200037.1642988827": "1.2M", + "12000371.642988827": "12M", + "120003716.42988828": "120M", + "1200037164.2988853": "1.2B", + "12000371642.988852": "12B", + "120003716429.88853": "120B", + "1200037164298.8853": "1.2T", + "12000371642988.852": "12T", + "130.00402613237895": "130", + "1300.0402613237895": "1.3K", + "13000.402613237897": "13K", + "130004.02613237896": "130K", + "1300040.2613237896": "1.3M", + "13000402.613237895": "13M", + "130004026.13237897": "130M", + "1300040261.3237925": "1.3B", + "13000402613.237923": "13B", + "130004026132.37924": "130B", + "1300040261323.7925": "1.3T", + "13000402613237.924": "13T", + "140.00433583486966": "140", + "1400.0433583486965": "1.4K", + "14000.433583486967": "14K", + "140004.33583486965": "140K", + "1400043.3583486965": "1.4M", + "14000433.583486965": "14M", + "140004335.83486965": "140M", + "1400043358.3486996": "1.4B", + "14000433583.486994": "14B", + "140004335834.86996": "140B", + "1400043358348.6995": "1.4T", + "14000433583486.994": "14T", + "150.00464553736035": "150", + "1500.0464553736033": "1.5K", + "15000.464553736036": "15K", + "150004.64553736034": "150K", + "1500046.4553736034": "1.5M", + "15000464.553736035": "15M", + "150004645.53736034": "150M", + "1500046455.3736067": "1.5B", + "15000464553.736065": "15B", + "150004645537.36066": "150B", + "1500046455373.6064": "1.5T", + "15000464553736.066": "15T", + "20.00061940498138": "20", + "200.0061940498138": "200", + "2000.061940498138": "2K", + "20000.61940498138": "20K", + "200006.19404981378": "200K", + "2000061.9404981378": "2M", + "20000619.40498138": "20M", + "200006194.04981422": "200M", + "2000061940.498142": "2B", + "20000619404.981422": "20B", + "200006194049.8142": "200B", + "2000061940498.142": "2T", + "30.000929107472068": "30", + "300.0092910747207": "300", + "3000.092910747207": "3K", + "30000.929107472068": "30K", + "300009.2910747207": "300K", + "3000092.910747207": "3M", + "30000929.10747207": "30M", + "300009291.07472134": "300M", + "3000092910.747213": "3B", + "30000929107.472134": "30B", + "300009291074.7213": "300B", + "3000092910747.213": "3T", + "40.00123880996276": "40", + "400.0123880996276": "400", + "4000.123880996276": "4K", + "40001.23880996276": "40K", + "400012.38809962757": "400K", + "4000123.8809962757": "4M", + "40001238.80996276": "40M", + "400012388.09962845": "400M", + "4000123880.996284": "4B", + "40001238809.962845": "40B", + "400012388099.6284": "400B", + "4000123880996.284": "4T", + "50.00154851245345": "50", + "500.01548512453445": "500", + "5000.154851245345": "5K", + "50001.548512453446": "50K", + "500015.48512453446": "500K", + "5000154.851245345": "5M", + "50001548.512453444": "50M", + "500015485.12453556": "500M", + "5000154851.245355": "5B", + "50001548512.45355": "50B", + "500015485124.5355": "500B", + "5000154851245.355": "5T", + "60.001858214944136": "60", + "600.0185821494414": "600", + "6000.185821494414": "6K", + "60001.858214944135": "60K", + "600018.5821494414": "600K", + "6000185.821494414": "6M", + "60001858.21494414": "60M", + "600018582.1494427": "600M", + "6000185821.494426": "6B", + "60001858214.94427": "60B", + "600018582149.4426": "600B", + "6000185821494.426": "6T", + "70.00216791743483": "70", + "700.0216791743483": "700", + "7000.216791743484": "7K", + "70002.16791743482": "70K", + "700021.6791743482": "700K", + "7000216.791743482": "7M", + "70002167.91743483": "70M", + "700021679.1743498": "700M", + "7000216791.743497": "7B", + "70002167917.43498": "70B", + "700021679174.3497": "700B", + "7000216791743.497": "7T", + "80.00247761992551": "80", + "800.0247761992551": "800", + "8000.247761992552": "8K", + "80002.47761992551": "80K", + "800024.7761992551": "800K", + "8000247.761992551": "8M", + "80002477.61992551": "80M", + "800024776.1992569": "800M", + "8000247761.992568": "8B", + "80002477619.92569": "80B", + "800024776199.2568": "800B", + "8000247761992.568": "8T", + "90.0027873224162": "90", + "900.027873224162": "900", + "9000.27873224162": "9K", + "90002.7873224162": "90K", + "900027.873224162": "900K", + "9000278.73224162": "9M", + "90002787.3224162": "90M", + "900027873.224164": "900M", + "9000278732.241638": "9B", + "90002787322.4164": "90B", + "900027873224.164": "900B", + "9000278732241.639": "9T", } `; diff --git a/src/components/graphCard/__tests__/graphCardHelpers.test.js b/src/components/graphCard/__tests__/graphCardHelpers.test.js index 65c647e52..7af18dd70 100644 --- a/src/components/graphCard/__tests__/graphCardHelpers.test.js +++ b/src/components/graphCard/__tests__/graphCardHelpers.test.js @@ -87,8 +87,8 @@ describe('GraphCardHelpers', () => { it('yAxisTickFormat should produce consistent y axis tick values', () => { const generateTicks = (method = yAxisTickFormat) => { const ticks = {}; - for (let i = 0; i < 13; i++) { - const multiplier = Math.pow(10, i); + for (let i = 0.00001345; i < 13; i++) { + const multiplier = i < 1 ? i : Math.pow(10, i); for (let k = 1; k < 16; k++) { const incrementMultiplier = k * multiplier; ticks[incrementMultiplier] = method({ tick: incrementMultiplier }); diff --git a/src/components/graphCard/graphCardHelpers.js b/src/components/graphCard/graphCardHelpers.js index 4660ae8d3..1a71fdaee 100644 --- a/src/components/graphCard/graphCardHelpers.js +++ b/src/components/graphCard/graphCardHelpers.js @@ -79,7 +79,7 @@ const getChartXAxisLabelIncrement = granularity => { * @param {string} params.granularity See enum of RHSM_API_QUERY_GRANULARITY_TYPES * @returns {string} */ -const getTooltipDate = ({ date, granularity }) => { +const getTooltipDate = ({ date, granularity } = {}) => { const momentDate = moment.utc(date); switch (granularity) { @@ -106,17 +106,22 @@ const getTooltipDate = ({ date, granularity }) => { * Format x axis ticks. * * @param {object} params + * @param {Function} params.callback * @param {Date} params.date * @param {string} params.granularity See enum of RHSM_API_QUERY_GRANULARITY_TYPES * @param {number|string} params.tick * @param {Date} params.previousDate * @returns {string|undefined} */ -const xAxisTickFormat = ({ date, granularity, tick, previousDate }) => { +const xAxisTickFormat = ({ callback, date, granularity, tick, previousDate } = {}) => { if (!date || !granularity) { return undefined; } + if (callback) { + return callback({ callback, date, granularity, tick, previousDate }); + } + const momentDate = moment.utc(date); const isNewYear = tick !== 0 && Number.parseInt(momentDate.year(), 10) !== Number.parseInt(moment.utc(previousDate).year(), 10); @@ -159,24 +164,22 @@ const xAxisTickFormat = ({ date, granularity, tick, previousDate }) => { * Format y axis ticks. * * @param {object} params + * @param {Function} params.callback * @param {number|string} params.tick * @returns {string} */ -const yAxisTickFormat = ({ tick }) => { - const options = { - average: true, - mantissa: 1, - trimMantissa: true, - lowPrecision: false - }; - - if (!Number.isInteger(tick)) { - options.mantissa = 5; - options.lowPrecision = true; +const yAxisTickFormat = ({ callback, tick } = {}) => { + if (callback) { + return callback({ tick }); } return numbro(tick) - .format({ ...options }) + .format({ + average: true, + mantissa: 1, + trimMantissa: true, + lowPrecision: false + }) .toUpperCase(); }; @@ -193,12 +196,17 @@ const generateExtendedChartSettings = ({ settings, granularity } = {}) => ({ xAxisLabelIncrement: getChartXAxisLabelIncrement(granularity), xAxisTickFormat: ({ item, previousItem, tick }) => xAxisTickFormat({ + callback: settings?.xAxisTickFormat, tick, date: item.date, previousDate: previousItem.date, granularity }), - yAxisTickFormat + yAxisTickFormat: ({ tick }) => + yAxisTickFormat({ + callback: settings?.yAxisTickFormat, + tick + }) }); const graphCardHelpers = { diff --git a/src/config/__tests__/__snapshots__/product.rhosak.test.js.snap b/src/config/__tests__/__snapshots__/product.rhosak.test.js.snap index f6723b81c..5e7396e0c 100644 --- a/src/config/__tests__/__snapshots__/product.rhosak.test.js.snap +++ b/src/config/__tests__/__snapshots__/product.rhosak.test.js.snap @@ -48,5 +48,199 @@ exports[`Product RHOSAK config should apply graph configuration: settings 1`] = Object { "isCardTitleDescription": true, "xAxisChartLabel": [Function], + "yAxisTickFormat": [Function], +} +`; + +exports[`Product RHOSAK config should handle a custom yAxisTickFormat for floating points: yAxisTickFormat 1`] = ` +Object { + "0.00001345": "0.00001", + "0.0000269": "0.00003", + "0.00004035": "0.00004", + "0.0000538": "0.00005", + "0.00006725": "0.00007", + "0.0000807": "0.00008", + "0.00009415": "0.00009", + "0.0001076": "0.00011", + "0.00012105": "0.00012", + "0.0001345": "0.00013", + "0.00014795": "0.00015", + "0.0001614": "0.00016", + "0.00017485": "0.00017", + "0.0001883": "0.00019", + "0.00020175": "0.0002", + "10.00030970249069": "10", + "100.0030970249069": "100", + "1000.0309702490689": "1K", + "1000.030970249069": "1K", + "10000.30970249069": "10K", + "100003.09702490689": "100K", + "1000030.9702490689": "1M", + "10000309.70249069": "10M", + "100003097.02490689": "100M", + "100003097.02490711": "100M", + "1000030970.249071": "1B", + "1000030970.2490711": "1B", + "10000309702.49071": "10B", + "10000309702.490711": "10B", + "100003097024.9071": "100B", + "1000030970249.071": "1T", + "10000309702490.71": "10T", + "110.00340672739759": "110", + "1100.0340672739758": "1.1K", + "11000.34067273976": "11K", + "110003.40672739758": "110K", + "1100034.0672739758": "1.1M", + "11000340.67273976": "11M", + "110003406.72739758": "110M", + "1100034067.2739782": "1.1B", + "11000340672.73978": "11B", + "110003406727.39783": "110B", + "1100034067273.978": "1.1T", + "11000340672739.781": "11T", + "120.00371642988827": "120", + "1200.0371642988828": "1.2K", + "12000.371642988828": "12K", + "120003.71642988827": "120K", + "1200037.1642988827": "1.2M", + "12000371.642988827": "12M", + "120003716.42988828": "120M", + "1200037164.2988853": "1.2B", + "12000371642.988852": "12B", + "120003716429.88853": "120B", + "1200037164298.8853": "1.2T", + "12000371642988.852": "12T", + "130.00402613237895": "130", + "1300.0402613237895": "1.3K", + "13000.402613237897": "13K", + "130004.02613237896": "130K", + "1300040.2613237896": "1.3M", + "13000402.613237895": "13M", + "130004026.13237897": "130M", + "1300040261.3237925": "1.3B", + "13000402613.237923": "13B", + "130004026132.37924": "130B", + "1300040261323.7925": "1.3T", + "13000402613237.924": "13T", + "140.00433583486966": "140", + "1400.0433583486965": "1.4K", + "14000.433583486967": "14K", + "140004.33583486965": "140K", + "1400043.3583486965": "1.4M", + "14000433.583486965": "14M", + "140004335.83486965": "140M", + "1400043358.3486996": "1.4B", + "14000433583.486994": "14B", + "140004335834.86996": "140B", + "1400043358348.6995": "1.4T", + "14000433583486.994": "14T", + "150.00464553736035": "150", + "1500.0464553736033": "1.5K", + "15000.464553736036": "15K", + "150004.64553736034": "150K", + "1500046.4553736034": "1.5M", + "15000464.553736035": "15M", + "150004645.53736034": "150M", + "1500046455.3736067": "1.5B", + "15000464553.736065": "15B", + "150004645537.36066": "150B", + "1500046455373.6064": "1.5T", + "15000464553736.066": "15T", + "20.00061940498138": "20", + "200.0061940498138": "200", + "2000.061940498138": "2K", + "20000.61940498138": "20K", + "200006.19404981378": "200K", + "2000061.9404981378": "2M", + "20000619.40498138": "20M", + "200006194.04981422": "200M", + "2000061940.498142": "2B", + "20000619404.981422": "20B", + "200006194049.8142": "200B", + "2000061940498.142": "2T", + "30.000929107472068": "30", + "300.0092910747207": "300", + "3000.092910747207": "3K", + "30000.929107472068": "30K", + "300009.2910747207": "300K", + "3000092.910747207": "3M", + "30000929.10747207": "30M", + "300009291.07472134": "300M", + "3000092910.747213": "3B", + "30000929107.472134": "30B", + "300009291074.7213": "300B", + "3000092910747.213": "3T", + "40.00123880996276": "40", + "400.0123880996276": "400", + "4000.123880996276": "4K", + "40001.23880996276": "40K", + "400012.38809962757": "400K", + "4000123.8809962757": "4M", + "40001238.80996276": "40M", + "400012388.09962845": "400M", + "4000123880.996284": "4B", + "40001238809.962845": "40B", + "400012388099.6284": "400B", + "4000123880996.284": "4T", + "50.00154851245345": "50", + "500.01548512453445": "500", + "5000.154851245345": "5K", + "50001.548512453446": "50K", + "500015.48512453446": "500K", + "5000154.851245345": "5M", + "50001548.512453444": "50M", + "500015485.12453556": "500M", + "5000154851.245355": "5B", + "50001548512.45355": "50B", + "500015485124.5355": "500B", + "5000154851245.355": "5T", + "60.001858214944136": "60", + "600.0185821494414": "600", + "6000.185821494414": "6K", + "60001.858214944135": "60K", + "600018.5821494414": "600K", + "6000185.821494414": "6M", + "60001858.21494414": "60M", + "600018582.1494427": "600M", + "6000185821.494426": "6B", + "60001858214.94427": "60B", + "600018582149.4426": "600B", + "6000185821494.426": "6T", + "70.00216791743483": "70", + "700.0216791743483": "700", + "7000.216791743484": "7K", + "70002.16791743482": "70K", + "700021.6791743482": "700K", + "7000216.791743482": "7M", + "70002167.91743483": "70M", + "700021679.1743498": "700M", + "7000216791.743497": "7B", + "70002167917.43498": "70B", + "700021679174.3497": "700B", + "7000216791743.497": "7T", + "80.00247761992551": "80", + "800.0247761992551": "800", + "8000.247761992552": "8K", + "80002.47761992551": "80K", + "800024.7761992551": "800K", + "8000247.761992551": "8M", + "80002477.61992551": "80M", + "800024776.1992569": "800M", + "8000247761.992568": "8B", + "80002477619.92569": "80B", + "800024776199.2568": "800B", + "8000247761992.568": "8T", + "90.0027873224162": "90", + "900.027873224162": "900", + "9000.27873224162": "9K", + "90002.7873224162": "90K", + "900027.873224162": "900K", + "9000278.73224162": "9M", + "90002787.3224162": "90M", + "900027873.224164": "900M", + "9000278732.241638": "9B", + "90002787322.4164": "90B", + "900027873224.164": "900B", + "9000278732241.639": "9T", } `; diff --git a/src/config/__tests__/product.rhosak.test.js b/src/config/__tests__/product.rhosak.test.js index 45a166568..ad76b5f96 100644 --- a/src/config/__tests__/product.rhosak.test.js +++ b/src/config/__tests__/product.rhosak.test.js @@ -8,4 +8,20 @@ describe('Product RHOSAK config', () => { expect(generateChartSettings(initialGraphFilters)).toMatchSnapshot('filters'); expect(initialGraphSettings).toMatchSnapshot('settings'); }); + + it('should handle a custom yAxisTickFormat for floating points', () => { + const generateTicks = (method = config.initialGraphSettings.yAxisTickFormat) => { + const ticks = {}; + for (let i = 0.00001345; i < 13; i++) { + const multiplier = i < 1 ? i : Math.pow(10, i); + for (let k = 1; k < 16; k++) { + const incrementMultiplier = k * multiplier; + ticks[incrementMultiplier] = method({ tick: incrementMultiplier }); + } + } + return ticks; + }; + + expect(generateTicks()).toMatchSnapshot('yAxisTickFormat'); + }); }); diff --git a/src/config/product.rhosak.js b/src/config/product.rhosak.js index 28bca644b..912cc7eaa 100644 --- a/src/config/product.rhosak.js +++ b/src/config/product.rhosak.js @@ -6,6 +6,7 @@ import { chart_color_purple_100 as chartColorPurpleLight, chart_color_purple_300 as chartColorPurpleDark } from '@patternfly/react-tokens'; +import numbro from 'numbro'; import { RHSM_API_QUERY_GRANULARITY_TYPES as GRANULARITY_TYPES, RHSM_API_QUERY_SET_TYPES, @@ -74,7 +75,15 @@ const config = { ], initialGraphSettings: { isCardTitleDescription: true, - xAxisChartLabel: () => translate('curiosity-graph.label_axisX', { context: GRANULARITY_TYPES.DAILY }) + xAxisChartLabel: () => translate('curiosity-graph.label_axisX', { context: GRANULARITY_TYPES.DAILY }), + yAxisTickFormat: ({ tick }) => { + if (tick > 1) { + return numbro(tick) + .format({ average: true, mantissa: 1, trimMantissa: true, lowPrecision: false }) + .toUpperCase(); + } + return numbro(tick).format({ average: true, mantissa: 5, trimMantissa: true, lowPrecision: true }).toUpperCase(); + } }, initialToolbarFilters: [ {