@@ -20,6 +20,7 @@ const chartColors: ChartProps['colors'] = {
2020const generateDataPoints = ( {
2121 startingValue = 400 ,
2222 minimum = 0 ,
23+ maximum = 3000 ,
2324 radomFactor = 20 ,
2425} = { } ) => {
2526 const points = [ ]
@@ -31,9 +32,10 @@ const generateDataPoints = ({
3132 const randomVariation = ( Math . random ( ) - 0.5 ) * radomFactor
3233 value += randomVariation
3334
34- // randomVariation was negative and value went below minimum
35- if ( value < minimum ) {
36- // invert direction to keep above minimum
35+ // either randomVariation was negative and value went below minimum
36+ // or randomVariation was positive and value went above maximum
37+ if ( value < minimum || value > maximum ) {
38+ // invert direction to keep within bounds
3739 value -= 2 * randomVariation
3840 }
3941
@@ -44,28 +46,36 @@ const generateDataPoints = ({
4446}
4547
4648enum Measurement {
47- Red = 'Red ' ,
49+ Temperature = 'Temperature ' ,
4850 Blue = 'Blue' ,
4951 Green = 'Green' ,
5052 Pink = 'Pink' ,
5153}
5254const measurementKeys = Object . values ( Measurement )
5355const measurementsRecords : Record < Measurement , Dataset > = {
54- [ Measurement . Red ] : {
56+ [ Measurement . Temperature ] : {
5557 unit : '°C' ,
56- points : generateDataPoints ( ) ,
58+ points : generateDataPoints ( {
59+ maximum : 40 ,
60+ minimum : - 10 ,
61+ radomFactor : 1 ,
62+ startingValue : - 8 ,
63+ } ) ,
5764 decimals : 0 ,
58- areaColor : '#e78e96 ' ,
65+ areaColor : '#ff00ff' , // '#83cba8 ',
5966 color : {
6067 type : 'thresholds' ,
61- baseColor : '#CF1E2E ' ,
62- gradientBlur : 50 ,
68+ baseColor : '#3d91ff ' ,
69+ gradientBlur : 2 ,
6370 thresholds : [
64- { value : 800 , color : '#089851' } ,
65- { value : 400 , color : '#F29400' } ,
71+ { value : 32 , color : '#bb2222' } ,
72+ { value : 24 , color : '#ffc400' } ,
73+ { value : 16 , color : '#089851' } ,
74+ { value : 10 , color : '#9ceeff' } ,
75+ { value : 0 , color : '#00d5ff' } ,
6676 ] ,
6777 } ,
68- measurementName : Measurement . Red ,
78+ measurementName : Measurement . Temperature ,
6979 } ,
7080 [ Measurement . Blue ] : {
7181 unit : 'l' ,
@@ -123,7 +133,7 @@ export default function App() {
123133 } , [ timeDomainType ] )
124134
125135 const [ enabledMeasurements , setEnabledMeasurements ] = useState < Measurement [ ] > (
126- [ Measurement . Red ]
136+ [ Measurement . Temperature ]
127137 )
128138
129139 const datasets = useMemo < Dataset [ ] > (
0 commit comments