-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add at the top of the size graph the total size that has been used by the library - Add a new control that can be reused (limited since only for size) - Set the graph to be relative to allow overlay with relative position in CSS
- Loading branch information
1 parent
2a63056
commit 8cdc27e
Showing
7 changed files
with
120 additions
and
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"printWidth": 120, | ||
"tabWidth": 4, | ||
"jsxBracketSameLine": false | ||
} |
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
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
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,53 @@ | ||
import * as React from "react"; | ||
import CountUp from "react-countup"; | ||
import { sizeConversation, SizeUnit, Statistics } from "../../BusinessLogics/Model"; | ||
export interface GraphSizeOverlayProps { | ||
statistics: Statistics; | ||
} | ||
|
||
export interface GraphSizeOverlayState { | ||
oldSize: SizeUnit; | ||
newSize: SizeUnit; | ||
} | ||
export class GraphSizeOverlay extends React.Component<GraphSizeOverlayProps, GraphSizeOverlayState> { | ||
public constructor(props: GraphSizeOverlayProps) { | ||
super(props); | ||
this.state = { | ||
oldSize: { | ||
size: 0, | ||
unit: "B" | ||
}, | ||
newSize: { | ||
size: 0, | ||
unit: "B" | ||
} | ||
}; | ||
} | ||
public static getDerivedStateFromProps( | ||
props: GraphSizeOverlayProps, | ||
state: GraphSizeOverlayState | ||
): GraphSizeOverlayState { | ||
const total = | ||
props.statistics.httpBytes + props.statistics.memoryBytes + props.statistics.persistenceStorageBytes; | ||
const sizeUnit = sizeConversation(total); | ||
return { | ||
oldSize: state.newSize, | ||
newSize: sizeUnit | ||
}; | ||
} | ||
public render(): JSX.Element { | ||
const total = | ||
this.props.statistics.httpBytes + | ||
this.props.statistics.memoryBytes + | ||
this.props.statistics.persistenceStorageBytes; | ||
const sizeUnit = sizeConversation(total); | ||
return ( | ||
<div className="highlight-number-on-graph"> | ||
<span className="number"> | ||
<CountUp start={this.state.oldSize.size.toFixed(0)} end={this.state.newSize.size.toFixed(0)} /> | ||
</span> | ||
<span className="unit">{sizeUnit.unit}</span> | ||
</div> | ||
); | ||
} | ||
} |
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