Skip to content
Snippets Groups Projects
Unverified Commit 6a0b7d6b authored by Oleh's avatar Oleh Committed by GitHub
Browse files

Make reports more responsive (#1592)

parent 6817c45d
No related branches found
No related tags found
No related merge requests found
...@@ -75,6 +75,7 @@ export const Checkbox = (props: CheckboxProps) => { ...@@ -75,6 +75,7 @@ export const Checkbox = (props: CheckboxProps) => {
{ {
position: 'relative', position: 'relative',
margin: 0, margin: 0,
flexShrink: 0,
marginRight: 6, marginRight: 6,
width: 15, width: 15,
height: 15, height: 15,
......
...@@ -48,6 +48,7 @@ export default function CategorySelector({ ...@@ -48,6 +48,7 @@ export default function CategorySelector({
paddingLeft: 0, paddingLeft: 0,
paddingRight: 10, paddingRight: 10,
height: 320, height: 320,
flexGrow: 1,
overflowY: 'scroll', overflowY: 'scroll',
}} }}
> >
......
...@@ -135,7 +135,13 @@ function CategoryAverage() { ...@@ -135,7 +135,13 @@ function CategoryAverage() {
headerPrefixItems={headerPrefixItems} headerPrefixItems={headerPrefixItems}
/> />
<View <View
style={{ display: 'flex', flexDirection: 'row', padding: 15, gap: 15 }} style={{
display: 'flex',
flexDirection: 'row',
padding: 15,
gap: 15,
flexGrow: 1,
}}
> >
<View style={{ width: 200 }}> <View style={{ width: 200 }}>
<CategorySelector <CategorySelector
...@@ -157,6 +163,7 @@ function CategoryAverage() { ...@@ -157,6 +163,7 @@ function CategoryAverage() {
}} }}
> >
<CategorySpendingGraph <CategorySpendingGraph
style={{ flexGrow: 1 }}
start={start} start={start}
end={end} end={end}
graphData={perCategorySpending} graphData={perCategorySpending}
......
...@@ -105,6 +105,7 @@ export default function NetWorth() { ...@@ -105,6 +105,7 @@ export default function NetWorth() {
padding: 30, padding: 30,
paddingTop: 0, paddingTop: 0,
overflow: 'auto', overflow: 'auto',
flexGrow: 1,
}} }}
> >
<View <View
...@@ -127,7 +128,12 @@ export default function NetWorth() { ...@@ -127,7 +128,12 @@ export default function NetWorth() {
</PrivacyFilter> </PrivacyFilter>
</View> </View>
<NetWorthGraph start={start} end={end} graphData={data.graphData} /> <NetWorthGraph
style={{ flexGrow: 1 }}
start={start}
end={end}
graphData={data.graphData}
/>
<View style={{ marginTop: 30 }}> <View style={{ marginTop: 30 }}>
<Paragraph> <Paragraph>
......
import type { CSSProperties } from 'react';
import * as d from 'date-fns'; import * as d from 'date-fns';
import { VictoryAxis, VictoryBar, VictoryChart, VictoryStack } from 'victory'; import { VictoryAxis, VictoryBar, VictoryChart, VictoryStack } from 'victory';
...@@ -13,8 +15,10 @@ type CategorySpendingGraphProps = { ...@@ -13,8 +15,10 @@ type CategorySpendingGraphProps = {
end: string; end: string;
graphData: CategorySpendingGraphData; graphData: CategorySpendingGraphData;
compact?: boolean; compact?: boolean;
style?: CSSProperties;
}; };
function CategorySpendingGraph({ function CategorySpendingGraph({
style,
start, start,
end, end,
graphData, graphData,
...@@ -25,17 +29,19 @@ function CategorySpendingGraph({ ...@@ -25,17 +29,19 @@ function CategorySpendingGraph({
} }
return ( return (
<Container style={compact && { height: 'auto', flex: 1 }}> <Container style={[style, compact && { height: 'auto', flex: 1 }]}>
{(width, height, portalHost) => ( {(width, height, portalHost) => (
<VictoryChart <VictoryChart
scale={{ x: 'time', y: 'linear' }} scale={{ x: 'time', y: 'linear' }}
theme={theme} theme={theme}
domainPadding={compact ? { x: 10, y: 5 } : { x: 50, y: 10 }}
width={width} width={width}
height={height} height={height}
> >
<Area start={start} end={end} /> <Area start={start} end={end} />
<VictoryStack colorScale="qualitative"> <VictoryStack
colorScale="qualitative"
domainPadding={{ x: compact ? 5 : 15 }}
>
{graphData.categories.map(category => ( {graphData.categories.map(category => (
<VictoryBar <VictoryBar
key={category.id} key={category.id}
...@@ -65,7 +71,7 @@ function CategorySpendingGraph({ ...@@ -65,7 +71,7 @@ function CategorySpendingGraph({
dependentAxis dependentAxis
crossAxis={false} crossAxis={false}
invertAxis invertAxis
tickCount={compact ? 2 : undefined} tickCount={compact ? 2 : height / 70}
/> />
</VictoryChart> </VictoryChart>
)} )}
......
...@@ -92,12 +92,16 @@ function NetWorthGraph({ style, graphData, compact }: NetWorthGraphProps) { ...@@ -92,12 +92,16 @@ function NetWorthGraph({ style, graphData, compact }: NetWorthGraphProps) {
// eslint-disable-next-line rulesdir/typography // eslint-disable-next-line rulesdir/typography
tickFormat={x => d.format(x, "MMM ''yy")} tickFormat={x => d.format(x, "MMM ''yy")}
tickValues={graphData.data.map(item => item.x)} tickValues={graphData.data.map(item => item.x)}
tickCount={Math.min(5, graphData.data.length)} tickCount={Math.min(width / 220, graphData.data.length)}
offsetY={50} offsetY={50}
/> />
)} )}
{!compact && ( {!compact && (
<VictoryAxis dependentAxis crossAxis={!graphData.hasNegative} /> <VictoryAxis
dependentAxis
tickCount={Math.round(height / 70)}
crossAxis={!graphData.hasNegative}
/>
)} )}
</Chart> </Chart>
) )
......
---
category: Enhancements
authors: [OlegWock]
---
Make reports more responsive.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment