Adds time support
This commit is contained in:
		
							parent
							
								
									7eb1781079
								
							
						
					
					
						commit
						702044d4d5
					
				|  | @ -20,6 +20,7 @@ let make = | |||
|       ~minX=?, | ||||
|       ~onHover=(f: float) => (), | ||||
|       ~primaryDistribution=?, | ||||
|       ~scale=?, | ||||
|       ~children=[||], | ||||
|     ) => | ||||
|   ReasonReact.wrapJsForReason( | ||||
|  | @ -36,6 +37,7 @@ let make = | |||
|         ~maxX?, | ||||
|         ~minX?, | ||||
|         ~primaryDistribution?, | ||||
|         ~scale?, | ||||
|         (), | ||||
|       ), | ||||
|     children, | ||||
|  |  | |||
|  | @ -21,6 +21,7 @@ let make = | |||
|       ~data, | ||||
|       ~minX=?, | ||||
|       ~maxX=?, | ||||
|       ~scale=?, | ||||
|       ~height=200, | ||||
|       ~color=`hex("111"), | ||||
|       ~onHover: float => unit, | ||||
|  | @ -30,6 +31,7 @@ let make = | |||
|       height | ||||
|       ?minX | ||||
|       ?maxX | ||||
|       ?scale | ||||
|       marginBottom=50 | ||||
|       marginTop=0 | ||||
|       onHover | ||||
|  |  | |||
|  | @ -1,6 +1,6 @@ | |||
| module Continuous = { | ||||
|   [@react.component] | ||||
|   let make = (~data) => { | ||||
|   let make = (~data, ~unit) => { | ||||
|     let (x, setX) = React.useState(() => 0.); | ||||
|     let chart = | ||||
|       React.useMemo1( | ||||
|  | @ -51,6 +51,7 @@ module Continuous = { | |||
| let make = (~dist) => { | ||||
|   switch ((dist: option(DistributionTypes.genericDistribution))) { | ||||
|   | Some({ | ||||
|       unit, | ||||
|       generationSource: | ||||
|         Shape( | ||||
|           Mixed({ | ||||
|  | @ -61,7 +62,7 @@ let make = (~dist) => { | |||
|         ), | ||||
|     }) => | ||||
|     <div> | ||||
|       <Continuous data={n |> Shape.Continuous.toPdf} /> | ||||
|       <Continuous data={n |> Shape.Continuous.toPdf} unit /> | ||||
|       {d |> Shape.Discrete.scaleYToTotal(f) |> Shape.Discrete.render} | ||||
|     </div> | ||||
|   | _ => <div /> | ||||
|  |  | |||
|  | @ -14,13 +14,6 @@ function getRandomInt(min, max) { | |||
|   return Math.floor(Math.random() * (max - min + 1)) + min; | ||||
| } | ||||
| 
 | ||||
| /** | ||||
|  * Example input: | ||||
|  * { | ||||
|  * xs: [50,100,300,400,500,600], | ||||
|  * ys: [0.1, 0.4, 0.6, 0.7,0.8, 0.9]} | ||||
|  * } | ||||
|  */ | ||||
| function CdfChart(props) { | ||||
|   const id = "chart-" + getRandomInt(0, 100000); | ||||
|   const [sized, { width }] = useSize(() => { | ||||
|  | @ -47,6 +40,7 @@ function CdfChart(props) { | |||
|       .showVerticalLine(props.showVerticalLine) | ||||
|       .container("#" + id) | ||||
|       .data({ primary: props.primaryDistribution }) | ||||
|       .scale('linear') | ||||
|       .render(); | ||||
|   }); | ||||
| 
 | ||||
|  |  | |||
|  | @ -76,6 +76,11 @@ class Chartigo { | |||
|     return this; | ||||
|   } | ||||
| 
 | ||||
|   scale(scale) { | ||||
|     this.attrs.scale = scale; | ||||
|     return this; | ||||
|   } | ||||
| 
 | ||||
|   onHover(onHover) { | ||||
|     this.attrs.onHover = onHover; | ||||
|     return this; | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user