diff --git a/package.json b/package.json index 4f7ad6b8..3384d2fd 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@ledgerhq/hw-transport": "^4.12.0", "@ledgerhq/hw-transport-node-hid": "^4.12.0", "@ledgerhq/ledger-core": "1.4.1", - "@ledgerhq/live-common": "2.19.0", + "@ledgerhq/live-common": "2.22.0", "axios": "^0.18.0", "babel-runtime": "^6.26.0", "bcryptjs": "^2.4.3", diff --git a/src/components/BalanceSummary/index.js b/src/components/BalanceSummary/index.js index be091a8f..80080c44 100644 --- a/src/components/BalanceSummary/index.js +++ b/src/components/BalanceSummary/index.js @@ -1,6 +1,7 @@ // @flow import React, { Fragment } from 'react' +import { formatShort } from '@ledgerhq/live-common/lib/helpers/currencies' import type { Currency, Account } from '@ledgerhq/live-common/lib/types' import Chart from 'components/base/Chart' @@ -53,12 +54,13 @@ const BalanceSummary = ({ formatShort(counterValue.units[0], val)} renderTooltip={ isAvailable && !account ? d => ( diff --git a/src/components/DashboardPage/AccountCard.js b/src/components/DashboardPage/AccountCard.js index 0805632f..4a6c8b9a 100644 --- a/src/components/DashboardPage/AccountCard.js +++ b/src/components/DashboardPage/AccountCard.js @@ -88,7 +88,7 @@ const AccountCard = ({ hideAxis isInteractive={false} id={`account-chart-${account.id}`} - account={account} + unit={account.unit} /> )} diff --git a/src/components/base/Chart/Tooltip.js b/src/components/base/Chart/Tooltip.js index 2ccbdbec..900afa8e 100644 --- a/src/components/base/Chart/Tooltip.js +++ b/src/components/base/Chart/Tooltip.js @@ -3,7 +3,7 @@ import React, { Fragment } from 'react' import styled from 'styled-components' -import type { Account, Currency } from '@ledgerhq/live-common/lib/types' +import type { Unit, Currency } from '@ledgerhq/live-common/lib/types' import FormattedVal from 'components/base/FormattedVal' import Box from 'components/base/Box' @@ -25,12 +25,12 @@ const Container = styled(Box).attrs({ const Tooltip = ({ item, renderTooltip, - account, + unit, counterValue, }: { item: Item, renderTooltip?: Function, - account?: Account, + unit?: ?Unit, counterValue: Currency, }) => (
@@ -57,13 +57,13 @@ const Tooltip = ({ unit={counterValue.units[0]} val={item.value} /> - {account && ( + {unit && ( )} diff --git a/src/components/base/Chart/handleMouseEvents.js b/src/components/base/Chart/handleMouseEvents.js index bf5a918a..77096ed3 100644 --- a/src/components/base/Chart/handleMouseEvents.js +++ b/src/components/base/Chart/handleMouseEvents.js @@ -30,7 +30,6 @@ export default function handleMouseEvents({ renderTooltip?: Function, }) { const { MARGINS, HEIGHT, WIDTH, NODES, DATA, x, y } = ctx - const { account } = props const bisectDate = d3.bisector(d => d.parsedDate).left @@ -94,7 +93,7 @@ export default function handleMouseEvents({ string | number, // eslint-disable-line react/no-unused-prop-types } class Chart extends PureComponent { @@ -69,6 +68,7 @@ class Chart extends PureComponent { id: 'chart', isInteractive: true, tickXScale: 'month', + renderTickY: (t: *) => t, } componentDidMount() { diff --git a/src/components/base/Chart/refreshDraw.js b/src/components/base/Chart/refreshDraw.js index eac16978..fa3d2e31 100644 --- a/src/components/base/Chart/refreshDraw.js +++ b/src/components/base/Chart/refreshDraw.js @@ -2,7 +2,6 @@ import * as d3 from 'd3' import moment from 'moment' -import { formatShort } from '@ledgerhq/live-common/lib/helpers/currencies' import { colors as themeColors } from 'styles/theme' @@ -31,11 +30,10 @@ function getRenderTickX(selectedTime) { export default function refreshDraw({ ctx, props }: { ctx: CTX, props: Props }) { const { NODES, WIDTH, HEIGHT, MARGINS, COLORS, INVALIDATED, DATA, x, y } = ctx - const { hideAxis, isInteractive, tickXScale, account } = props + const { hideAxis, isInteractive, tickXScale, renderTickY } = props const nbTicksX = getTickXCount(tickXScale) const renderTickX = getRenderTickX(tickXScale) - const renderTickY = t => (account ? formatShort(account.unit, t) : t) const area = d3 .area() @@ -89,7 +87,7 @@ export default function refreshDraw({ ctx, props }: { ctx: CTX, props: Props }) d3 .axisLeft(y) .ticks(3) - .tickFormat(val => (renderTickY ? renderTickY(val) : val)), + .tickFormat(renderTickY), ) NODES.axisBot.call( d3 diff --git a/src/components/base/Chart/stories.js b/src/components/base/Chart/stories.js index e1f4e704..a88182bb 100644 --- a/src/components/base/Chart/stories.js +++ b/src/components/base/Chart/stories.js @@ -62,7 +62,7 @@ class Wrapper extends Component { color={color('color', '#5f8ced')} data={data.slice(start, stop)} height={number('height', 300)} - account={fakeAccount} + unit={fakeAccount.unit} /> ) diff --git a/yarn.lock b/yarn.lock index 686fe014..799f056e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1495,9 +1495,9 @@ npm "^5.7.1" prebuild-install "^2.2.2" -"@ledgerhq/live-common@2.19.0": - version "2.19.0" - resolved "https://registry.yarnpkg.com/@ledgerhq/live-common/-/live-common-2.19.0.tgz#bc0e12cbf1a9742a5c6497513d0269fdc6a90b95" +"@ledgerhq/live-common@2.22.0": + version "2.22.0" + resolved "https://registry.yarnpkg.com/@ledgerhq/live-common/-/live-common-2.22.0.tgz#f958ee28cc09af40a6bed484e73204f01b54d709" dependencies: axios "^0.18.0" invariant "^2.2.2"