-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: Refactor object ResultArea component wiht new design. * chore: Add simple dialog. * chore: create initial plot with dummy data. * chore: Update generated api files. * chore: chore: Plot channel height data. * chore: Add min and max to data for plot. * chore: Add toggle between different plots.
- Loading branch information
1 parent
65ee09b
commit 7108d3b
Showing
17 changed files
with
508 additions
and
56 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
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
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,17 @@ | ||
/* generated using openapi-typescript-codegen -- do no edit */ | ||
/* istanbul ignore file */ | ||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
|
||
export type PercentilesDto = { | ||
p10: number; | ||
p20: number; | ||
p30: number; | ||
p40: number; | ||
p50: number; | ||
p60: number; | ||
p70: number; | ||
p80: number; | ||
p90: number; | ||
}; | ||
|
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
81 changes: 81 additions & 0 deletions
81
src/features/Results/CaseResult/CaseResultView/ObjectCaseResult/Echarts/ReactECharts.tsx
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,81 @@ | ||
/** | ||
* Component 'Borrowed' from https://dev.to/manufac/using-apache-echarts-with-react-and-typescript-353k | ||
* Echarts wrapper to make Echarts more usable with React lifecycle. | ||
* | ||
* This component only ensures that the chart is initialized with provided options, resizes the chart on container resize | ||
* and cleans up the chart when the component is removed from DOM. It also interacts with echarts | ||
* built in chart loading functionally such that this does not need to be done elsewhere. | ||
* | ||
* **Note: This base is configured such that the chart's width and height will be set to take the entire width and height | ||
* of its parent element. This behaviour can be overridden using the {@see style} prop.** | ||
*/ | ||
|
||
import { | ||
ECharts, | ||
EChartsOption, | ||
getInstanceByDom, | ||
init, | ||
SetOptionOpts, | ||
} from 'echarts'; | ||
import { CSSProperties, useEffect, useRef } from 'react'; | ||
|
||
export interface ReactEChartsProps { | ||
option: EChartsOption; | ||
style?: CSSProperties; | ||
settings?: SetOptionOpts; | ||
loading?: boolean; | ||
theme?: 'light' | 'dark'; | ||
} | ||
|
||
export function ReactECharts({ | ||
option, | ||
style, | ||
settings, | ||
loading, | ||
theme, | ||
}: ReactEChartsProps): JSX.Element { | ||
const chartRef = useRef<HTMLDivElement>(null); | ||
|
||
useEffect(() => { | ||
// Initialize chart | ||
let chart: ECharts | undefined; | ||
|
||
if (chartRef.current !== null) { | ||
chart = init(chartRef.current, theme); | ||
} | ||
|
||
// Add chart resize listener | ||
// ResizeObserver is leading to a bit janky UX | ||
function resizeChart() { | ||
chart?.resize(); | ||
} | ||
window.addEventListener('resize', resizeChart); | ||
|
||
// Return cleanup function | ||
return () => { | ||
chart?.dispose(); | ||
window.removeEventListener('resize', resizeChart); | ||
}; | ||
}, [theme]); | ||
|
||
useEffect(() => { | ||
// Update chart | ||
if (chartRef.current !== null) { | ||
const chart = getInstanceByDom(chartRef.current); | ||
chart?.setOption(option, settings); | ||
} | ||
}, [option, settings, theme]); // Whenever theme changes we need to add option and setting due to it being deleted in cleanup function | ||
|
||
useEffect(() => { | ||
// Update chart | ||
if (chartRef.current !== null) { | ||
const chart = getInstanceByDom(chartRef.current); | ||
// eslint-disable-next-line @typescript-eslint/no-unused-expressions | ||
loading === true ? chart?.showLoading() : chart?.hideLoading(); | ||
} | ||
}, [loading, theme]); | ||
|
||
return ( | ||
<div ref={chartRef} style={{ width: '100%', height: '350px', ...style }} /> | ||
); | ||
} |
59 changes: 59 additions & 0 deletions
59
src/features/Results/CaseResult/CaseResultView/ObjectCaseResult/GraphPlot/GraphPlot.tsx
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,59 @@ | ||
import { PercentilesDto } from '../../../../../../api/generated'; | ||
import { ReactECharts, ReactEChartsProps } from '../Echarts/ReactECharts'; | ||
|
||
export interface ExtendedPrecetile extends PercentilesDto { | ||
min: number; | ||
max: number; | ||
} | ||
export const GraphPlot = ({ | ||
data, | ||
mode, | ||
}: { | ||
data: ExtendedPrecetile | undefined; | ||
mode: string; | ||
}) => { | ||
if (data === undefined) return <>Loading ... </>; | ||
|
||
const option: ReactEChartsProps['option'] = { | ||
tooltip: { | ||
trigger: 'axis', | ||
axisPointer: { | ||
type: 'shadow', | ||
}, | ||
}, | ||
grid: { | ||
left: '10%', | ||
right: '10%', | ||
top: '10%', | ||
bottom: '20%', | ||
}, | ||
xAxis: { | ||
type: 'value', | ||
name: mode + ' (m)', | ||
nameLocation: 'middle', | ||
nameGap: 30, | ||
}, | ||
yAxis: { | ||
type: 'category', | ||
data: Object.keys(data), | ||
name: 'Precentile', | ||
nameLocation: 'middle', | ||
nameGap: 40, | ||
}, | ||
series: [ | ||
{ | ||
type: 'line', | ||
data: Object.values(data), | ||
}, | ||
], | ||
}; | ||
|
||
return ( | ||
<div> | ||
<ReactECharts | ||
option={option} | ||
style={{ width: '100%', height: '350px' }} | ||
/> | ||
</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
Oops, something went wrong.