-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
1 parent
14138b0
commit cf4818e
Showing
5 changed files
with
88 additions
and
2 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,39 @@ | ||
import React from 'react'; | ||
import Typography from '@material-ui/core/Typography'; | ||
import Slider from '@material-ui/core/Slider'; | ||
|
||
function valueLabelFormat(value) { | ||
const [coefficient, exponent] = value | ||
.toExponential() | ||
.split('e') | ||
.map(item => Number(item)); | ||
return `${Math.round(coefficient)}e^${exponent}`; | ||
} | ||
|
||
export default function NonLinearSlider() { | ||
const [value, setValue] = React.useState(1); | ||
|
||
const handleChange = (event, newValue) => { | ||
setValue(newValue); | ||
}; | ||
|
||
return ( | ||
<div> | ||
<Typography id="non-linear-slider" gutterBottom> | ||
Temperature range | ||
</Typography> | ||
<Slider | ||
value={value} | ||
min={0} | ||
step={0.1} | ||
max={6} | ||
scale={x => x ** 10} | ||
getAriaValueText={valueLabelFormat} | ||
valueLabelFormat={valueLabelFormat} | ||
onChange={handleChange} | ||
valueLabelDisplay="auto" | ||
aria-labelledby="non-linear-slider" | ||
/> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import React from 'react'; | ||
import Typography from '@material-ui/core/Typography'; | ||
import Slider from '@material-ui/core/Slider'; | ||
|
||
function valueLabelFormat(value: number) { | ||
const [coefficient, exponent] = value | ||
.toExponential() | ||
.split('e') | ||
.map(item => Number(item)); | ||
return `${Math.round(coefficient)}e^${exponent}`; | ||
} | ||
|
||
export default function NonLinearSlider() { | ||
const [value, setValue] = React.useState<number | number[]>(1); | ||
|
||
const handleChange = (event: any, newValue: number | number[]) => { | ||
setValue(newValue); | ||
}; | ||
|
||
return ( | ||
<div> | ||
<Typography id="non-linear-slider" gutterBottom> | ||
Temperature range | ||
</Typography> | ||
<Slider | ||
value={value} | ||
min={0} | ||
step={0.1} | ||
max={6} | ||
scale={x => x ** 10} | ||
getAriaValueText={valueLabelFormat} | ||
valueLabelFormat={valueLabelFormat} | ||
onChange={handleChange} | ||
valueLabelDisplay="auto" | ||
aria-labelledby="non-linear-slider" | ||
/> | ||
</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
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