@@ -8,6 +8,9 @@ import { Grid, GridRows } from '@visx/grid';
88import { Result , ResultKind , useResult } from '../../store/result-store' ;
99import { pickProps } from '../../common/helpers' ;
1010import { on } from '../../messenger' ;
11+ import styled from 'styled-components' ;
12+ import { LegendItem , LegendOrdinal } from '@visx/legend' ;
13+ import PropertyRowLabel from '../parameter-config/property-row/PropertyRowLabel' ;
1114
1215export type BarGroupProps = {
1316 uuid : string ;
@@ -64,9 +67,11 @@ const testrtdata: RTData[] = [
6467
6568//type CityName = 'New York' | 'San Francisco' | 'Austin';
6669
70+ const blue = '#48beff' ;
71+ const green = '#43c593' ;
72+ const darkgreen = '#14453d' ;
6773const black = '#000000' ;
68- const red = '#ff0000' ;
69- const green = '#00ff00' ;
74+
7075export const background = '#612efb' ;
7176
7277type RtType = 'Sabine' | 'Eyring' | 'AP' ;
@@ -83,12 +88,48 @@ const getFreqAsString = (d: RTData) => (d.frequency).toString()
8388const getSabine = ( d : RTData ) => d . sabine ;
8489const getEyring = ( d : RTData ) => d . eyring ;
8590
91+ const VerticalContainer = styled . div `
92+ display: flex;
93+ flex-direction: column;
94+ ` ;
95+
96+ const Title = styled . div `
97+ display: flex;
98+ justify-content: center;
99+ ` ;
100+
101+ const HorizontalContainer = styled . div `
102+ display: flex;
103+ flex-direction: row;
104+ flex: 1;
105+ ` ;
106+
107+ const LegendContainer = styled . div `
108+ display: flex;
109+ flex-direction: column;
110+ align-items: center;
111+ padding: 0px 16px;
112+ ` ;
113+
114+ const FrequencyContainer = styled . div `
115+ display: flex;
116+ flex-direction: column;
117+ align-items: center;
118+ padding: 16px 16px;
119+ ` ;
120+
121+ const GraphContainer = styled . div `
122+ display: flex;
123+ flex: 8;
124+ width: 80%;
125+ ` ;
126+
86127const useUpdate = ( ) => {
87128 const [ updateCount , setUpdateCount ] = useState < number > ( 0 ) ;
88129 return [ updateCount , ( ) => setUpdateCount ( updateCount + 1 ) ] as [ number , ( ) => void ] ;
89130}
90131
91- export const RT60Chart = ( {
132+ export const Chart = ( {
92133 uuid,
93134 width = 500 ,
94135 height = 300 ,
@@ -117,7 +158,7 @@ export const RT60Chart = ({
117158
118159 const colorScale = scaleOrdinal < string , string > ( {
119160 domain : keys ,
120- range : [ black , red , green ] ,
161+ range : [ blue , green , darkgreen ] ,
121162 } ) ;
122163
123164 useEffect ( ( ) => on ( "UPDATE_RESULT" , ( e ) => {
@@ -210,4 +251,40 @@ export const RT60Chart = ({
210251 ) ;
211252}
212253
254+ export const RT60Chart = ( {
255+ uuid,
256+ width = 500 ,
257+ height = 300 ,
258+ events = false ,
259+ } : BarGroupProps ) => {
260+ const { info, data, from} = useResult ( state => pickProps ( [ "info" , "data" , "from" ] , state . results [ uuid ] as Result < ResultKind . StatisticalRT60 > ) )
261+ const keys = Object . keys ( data [ 0 ] ) . filter ( d => d !== 'frequency' ) as RtType [ ] ;
262+
263+ return width < 10 ? null : (
264+ < VerticalContainer >
265+ < Title > { 'Statistical RT60 Results' } </ Title >
266+ < HorizontalContainer >
267+ < GraphContainer >
268+ < Chart { ...{ width, height, uuid, events } } > </ Chart >
269+ </ GraphContainer >
270+ < VerticalContainer >
271+ < LegendContainer >
272+ { keys . map ( ( k ) => {
273+ < LegendItem
274+ key = { `rt-type-${ k } ` }
275+ margin = "0 5px"
276+ onClick = { ( ) => {
277+ } } >
278+ < PropertyRowLabel
279+ label = { k . toString ( ) }
280+ />
281+ </ LegendItem >
282+ } ) }
283+ </ LegendContainer >
284+ </ VerticalContainer >
285+ </ HorizontalContainer >
286+ </ VerticalContainer >
287+ ) ;
288+ } ;
289+
213290export default RT60Chart
0 commit comments