Skip to content

Commit e05d155

Browse files
committed
added additional zoom capabilities
1 parent 0fa2ac0 commit e05d155

File tree

3 files changed

+23
-57
lines changed

3 files changed

+23
-57
lines changed

package.json

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,16 +107,19 @@
107107
},
108108
"dependencies": {
109109
"@visx/axis": "^1.0.0",
110+
"@visx/clip-path": "^1.0.0",
111+
"@visx/event": "^1.0.0",
112+
"@visx/glyph": "^1.0.0",
113+
"@visx/gradient": "^1.0.0",
110114
"@visx/grid": "^1.0.0",
115+
"@visx/group": "^1.0.0",
116+
"@visx/hierarchy": "^1.0.0",
111117
"@visx/legend": "^1.0.0",
112118
"@visx/responsive": "^1.0.0",
113119
"@visx/scale": "^1.0.0",
114-
"@visx/tooltip": "^1.0.0",
115-
"@visx/gradient": "^1.0.0",
116-
"@visx/group": "^1.0.0",
117-
"@visx/hierarchy": "^1.0.0",
118-
"@visx/glyph": "^1.0.0",
119120
"@visx/shape": "^1.0.0",
121+
"@visx/tooltip": "^1.0.0",
122+
"@visx/zoom": "^1.0.0",
120123
"acorn": "^7.3.1",
121124
"acorn-jsx": "^5.2.0",
122125
"bower": "^1.8.8",

src/app/components/legend.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ import { LegendOrdinal, LegendItem, LegendLabel } from '@visx/legend';
66

77
const legendGlyphSize = 8;
88

9-
type snapHierarchy = {};
9+
type snapHierarchy = {`Record<string, unknown>`}
10+
};
1011

11-
export default function LegendKey(props: `Record<string, unknown>`) {
12+
export default function LegendKey(props: snapHierarchy) {
1213
const { hierarchy } = props;
14+
console.log('which ends up being, hierarchy: ', hierarchy);
1315

1416
// We are taking the array of displayNames and sifting through them and placing each set of
1517
// branches as a key in an object, { '.0': [1.0, 2.0, 3.0, 4.0], '.1': [1.1, 2.1, 3.1,...], '.2': [....]}

src/app/components/zoomFt.tsx

Lines changed: 11 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import { Zoom } from '@visx/zoom';
55
import { localPoint } from '@visx/event';
66
import { RectClipPath } from '@visx/clip-path';
77
import { scaleLinear } from '@visx/scale';
8+
import LegendKey from './legend';
9+
import History from './History';
10+
// import { hierarchy } from '@visx/hierarchy';
811

912
const bg = '';
1013
const points = [...new Array(1000)];
@@ -21,14 +24,15 @@ const initialTransform = {
2124
skewY: 0,
2225
};
2326

24-
export type ZoomIProps = {
25-
width: number;
26-
height: number;
27-
};
27+
// export type ZoomIProps = {
28+
// width: number;
29+
// height: number;
30+
// };
2831

29-
export default function ZoomI({ width, height }: ZoomIProps) {
32+
export default function ZoomI(props: any) {
3033
const [showMiniMap, setShowMiniMap] = useState<boolean>(true);
31-
34+
// const { width, height, hierarchy, dispatch, sliderIndex, viewIndex } = props;
35+
const { width, height } = props;
3236
// const genenerator: GenPhyllotaxisFunction = genPhyllotaxis({
3337
// radius: 10,
3438
// width,
@@ -56,18 +60,7 @@ export default function ZoomI({ width, height }: ZoomIProps) {
5660
>
5761
<RectClipPath id="zoom-clip" width={width} height={height} />
5862
<rect width={width} height={height} rx={14} fill={bg} />
59-
<g transform={zoom.toString()}>
60-
{phyllotaxis.map(({ x, y }, i) => (
61-
// <React.Fragment key={`dot-${i}`}>
62-
// <circle
63-
// cx={x}
64-
// cy={y}
65-
// r={i > 500 ? sizeScale(1000 - i) : sizeScale(i)}
66-
// // fill={interpolateRainbow(colorScale(i) ?? 0)}
67-
// />
68-
</React.Fragment>
69-
))}
70-
</g>
63+
<g transform={zoom.toString()}>{/* invoke them here */}</g>
7164
<rect
7265
width={width}
7366
height={height}
@@ -88,38 +81,6 @@ export default function ZoomI({ width, height }: ZoomIProps) {
8881
zoom.scale({ scaleX: 1.1, scaleY: 1.1, point });
8982
}}
9083
/>
91-
{showMiniMap && (
92-
<g
93-
clipPath="url(#zoom-clip)"
94-
transform={`
95-
scale(0.25)
96-
translate(${width * 4 - width - 60}, ${
97-
height * 4 - height - 60
98-
})
99-
`}
100-
>
101-
<rect width={width} height={height} fill="#1a1a1a" />
102-
{phyllotaxis.map(({ x, y }, i) => (
103-
// <React.Fragment key={`dot-sm-${i}`}>
104-
// <circle
105-
// cx={x}
106-
// cy={y}
107-
// r={i > 500 ? sizeScale(1000 - i) : sizeScale(i)}
108-
// // fill={interpolateRainbow(colorScale(i) ?? 0)}
109-
// />
110-
</React.Fragment>
111-
))}
112-
<rect
113-
width={width}
114-
height={height}
115-
fill="white"
116-
fillOpacity={0.2}
117-
stroke="white"
118-
strokeWidth={4}
119-
transform={zoom.toStringInvert()}
120-
/>
121-
</g>
122-
)}
12384
</svg>
12485
<div className="controls">
12586
<button

0 commit comments

Comments
 (0)