|
|
|
@ -22,7 +22,7 @@ export const VizWrapper: FC<Props> = ({ data, currentPanel, changePanel }) => { |
|
|
|
|
}); |
|
|
|
|
const panels = getSupportedPanels(); |
|
|
|
|
const vizHeight = useVizHeight(data, currentPanel, options.frameIndex); |
|
|
|
|
const styles = useStyles2(getStyles); |
|
|
|
|
const styles = useStyles2(getStyles(vizHeight)); |
|
|
|
|
|
|
|
|
|
if (!options || !data) { |
|
|
|
|
return null; |
|
|
|
@ -33,15 +33,15 @@ export const VizWrapper: FC<Props> = ({ data, currentPanel, changePanel }) => { |
|
|
|
|
<div className={styles.buttonGroup}> |
|
|
|
|
<RadioButtonGroup options={panels} value={currentPanel} onChange={changePanel} /> |
|
|
|
|
</div> |
|
|
|
|
<div style={{ height: vizHeight, width: '100%' }}> |
|
|
|
|
<AutoSizer style={{ width: '100%', height: '100%' }}> |
|
|
|
|
{({ width, height }) => { |
|
|
|
|
if (width === 0 || height === 0) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
return ( |
|
|
|
|
<AutoSizer> |
|
|
|
|
{({ width }) => { |
|
|
|
|
if (width === 0) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
return ( |
|
|
|
|
<div style={{ height: `${vizHeight}px`, width: `${width}px` }}> |
|
|
|
|
<PanelRenderer |
|
|
|
|
height={height} |
|
|
|
|
height={vizHeight} |
|
|
|
|
width={width} |
|
|
|
|
data={data} |
|
|
|
|
pluginId={currentPanel} |
|
|
|
@ -49,10 +49,10 @@ export const VizWrapper: FC<Props> = ({ data, currentPanel, changePanel }) => { |
|
|
|
|
onOptionsChange={setOptions} |
|
|
|
|
options={options} |
|
|
|
|
/> |
|
|
|
|
); |
|
|
|
|
}} |
|
|
|
|
</AutoSizer> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
|
); |
|
|
|
|
}} |
|
|
|
|
</AutoSizer> |
|
|
|
|
</div> |
|
|
|
|
); |
|
|
|
|
}; |
|
|
|
@ -63,9 +63,10 @@ const getSupportedPanels = () => { |
|
|
|
|
.map((panel) => ({ value: panel.id, label: panel.name, imgUrl: panel.info.logos.small })); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const getStyles = (theme: GrafanaTheme2) => ({ |
|
|
|
|
const getStyles = (visHeight: number) => (theme: GrafanaTheme2) => ({ |
|
|
|
|
wrapper: css` |
|
|
|
|
padding: 0 ${theme.spacing(2)}; |
|
|
|
|
height: ${visHeight + theme.spacing.gridSize * 4}px; |
|
|
|
|
`,
|
|
|
|
|
autoSizerWrapper: css` |
|
|
|
|
width: 100%; |
|
|
|
|