-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
158 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
frontend/src/components/InstanceView/InstanceContentGrowth.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import React from "react"; | ||
import { useColorScheme } from "@mui/joy/styles"; | ||
|
||
import Badge from "@mui/joy/Badge"; | ||
import Tabs from "@mui/joy/Tabs"; | ||
import TabList from "@mui/joy/TabList"; | ||
import Tab from "@mui/joy/Tab"; | ||
import Breadcrumbs from "@mui/joy/Breadcrumbs"; | ||
import Link from "@mui/joy/Link"; | ||
import Container from "@mui/joy/Container"; | ||
import Box from "@mui/joy/Box"; | ||
import Typography from "@mui/joy/Typography"; | ||
|
||
import moment from "moment"; | ||
|
||
// import { ResponsiveContainer, Line, LineChart, Scatter, ScatterChart, Tooltip, XAxis, YAxis } from "recharts"; | ||
|
||
import LineGraph from "../Shared/LineGraph"; | ||
|
||
// const CustomTooltip = ({ active, payload, label }) => { | ||
// console.info(payload); | ||
// if (active && payload && payload.length) { | ||
// return ( | ||
// <Box> | ||
// {payload.map((i) => ( | ||
// <p className="label">{`${i.name} : ${i.value}`}</p> | ||
// ))} | ||
// </Box> | ||
// ); | ||
// } | ||
|
||
// return null; | ||
// }; | ||
|
||
export default function InstanceContentGrowth({ userSeries }) { | ||
console.log("userSeries", userSeries); | ||
|
||
return <LineGraph dataSeries={userSeries} />; | ||
} |
75 changes: 34 additions & 41 deletions
75
frontend/src/components/InstanceView/InstanceUserGrowth.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,39 @@ | ||
import React from "react"; | ||
import { useColorScheme } from "@mui/joy/styles"; | ||
|
||
import Badge from "@mui/joy/Badge"; | ||
import Tabs from "@mui/joy/Tabs"; | ||
import TabList from "@mui/joy/TabList"; | ||
import Tab from "@mui/joy/Tab"; | ||
import Breadcrumbs from "@mui/joy/Breadcrumbs"; | ||
import Link from "@mui/joy/Link"; | ||
import Container from "@mui/joy/Container"; | ||
import Box from "@mui/joy/Box"; | ||
import Typography from "@mui/joy/Typography"; | ||
|
||
import moment from "moment"; | ||
|
||
import { ResponsiveContainer, Scatter, ScatterChart, Tooltip, XAxis, YAxis } from "recharts"; | ||
|
||
export default function InstanceUserGrowth({ userSeries }) { | ||
const minUsers = Number(userSeries[0].value); | ||
const maxUsers = Number(userSeries[userSeries.length - 1].value); | ||
|
||
// round to closest 1000 | ||
const minUsersRounded = Math.floor(minUsers / 1000) * 1000; | ||
const maxUsersRounded = Math.ceil(maxUsers / 1000) * 1000; | ||
|
||
return ( | ||
<ResponsiveContainer width="100%" height={500}> | ||
<ScatterChart | ||
// margin={{ | ||
// top: 5, | ||
// right: 30, | ||
// left: 20, | ||
// bottom: 5, | ||
// }} | ||
> | ||
<XAxis | ||
dataKey="time" | ||
domain={["auto", "dataMax"]} | ||
name="Time" | ||
tickFormatter={(unixTime) => moment(unixTime).format("HH:mm DD-MM-YYYY")} | ||
type="number" | ||
/> | ||
|
||
<Tooltip /> | ||
<YAxis dataKey="value" name="Value" type="number" domain={[minUsersRounded, maxUsersRounded]} /> | ||
|
||
<Scatter | ||
data={userSeries} | ||
lineType="joint" | ||
line={{ stroke: "#eee" }} | ||
// lineJointType="monotoneX" | ||
name="Values" | ||
/> | ||
</ScatterChart> | ||
</ResponsiveContainer> | ||
); | ||
// import { ResponsiveContainer, Line, LineChart, Scatter, ScatterChart, Tooltip, XAxis, YAxis } from "recharts"; | ||
|
||
import LineGraph from "../Shared/LineGraph"; | ||
|
||
// const CustomTooltip = ({ active, payload, label }) => { | ||
// console.info(payload); | ||
// if (active && payload && payload.length) { | ||
// return ( | ||
// <Box> | ||
// {payload.map((i) => ( | ||
// <p className="label">{`${i.name} : ${i.value}`}</p> | ||
// ))} | ||
// </Box> | ||
// ); | ||
// } | ||
|
||
// return null; | ||
// }; | ||
|
||
export default function InstanceUserGrowth({ metricsData }) { | ||
console.log("userSeries", metricsData); | ||
|
||
return <LineGraph dataSeries={metricsData.users} />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import React from "react"; | ||
import { useColorScheme } from "@mui/joy/styles"; | ||
|
||
import Box from "@mui/joy/Box"; | ||
|
||
import moment from "moment"; | ||
import { SimpleNumberFormat } from "../Shared/Display"; | ||
|
||
import { ResponsiveContainer, Line, LineChart, Tooltip, XAxis, YAxis } from "recharts"; | ||
|
||
import { scaleLog } from "d3-scale"; | ||
|
||
const CustomTooltip = ({ active, payload, label }) => { | ||
console.info(payload); | ||
if (active && payload && payload.length) { | ||
return ( | ||
<Box> | ||
{payload.map((i) => ( | ||
<p className="label"> | ||
{i.name}: <SimpleNumberFormat value={i.value} />{" "} | ||
</p> | ||
))} | ||
</Box> | ||
); | ||
} | ||
|
||
return null; | ||
}; | ||
|
||
export default function LineGraph({ dataSeries }) { | ||
const { mode } = useColorScheme(); | ||
|
||
const minUsers = Number(dataSeries[0].value); | ||
const maxUsers = Number(dataSeries[dataSeries.length - 1].value); | ||
|
||
// round to closest 1000 | ||
const minUsersRounded = Math.floor(minUsers / 1000) * 1000; | ||
const maxUsersRounded = Math.ceil(maxUsers / 1000) * 1000; | ||
|
||
console.log("userSeries", dataSeries); | ||
|
||
const scale = "linear"; //scaleLog().base(Math.E); | ||
|
||
return ( | ||
<ResponsiveContainer width="100%" height={500}> | ||
<LineChart data={dataSeries}> | ||
{/* Time Axis */} | ||
<XAxis | ||
dataKey="time" | ||
domain={["dataMax", "dataMax"]} | ||
name="Time" | ||
tickFormatter={(unixTime) => moment(unixTime).format("DD-MM-YYYY")} | ||
type="number" | ||
padding={{ left: 30, right: 30 }} | ||
/> | ||
|
||
<Tooltip | ||
cursor={{ stroke: "#999", strokeWidth: 2, strokeDasharray: "7,5" }} | ||
content={CustomTooltip} | ||
/> | ||
|
||
{/* Count Axis */} | ||
<YAxis | ||
dataKey="value" | ||
type="number" | ||
domain={[minUsersRounded, maxUsersRounded]} | ||
scale={scale} | ||
tickFormatter={(unixTime) => unixTime.toLocaleString()} | ||
/> | ||
|
||
<Line | ||
dataKey="value" | ||
dot={false} | ||
stroke={mode === "dark" ? "#8884d8" : "#82ca9d"} | ||
strokeDasharray="3 3" | ||
name="Users" | ||
/> | ||
</LineChart> | ||
</ResponsiveContainer> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters