Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import {format as formatDate, subMonths, subDays, subHours, subMinutes, getDaysInMonth} from 'date-fns';
import {formatCurrency} from '../util';
import './TimeSeriesChart.scss';
const CustomTooltip = ({payload}) => {
// It's sometimes empty…
if (!(payload && payload.length > 0)) {
return null;
}
return (
<div>{formatCurrency(payload[0].payload.value)}</div>
);
};
CustomTooltip.propTypes = Tooltip.propTypes;
const resolutionToLabelFormat = new Map([
['hour', 'HH:mm'],
['day', 'HH:mm dddd'],
['week', 'dddd DD/MM'],
['month', 'DD/MM'],
['year', 'MMMM'],
['all', 'MMMM YYYY'],
]);
const makeTicks = (count, fn) => {
const now = new Date();
return [...new Array(count).keys()].map(index => fn(now, index)).reverse();
};
const getTicks = resolution => {
import './PieChart.scss';
const CustomTooltip = ({payload}) => {
// It's sometimes empty…
if (!(payload && payload.length > 0)) {
return null;
}
const [data] = payload;
return (
<div>{data.name}: {formatCurrency(data.value)}</div>
);
};
CustomTooltip.propTypes = Tooltip.propTypes;
const PieChart = () => {
const {state: appState} = appContainer;
const {currencies} = appState;
const data = currencies.map(currency => ({
name: currency.symbol,
value: currency.cmcBalanceUsd,
}));
let PieChart = () => (
// TODO(sindresorhus): The default behavior of tooltips is to follow the mouse.
// We should make it static: https://github.com/recharts/recharts/issues/488
const CustomTooltipContent = ({payload}) => {
// No idea why it's sometimes empty
if (payload.length === 0) {
return null;
}
return (
<div>{formatCurrency(payload[0].payload.price)}</div>
);
};
CustomTooltipContent.propTypes = Tooltip.propTypes;
const DepthChart = props => {
let {bids, asks} = props;
const getDepths = orders => orders.map(order => order.depth);
const maxDepth = Math.max(...getDepths(asks), ...getDepths(bids));
const isEmpty = bids.length === 0 && asks.length === 0;
// We still supply values when it's empty so it will show the left/right border
bids = bids.length > 0 ? bids : [{price: 0, depth: 0}];
asks = asks.length > 0 ? asks : [{price: 0, depth: 0}];
bids = _.orderBy(bids, ['depth'], ['desc']);
asks = _.orderBy(asks, ['depth'], ['asc']);
bids = roundPrice(bids);
asks = roundPrice(asks);