Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
holtzy committed Nov 4, 2024
1 parent 790977b commit 9f456ca
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
2 changes: 0 additions & 2 deletions pages/course/hover-effect/css-pseudo-class.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,6 @@ export default function Home() {
},
]}
/>

<Graph11 />
</LayoutCourse>
);
}
Expand Down
22 changes: 7 additions & 15 deletions viz/ScatterplotHoverHighlightPseudoClass/Scatterplot.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import * as d3 from "d3";
import styles from "./scatterplot.module.css";
import { AxisLeft } from "./AxisLeft";
import { AxisBottom } from "./AxisBottom";
import { useState } from "react";
import * as d3 from 'd3';
import styles from './scatterplot.module.css';
import { AxisLeft } from './AxisLeft';
import { AxisBottom } from './AxisBottom';

const MARGIN = { top: 60, right: 60, bottom: 60, left: 60 };

Expand All @@ -17,8 +16,6 @@ export const Scatterplot = ({ width, height, data }: ScatterplotProps) => {
const boundsWidth = width - MARGIN.right - MARGIN.left;
const boundsHeight = height - MARGIN.top - MARGIN.bottom;

const [hoveredGroup, setHoveredGroup] = useState<string | null>(null);

// Scales
const yScale = d3.scaleLinear().domain([35, 85]).range([boundsHeight, 0]);
const xScale = d3
Expand All @@ -29,14 +26,11 @@ export const Scatterplot = ({ width, height, data }: ScatterplotProps) => {
const colorScale = d3
.scaleOrdinal<string>()
.domain(allGroups)
.range(["#e0ac2b", "#e85252", "#6689c6", "#9a6fb0", "#a53253"]);
.range(['#e0ac2b', '#e85252', '#6689c6', '#9a6fb0', '#a53253']);

// Build the shapes
const allShapes = data.map((d, i) => {
const className =
hoveredGroup && d.group !== hoveredGroup
? styles.scatterplotCircle + " " + styles.dimmed
: styles.scatterplotCircle;
const className = styles.scatterplotCircle;

return (
<circle
Expand All @@ -47,8 +41,6 @@ export const Scatterplot = ({ width, height, data }: ScatterplotProps) => {
className={className}
stroke={colorScale(d.group)}
fill={colorScale(d.group)}
onMouseOver={() => setHoveredGroup(d.group)}
onMouseLeave={() => setHoveredGroup(null)}
/>
);
});
Expand All @@ -60,7 +52,7 @@ export const Scatterplot = ({ width, height, data }: ScatterplotProps) => {
<g
width={boundsWidth}
height={boundsHeight}
transform={`translate(${[MARGIN.left, MARGIN.top].join(",")})`}
transform={`translate(${[MARGIN.left, MARGIN.top].join(',')})`}
>
{/* Y axis */}
<AxisLeft yScale={yScale} pixelsPerTick={40} width={boundsWidth} />
Expand Down

0 comments on commit 9f456ca

Please sign in to comment.