This is an automated email from the ASF dual-hosted git repository. michaelsmolina pushed a commit to branch 3.0 in repository https://gitbox.apache.org/repos/asf/superset.git
commit 3ffc5b69f8e8f37f2949f8d41884ebfb81321bbc Author: Michael S. Molina <[email protected]> AuthorDate: Tue Aug 15 13:35:35 2023 -0300 fix: Calendar Heatmap day offset (#24989) (cherry picked from commit 025e4d4772e778097da7b9e1675782b73eaa887c) --- .../src/vendor/cal-heatmap.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/superset-frontend/plugins/legacy-plugin-chart-calendar/src/vendor/cal-heatmap.js b/superset-frontend/plugins/legacy-plugin-chart-calendar/src/vendor/cal-heatmap.js index 760bf0ce2b..482a315392 100644 --- a/superset-frontend/plugins/legacy-plugin-chart-calendar/src/vendor/cal-heatmap.js +++ b/superset-frontend/plugins/legacy-plugin-chart-calendar/src/vendor/cal-heatmap.js @@ -296,8 +296,21 @@ var CalHeatMap = function () { // Used mainly to convert the datas if they're not formatted like expected // Takes the fetched "data" object as argument, must return a json object // formatted like {timestamp:count, timestamp2:count2}, - afterLoadData: function (data) { - return data; + afterLoadData: function (timestamps) { + // See https://github.com/wa0x6e/cal-heatmap/issues/126#issuecomment-373301803 + const stdTimezoneOffset = date => { + const jan = new Date(date.getFullYear(), 0, 1); + const jul = new Date(date.getFullYear(), 6, 1); + return Math.max(jan.getTimezoneOffset(), jul.getTimezoneOffset()); + }; + const offset = stdTimezoneOffset(new Date()) * 60; + let results = {}; + for (let timestamp in timestamps) { + const value = timestamps[timestamp]; + timestamp = parseInt(timestamp, 10); + results[timestamp + offset] = value; + } + return results; }, // Callback triggered after calling and completing update().
