Skip to content

Commit

Permalink
Fix line graph when less than 60 days of data
Browse files Browse the repository at this point in the history
  • Loading branch information
adamsoffer committed Jun 7, 2023
1 parent 22f876b commit 80bedb9
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 17 deletions.
2 changes: 1 addition & 1 deletion components/LineGraph/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const LineGraph = ({ color, days, dimensions }: props) => {
const formattedData = days.map((day) => {
return {
time: new Date(day.date * 1000).toLocaleDateString("fr-CA"),
value: day.revenue,
value: days.length < 60 ? 0 : day.revenue,
};
});
lineSeries.setData(formattedData);
Expand Down
2 changes: 1 addition & 1 deletion components/Listing/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ const Listing = ({ data, ...props }) => {
: "revenue";
if (row.values.untracked) return "--";
const color =
row.values.usage[paymentType].thirtyDayPercentChange > 0
row.values.usage[paymentType].thirtyDayPercentChange >= 0
? defaultTheme.colors.green
: defaultTheme.colors.red;

Expand Down
31 changes: 17 additions & 14 deletions components/RevenueChange/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,28 @@ import { defaultTheme } from "../../stitches.config";

const RevenueChange = ({ percentChange, css = {}, ...props }) => {
const color =
parseFloat(percentChange) > 0
parseFloat(percentChange) >= 0
? defaultTheme.colors.green
: defaultTheme.colors.red;

console.log(percentChange);
return (
<Box css={{ display: "flex", alignItems: "center", ...css }} {...props}>
<Box
css={{
fontSize: "$1",
width: "0",
height: "0",
borderStyle: "solid",
borderWidth: "0 4px 6px 4px",
borderColor: `transparent transparent ${color} transparent`,
mr: "$1",
transform:
parseFloat(percentChange) > 0 ? "rotate(0)" : "rotate(180deg)",
}}
/>
{parseFloat(percentChange) !== 0 && (
<Box
css={{
fontSize: "$1",
width: "0",
height: "0",
borderStyle: "solid",
borderWidth: "0 4px 6px 4px",
borderColor: `transparent transparent ${color} transparent`,
mr: "$1",
transform:
parseFloat(percentChange) > 0 ? "rotate(0)" : "rotate(180deg)",
}}
/>
)}
<Box css={{ color }}>{percentChange}%</Box>
</Box>
);
Expand Down
2 changes: 1 addition & 1 deletion components/Ticker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const Project = ({ project }) => {
: "revenue";

const color =
project.usage[paymentType].thirtyDayPercentChange > 0
project.usage[paymentType].thirtyDayPercentChange >= 0
? defaultTheme.colors.green
: defaultTheme.colors.red;

Expand Down

1 comment on commit 80bedb9

@vercel
Copy link

@vercel vercel bot commented on 80bedb9 Jun 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.