Skip to content

Commit efc178a

Browse files
committed
fixed display issues with annotations
1 parent 9da2b64 commit efc178a

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/App.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ function App() {
2020
{
2121
title: "Word intervals:",
2222
data: wordIntervals,
23-
height: 30,
24-
strokeWidth: 0.5,
23+
height: 20,
24+
strokeWidth: 1,
2525
},
2626
{
2727
title: "Phone intervals:",
2828
data: phoneIntervals,
29-
height: 30,
29+
height: 20,
3030
strokeWidth: 0.5,
3131
},
3232
]

src/lib/SpectogramAnnotations.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Fragment } from "react";
44
import { useTheme } from "./ThemeProvider";
55
import { Annotations } from "./Annotation";
66

7-
const DEFAULT_HEIGHT = 30
7+
const DEFAULT_HEIGHT = 20
88
const DEFAULT_STROKE_WIDTH = 1
99

1010
function SpectrogramAnnotations(props: Annotations) {
@@ -22,7 +22,8 @@ function SpectrogramAnnotations(props: Annotations) {
2222
}
2323
handleWindowResize()
2424
window.addEventListener('resize', handleWindowResize);
25-
}, []);
25+
setInterval(handleWindowResize, 500)
26+
}, []);
2627

2728

2829
const { startTime: zoomStartTime, endTime: zoomEndTime } = useZoom()
@@ -35,12 +36,12 @@ function SpectrogramAnnotations(props: Annotations) {
3536

3637
const svgFontSize = svgCanvasHeight * 0.67
3738
const svgStrokeWidth = 0.001 * strokeWidth * displayRange
38-
39+
3940
const textPosY = svgCanvasHeight * 0.67
4041

4142
return (
4243
<Fragment>
43-
<span style={{font: 'monospace', color: annotationColor}}> {title} </span>
44+
<div style={{textAlign: 'left', fontFamily: 'monospace', color: annotationColor }}>{title}</div>
4445
<svg ref={svgRef} width="100%" height={height} viewBox={`${zoomStartTime},0,${displayRange},${svgCanvasHeight}`} preserveAspectRatio="none">
4546
{data.map((annotation) => {
4647
const start = Number(annotation[0])
@@ -49,7 +50,7 @@ function SpectrogramAnnotations(props: Annotations) {
4950
return (
5051
<Fragment key={start}>
5152
<line stroke={annotationColor} strokeWidth={svgStrokeWidth} x1={start} x2={start} y1={0} y2={svgCanvasHeight} />
52-
<text fill={annotationColor} x={start} y={textPosY} fontSize={svgFontSize}>&nbsp;{text}</text>
53+
<text fill={annotationColor} x={start} y={textPosY} fontSize={svgFontSize} fontFamily='monospace'>&nbsp;{text}</text>
5354
<line stroke={annotationColor} strokeWidth={svgStrokeWidth} x1={stop} x2={stop} y1={0} y2={svgCanvasHeight} />
5455
</Fragment>
5556
)

0 commit comments

Comments
 (0)