Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 26 additions & 32 deletions pkg/app/web/src/components/deployment-frequency-chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,22 @@ import {
XAxis,
CartesianGrid,
Tooltip,
ResponsiveContainer,
} from "recharts";
import dayjs from "dayjs";
import { theme } from "../theme";

const useStyles = makeStyles((theme) => ({
root: {
padding: theme.spacing(3),
width: 680,
},
chart: {
flex: 1,
minWidth: 600,
},
}));

interface Props {
data: InsightDataPoint.AsObject[];
}

const CHART_WIDTH = 600;
const CHART_HEIGHT = 400;

export const DeploymentFrequencyChart: FC<Props> = ({ data }) => {
const classes = useStyles();

Expand All @@ -44,38 +39,37 @@ export const DeploymentFrequencyChart: FC<Props> = ({ data }) => {
</Typography>
{data.length === 0 ? (
<Box
width={CHART_WIDTH}
height={CHART_HEIGHT}
display="flex"
alignItems="center"
justifyContent="center"
height={420}
>
<Typography variant="body1">No data</Typography>
</Box>
) : (
<LineChart
data={data}
width={CHART_WIDTH}
height={CHART_HEIGHT}
margin={{
top: 48,
right: 24,
left: 8,
bottom: 8,
}}
>
<CartesianGrid vertical={false} />
<Line
dataKey="value"
stroke={theme.palette.primary.main}
strokeWidth={2}
isAnimationActive={false}
dot={{ fill: theme.palette.primary.main }}
/>
<YAxis />
<XAxis dataKey="timestamp" tickFormatter={formatter} />
<Tooltip labelFormatter={formatter} />
</LineChart>
<ResponsiveContainer width="100%" aspect={2}>
<LineChart
data={data}
margin={{
top: 48,
right: 24,
left: 8,
bottom: 8,
}}
>
<CartesianGrid vertical={false} />
<Line
dataKey="value"
stroke={theme.palette.primary.main}
strokeWidth={2}
isAnimationActive={false}
dot={{ fill: theme.palette.primary.main }}
/>
<YAxis />
<XAxis dataKey="timestamp" tickFormatter={formatter} />
<Tooltip labelFormatter={formatter} />
</LineChart>
</ResponsiveContainer>
)}
</Paper>
);
Expand Down