-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into logscale-examples
- Loading branch information
Showing
25 changed files
with
714 additions
and
211 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { SVGProps } from 'react'; | ||
|
||
import { useDirectedEllipsePosition } from '../../hooks'; | ||
|
||
export interface AnnotationDirectedEllipseProps | ||
extends Omit< | ||
SVGProps<SVGEllipseElement>, | ||
'x1' | 'x2' | 'y1' | 'y2' | 'cx' | 'cy' | 'rx' | 'ry' | 'x' | 'y' | 'width' | ||
> { | ||
x1: number | string; | ||
y1: number | string; | ||
x2: number | string; | ||
y2: number | string; | ||
width: number | string; | ||
} | ||
|
||
export function DirectedEllipse(props: AnnotationDirectedEllipseProps) { | ||
const { x1, y1, y2, x2, color, width, style, ...otherProps } = props; | ||
|
||
const { cx, cy, rx, ry, rotation } = useDirectedEllipsePosition({ | ||
x1, | ||
y1, | ||
y2, | ||
x2, | ||
width, | ||
}); | ||
|
||
return ( | ||
<ellipse | ||
cx={cx} | ||
cy={cy} | ||
rx={rx} | ||
ry={ry} | ||
transform={`rotate(${rotation} 0 0)`} | ||
style={{ ...style, transformOrigin: 'center', transformBox: 'fill-box' }} | ||
fill={color} | ||
{...otherProps} | ||
/> | ||
); | ||
} |
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,37 @@ | ||
import { ScaleTime } from 'd3-scale'; | ||
import { useRef } from 'react'; | ||
import { useTimeTicks } from 'react-d3-utils'; | ||
|
||
import HorizontalAxis from './HorizontalAxis'; | ||
import VerticalAxis from './VerticalAxis'; | ||
import { AxisChildProps } from './types'; | ||
|
||
interface TimeAxisProps extends AxisChildProps { | ||
scale: ScaleTime<number, number>; | ||
} | ||
|
||
export default function TimeAxis(props: TimeAxisProps) { | ||
const { position, tickLabelFormat, scale, ...otherProps } = props; | ||
|
||
const axisRef = useRef<SVGGElement>(null); | ||
|
||
const direction = | ||
position === 'left' || position === 'right' ? 'vertical' : 'horizontal'; | ||
|
||
const primaryTicks = useTimeTicks(scale, direction, axisRef, { | ||
tickFormat: tickLabelFormat, | ||
}); | ||
|
||
const AxisComponent = | ||
direction === 'vertical' ? VerticalAxis : HorizontalAxis; | ||
|
||
return ( | ||
<AxisComponent | ||
scale={scale} | ||
axisRef={axisRef} | ||
primaryTicks={primaryTicks} | ||
position={position} | ||
{...otherProps} | ||
/> | ||
); | ||
} |
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
Oops, something went wrong.