-
Notifications
You must be signed in to change notification settings - Fork 596
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dashboard): add backpressure to the relation dependency graph (#…
…18280) (#18611) Co-authored-by: Noel Kwan <[email protected]> Co-authored-by: Eric Fu <[email protected]>
- Loading branch information
1 parent
9b0c53a
commit 74b190e
Showing
12 changed files
with
435 additions
and
69 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
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,43 @@ | ||
import { theme } from "@chakra-ui/react" | ||
import { tinycolor } from "@ctrl/tinycolor" | ||
|
||
/** | ||
* The color for the edge with given back pressure value. | ||
* | ||
* @param value The back pressure rate, between 0 and 100. | ||
*/ | ||
export function backPressureColor(value: number) { | ||
const colorRange = [ | ||
theme.colors.green["100"], | ||
theme.colors.green["300"], | ||
theme.colors.yellow["400"], | ||
theme.colors.orange["500"], | ||
theme.colors.red["700"], | ||
].map((c) => tinycolor(c)) | ||
|
||
value = Math.max(value, 0) | ||
value = Math.min(value, 100) | ||
|
||
const step = colorRange.length - 1 | ||
const pos = (value / 100) * step | ||
const floor = Math.floor(pos) | ||
const ceil = Math.ceil(pos) | ||
|
||
const color = tinycolor(colorRange[floor]) | ||
.mix(tinycolor(colorRange[ceil]), (pos - floor) * 100) | ||
.toHexString() | ||
|
||
return color | ||
} | ||
|
||
/** | ||
* The width for the edge with given back pressure value. | ||
* | ||
* @param value The back pressure rate, between 0 and 100. | ||
*/ | ||
export function backPressureWidth(value: number, scale: number) { | ||
value = Math.max(value, 0) | ||
value = Math.min(value, 100) | ||
|
||
return scale * (value / 100) + 2 | ||
} |
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
Oops, something went wrong.