Skip to content

Commit

Permalink
Polish a few things in margins revert recharts upgrade broke responsive
Browse files Browse the repository at this point in the history
  • Loading branch information
mohamedmansour committed Aug 15, 2021
1 parent d5983f3 commit 5a37ec1
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 37 deletions.
34 changes: 17 additions & 17 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
"react-icons": "^4.2.0",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.3",
"recharts": "^2.1.0",
"string.prototype.matchall": "^4.0.5",
"typescript": "^4.3.5"
"recharts": "2.0.10",
"string.prototype.matchall": "^4.0.5"
},
"scripts": {
"start": "react-scripts start",
Expand Down Expand Up @@ -50,11 +49,12 @@
"@types/d3-scale-chromatic": "^3.0.0",
"@types/jest": "^27.0.1",
"@types/node": "^16.6.1",
"@types/react": "^17.0.17",
"@types/react": "^17.0.18",
"@types/react-dom": "^17.0.9",
"@types/react-router-dom": "^5.1.8",
"@types/string.prototype.matchall": "^4.0.0",
"node-cron": "^3.0.0",
"node-fetch": "^2.6.1"
"node-fetch": "^2.6.1",
"typescript": "^4.3.5"
}
}
2 changes: 1 addition & 1 deletion frontend/src/atoms/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ export const Card = forwardRef<CardProps, 'div'>((props: CardProps, ref: React.F
</Box>
</Box>
)
})
})
29 changes: 16 additions & 13 deletions frontend/src/pages/Home.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useEffect, useState, useCallback } from 'react';
import { useHistory, useLocation } from 'react-router-dom';
import { useHistory, useLocation } from 'react-router-dom';
import {
PieChart, Pie, Cell, Tooltip,
PieChart, Pie, Cell, Tooltip,
LabelList, Bar, BarChart, XAxis, YAxis
} from 'recharts';

Expand Down Expand Up @@ -52,7 +52,7 @@ function Home() {
console.error(e);
}
}

if (filterCount(searchFilters) === 0) {
// Deep clone since we are mutating it.
searchFilters = JSON.parse(JSON.stringify(knownNodesFilter));
Expand Down Expand Up @@ -111,13 +111,13 @@ function Home() {
</g>
);
};

const renderTooltipContent = (props: any): any => {
if (!props.active || !props.payload || !props.payload.length) {
return null
}
const { payload: {name, count}} = props.payload[0]

const { payload: { name, count } } = props.payload[0]
return (
<TooltipCard>
<Text fontWeight="bold">{name}</Text>
Expand All @@ -134,9 +134,10 @@ function Home() {
<GridItem colSpan={LayoutTwoColSpan}>
<Filtering filters={filters} onFiltersChange={onFiltersChanged} />
</GridItem>

<GridItem colSpan={LayoutTwoColSpan}>
<Card title={barChartTitle} w="99%" contentHeight={barChartData.length * 40}>
<CustomResponsiveContainer height={barChartData.length * 40}>
<Card title={barChartTitle} contentHeight={barChartData.length * 40}>
<CustomResponsiveContainer>
<BarChart
data={barChartData}
layout="vertical"
Expand All @@ -145,7 +146,7 @@ function Home() {
>
<XAxis type="number" hide stroke={color} />
<YAxis dataKey="name" type="category" interval={0} stroke={color} />
<Tooltip cursor={false} content={renderTooltipContent}/>
<Tooltip cursor={false} content={renderTooltipContent} />
<Bar dataKey="count">
{barChartData.map((entry, index) => (
<Cell key={`cell-${index}`} fill={colors[index % 10]} />
Expand All @@ -157,8 +158,8 @@ function Home() {
</Card>
</GridItem>

<Card title="Popular Operating Systems" w="99%" contentHeight={300}>
<CustomResponsiveContainer height={300}>
<Card title="Popular Operating Systems" contentHeight={300}>
<CustomResponsiveContainer>
<PieChart>
<Pie
data={data.operatingSystems}
Expand All @@ -172,6 +173,7 @@ function Home() {
label={renderLabelContent}
isAnimationActive={false}
onClick={onOperatingSystemClicked}
stroke="none"
>
{
data.operatingSystems.map((entry, index) => (
Expand All @@ -186,8 +188,8 @@ function Home() {
</CustomResponsiveContainer>
</Card>

<Card title="Popular Client Runtimes" w="99%" contentHeight={300}>
<CustomResponsiveContainer height={300}>
<Card title="Popular Client Runtimes" contentHeight={300}>
<CustomResponsiveContainer>
<PieChart>
<Pie
data={data.languages}
Expand All @@ -200,6 +202,7 @@ function Home() {
minAngle={data.languages.length === 1 ? 0 : 20}
label={renderLabelContent}
isAnimationActive={false}
stroke="none"
>
{
data.languages.map((entry, index) => (
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const theme = extendTheme({
px: "2",
py: "3",
rounded: "md",
h: "100%",
})
},
TablePlus: {
Expand Down Expand Up @@ -60,4 +61,4 @@ export const theme = extendTheme({
},
}
}
})
})

0 comments on commit 5a37ec1

Please sign in to comment.