Browse Source

fix y axis values on graphs and dashboard page

master
Valentin D. Pinkman 7 years ago
parent
commit
9efc7aaa98
No known key found for this signature in database GPG Key ID: E7D110669FFB8D3E
  1. 2
      package.json
  2. 4
      src/components/BalanceSummary/index.js
  3. 4
      src/components/base/Chart/index.js
  4. 6
      src/components/base/Chart/refreshDraw.js
  5. 6
      yarn.lock

2
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.20.0",
"axios": "^0.18.0",
"babel-runtime": "^6.26.0",
"bcryptjs": "^2.4.3",

4
src/components/BalanceSummary/index.js

@ -1,6 +1,7 @@
// @flow
import React, { Fragment } from 'react'
import { formatCurrencyUnit } from '@ledgerhq/live-common/lib/helpers/currencies'
import type { Currency, Account } from '@ledgerhq/live-common/lib/types'
import Chart from 'components/base/Chart'
@ -59,6 +60,9 @@ const BalanceSummary = ({
height={250}
currency={counterValue}
tickXScale={selectedTime}
renderTickY={(val, account) =>
account ? formatCurrencyUnit(account.unit, val) : val
}
renderTooltip={
isAvailable && !account
? d => (

4
src/components/base/Chart/index.js

@ -36,6 +36,7 @@
import React, { PureComponent } from 'react'
import * as d3 from 'd3'
import noop from 'lodash/noop'
import { formatShort } from '@ledgerhq/live-common/lib/helpers/currencies'
import type { Account } from '@ledgerhq/live-common/lib/types'
@ -58,6 +59,7 @@ export type Props = {
dateFormat?: string, // eslint-disable-line react/no-unused-prop-types
isInteractive?: boolean, // eslint-disable-line react/no-unused-prop-types
renderTooltip?: Function, // eslint-disable-line react/no-unused-prop-types
renderTickY?: (t: number, account: Account) => mixed, // eslint-disable-line react/no-unused-prop-types
}
class Chart extends PureComponent<Props> {
@ -69,6 +71,8 @@ class Chart extends PureComponent<Props> {
id: 'chart',
isInteractive: true,
tickXScale: 'month',
renderTickY: (t: number, account: Account): mixed =>
account ? formatShort(account.unit, t) : t,
}
componentDidMount() {

6
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, account, 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(val => (renderTickY && account ? renderTickY(val, account) : val)),
)
NODES.axisBot.call(
d3

6
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.20.0":
version "2.20.0"
resolved "https://registry.yarnpkg.com/@ledgerhq/live-common/-/live-common-2.20.0.tgz#e6ec2a3a01a224edac82b093e2f1564312a30d0d"
dependencies:
axios "^0.18.0"
invariant "^2.2.2"

Loading…
Cancel
Save