Skip to content

Commit b1e03c9

Browse files
committed
Minor adjustement to work with network request
1 parent 235fd97 commit b1e03c9

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

web/src/pages/billing/BillingDashboard.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import SeqrProportionalMapGraph from './SeqrProportionalMapGraph'
44

55
const BillingDashboard: React.FunctionComponent = () => {
66
const [start, setStart] = React.useState<string>('2021-01-01')
7-
const [end, setEnd] = React.useState<string>('2021-12-31')
7+
const [end, setEnd] = React.useState<string>('2022-10-31')
88

99
return (
1010
<Card fluid>

web/src/pages/billing/SeqrProportionalMapGraph.tsx

+13-9
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
schemeAccent,
1515
scaleTime,
1616
utcDay,
17+
utcMonth,
1718
timeFormat,
1819
} from 'd3'
1920

@@ -72,7 +73,7 @@ const SeqrProportionalMapGraph: React.FunctionComponent<ISeqrProportionalMapGrap
7273

7374
const graphData: IPropMapData[] = summary.data.map(
7475
(obj: IProportionalDateModel) => ({
75-
date: obj.date,
76+
date: new Date(obj.date),
7677
...defaultPropMap,
7778
...obj.projects.reduce(
7879
(prev: { [project: string]: number }, projectObj) => ({
@@ -215,6 +216,12 @@ const SeqrProportionalMapGraph: React.FunctionComponent<ISeqrProportionalMapGrap
215216
.y0((d) => yScale(d[0]))
216217
.y1((d) => yScale(d[1]))
217218

219+
let interval = utcDay.every(10)
220+
// more than 3 months
221+
if ((new Date(end).valueOf() - new Date(start).valueOf()) > 1000 * 60 * 60 * 24 * 90) {
222+
interval = utcMonth.every(1)
223+
}
224+
218225
return (
219226
data && (
220227
<svg id={id} width={width} height={height}>
@@ -236,15 +243,12 @@ const SeqrProportionalMapGraph: React.FunctionComponent<ISeqrProportionalMapGrap
236243
Calling xScale(tick) turns a tick value into a pixel position to be drawn
237244
eg in the domain [2000, 2010] and range[0, 200] passing 2005 would be 50% of the way across the domain so 50% of the way between min and max specified pixel positions so it would draw at 100
238245
*/}
239-
{xScale.ticks(utcDay.every(1)).map(
240-
(
241-
tick // can change this to set how many ticks you want
242-
) => (
246+
{xScale.ticks(interval).map(
247+
tick => (
243248
<g
244-
key={tick}
245-
transform={`translate(${xScale(tick)}, ${
246-
height - margin.top - margin.bottom
247-
})`}
249+
key={`x-tick-${tick.toString()}`}
250+
transform={`translate(${xScale(tick)}, ${height - margin.top - margin.bottom
251+
})`}
248252
>
249253
<text
250254
y={8}

0 commit comments

Comments
 (0)