From b8570df93223691d8862e1d3cae7a78b0c65e507 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Tue, 13 Aug 2019 13:43:44 +0300 Subject: [PATCH] fix chart step size --- .../block_scout_web/assets/js/lib/coin_balance_history_chart.js | 2 +- apps/explorer/lib/explorer/chain.ex | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/block_scout_web/assets/js/lib/coin_balance_history_chart.js b/apps/block_scout_web/assets/js/lib/coin_balance_history_chart.js index edac1726dd..db84586c6b 100644 --- a/apps/block_scout_web/assets/js/lib/coin_balance_history_chart.js +++ b/apps/block_scout_web/assets/js/lib/coin_balance_history_chart.js @@ -21,7 +21,7 @@ export function createCoinBalanceHistoryChart (el) { var stepSize = 3 if (data.length > 1) { - var diff = Math.abs(new Date(data[0].date) - new Date(data[1].date)) + var diff = Math.abs(new Date(data[data.length - 1].date) - new Date(data[data.length - 2].date)) var periodInDays = diff / (1000 * 60 * 60 * 24) stepSize = periodInDays diff --git a/apps/explorer/lib/explorer/chain.ex b/apps/explorer/lib/explorer/chain.ex index 97ebd77d69..424636f005 100644 --- a/apps/explorer/lib/explorer/chain.ex +++ b/apps/explorer/lib/explorer/chain.ex @@ -2997,7 +2997,7 @@ defmodule Explorer.Chain do today = Date.to_string(NaiveDateTime.utc_now()) if Enum.count(result) > 0 && !Enum.any?(result, fn map -> map[:date] == today end) do - result ++ [%{date: today, value: List.last(result)[:value]}] + List.flatten([result | [%{date: today, value: List.last(result)[:value]}]]) else result end