Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 1 addition & 2 deletions pkg/app/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"@types/react-dom": "^16.9.8",
"@types/react-redux": "^7.1.9",
"@types/react-router-dom": "^5.1.5",
"@types/recharts": "^1.8.18",
"@types/redux-mock-store": "^1.0.2",
"@typescript-eslint/eslint-plugin": "^3.3.0",
"@typescript-eslint/parser": "^3.3.0",
Expand Down Expand Up @@ -90,7 +89,7 @@
"react-intersection-observer": "^8.26.2",
"react-redux": "^7.2.0",
"react-router-dom": "^5.2.0",
"recharts": "^1.8.5",
"recharts": "^2.0.3",
"redux": "^4.0.5",
"yup": "^0.29.3"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Box } from "@material-ui/core";
import React from "react";
import { DeploymentFrequencyChart } from "./deployment-frequency-chart";

Expand All @@ -12,6 +13,12 @@ const randData = Array.from(new Array(20)).map((_, v) => ({
}));

export const overview: React.FC = () => (
<DeploymentFrequencyChart data={randData} />
<Box width={800}>
<DeploymentFrequencyChart data={randData} />
</Box>
);
export const noData: React.FC = () => (
<Box width={800}>
<DeploymentFrequencyChart data={[]} />
</Box>
);
export const noData: React.FC = () => <DeploymentFrequencyChart data={[]} />;
37 changes: 27 additions & 10 deletions pkg/app/web/src/components/deployment-frequency-chart.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FC, useCallback } from "react";
import React, { FC } from "react";
import { Box, makeStyles, Paper, Typography } from "@material-ui/core";
import { InsightDataPoint } from "pipe/pkg/app/web/model/insight_pb";
import {
Expand All @@ -12,26 +12,36 @@ import {
} from "recharts";
import dayjs from "dayjs";
import { theme } from "../theme";
import { WarningOutlined } from "@material-ui/icons";

const useStyles = makeStyles((theme) => ({
root: {
padding: theme.spacing(3),
minWidth: 600,
},
noDataMessage: {
display: "flex",
},
noDataMessageIcon: {
marginRight: theme.spacing(1),
},
}));

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

const tickFormatter = (time: number | string): string =>
dayjs(time).format("MMM DD");

const labelFormatter = (time: number | string): string =>
dayjs(time).format("YYYY MMM DD");

const NO_DATA_TEXT = "No data is available.";

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

const formatter = useCallback(
(time: number | string) => dayjs(time).format("MMM DD"),
[]
);

return (
<Paper elevation={1} className={classes.root}>
<Typography variant="h6" component="div">
Expand All @@ -44,7 +54,14 @@ export const DeploymentFrequencyChart: FC<Props> = ({ data }) => {
justifyContent="center"
height={420}
>
<Typography variant="body1">No data</Typography>
<Typography
variant="body1"
color="textSecondary"
className={classes.noDataMessage}
>
<WarningOutlined className={classes.noDataMessageIcon} />
{NO_DATA_TEXT}
</Typography>
</Box>
) : (
<ResponsiveContainer width="100%" aspect={2}>
Expand All @@ -65,9 +82,9 @@ export const DeploymentFrequencyChart: FC<Props> = ({ data }) => {
isAnimationActive={false}
dot={{ fill: theme.palette.primary.main }}
/>
<YAxis />
<XAxis dataKey="timestamp" tickFormatter={formatter} />
<Tooltip labelFormatter={formatter} />
<YAxis axisLine={false} tickLine={false} />
<XAxis dataKey="timestamp" tickFormatter={tickFormatter} />
<Tooltip labelFormatter={labelFormatter} />
</LineChart>
</ResponsiveContainer>
)}
Expand Down
Loading