-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: function plot for Lockup Linear (#27)
* feat: function plot for Lockup Linear build: add "function-plot" as dep refactor: polish Stream Types refactor: uncollapse Protocol Concepts * feat: add function graphs * refactor: refine function plots --------- Co-authored-by: maxdesalle <max@sablier.finance>
- Loading branch information
1 parent
4cef81b
commit 4f33bd0
Showing
6 changed files
with
183 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"collapsed": true, | ||
"collapsed": false, | ||
"label": "Protocol Concepts", | ||
"position": 4 | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,32 @@ | ||
import functionPlot, { FunctionPlotOptions } from "function-plot"; | ||
import React, { useEffect, useRef } from "react"; | ||
|
||
export interface FunctionPlotProps { | ||
options?: FunctionPlotOptions; | ||
} | ||
|
||
// See https://github.com/mauriciopoppe/function-plot | ||
const FunctionPlot: React.FC<FunctionPlotProps> = React.memo(function ({ options }: FunctionPlotProps) { | ||
const rootEl = useRef(null); | ||
|
||
useEffect(() => { | ||
try { | ||
functionPlot({ | ||
...options, | ||
disableZoom: true, | ||
grid: true, | ||
xAxis: { domain: [0, 100], label: "x - time" }, | ||
yAxis: { domain: [0, 100], label: "y - earnings" }, | ||
target: rootEl.current, | ||
}); | ||
} catch (err) { | ||
console.error("FunctionPlot error: ", err); | ||
} | ||
}, [options, rootEl]); | ||
|
||
return <div ref={rootEl} />; | ||
}); | ||
|
||
FunctionPlot.displayName = "FunctionPlot"; | ||
|
||
export default FunctionPlot; |
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