From ae8f64272042996fa0c479bdd5054ceeee9331d4 Mon Sep 17 00:00:00 2001 From: Sammy-T Date: Tue, 16 Mar 2021 11:12:51 -0400 Subject: [PATCH] Include pixel density to scale along Bar Chart width --- components/metrics/BarChart.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/components/metrics/BarChart.js b/components/metrics/BarChart.js index 391f869b..642b1b63 100644 --- a/components/metrics/BarChart.js +++ b/components/metrics/BarChart.js @@ -40,7 +40,7 @@ export default function BarChart({ function renderXLabel(label, index, values) { if (loading) return ''; const d = new Date(values[index].value); - const w = canvas.current.width; + const sw = canvas.current.width / window.devicePixelRatio; switch (unit) { case 'minute': @@ -49,20 +49,20 @@ export default function BarChart({ return dateFormat(d, 'p', locale); case 'day': if (records > 31) { - if (w <= 500) { + if (sw <= 250) { return index % 10 === 0 ? dateFormat(d, 'M/d', locale) : ''; } return index % 5 === 0 ? dateFormat(d, 'M/d', locale) : ''; } - if (w <= 750) { + if (sw <= 375) { return index % 2 === 0 ? dateFormat(d, 'MMM d', locale) : ''; } - if (w <= 850) { + if (sw <= 425) { return dateFormat(d, 'MMM d', locale); } return dateFormat(d, 'EEE M/d', locale); case 'month': - if (w <= 660) { + if (sw <= 330) { return index % 2 === 0 ? dateFormat(d, 'MMM', locale) : ''; } return dateFormat(d, 'MMM', locale);