Skip to content

Commit

Permalink
Hacked the type.
Browse files Browse the repository at this point in the history
  • Loading branch information
buchananwill committed Apr 4, 2024
1 parent 1bc65b4 commit abaf4bc
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions app/playground/arcChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
BASE_HSL,
HUE_OPTIONS
} from '../generic/components/color/color-context';
import { Ribbon } from 'd3';
import { BaseType, Chord, ChordGroup, ChordSubgroup } from 'd3';

export default function ArcChart({ data }: { data: number[][] }) {
const width = 640;
Expand All @@ -22,11 +22,14 @@ export default function ArcChart({ data }: { data: number[][] }) {
.sortGroups(d3.descending)
.sortSubgroups(d3.ascending);

const arc = d3.arc().innerRadius(innerRadius).outerRadius(outerRadius);
const arc = d3
.arc<ChordGroup>()
.innerRadius(innerRadius)
.outerRadius(outerRadius);

const ribbon = d3.ribbon().radius(innerRadius);
const ribbon = d3.ribbon<Chord, ChordSubgroup>().radius(innerRadius);

const color = d3.scaleOrdinal(d3.schemeCategory10);
const ribbonGenerator = ribbon.context(null) as (d: Chord) => string;

const chords = chord(data);
return (
Expand Down Expand Up @@ -57,7 +60,7 @@ export default function ArcChart({ data }: { data: number[][] }) {
{chords.groups.map((group, index) => (
<path
key={index}
d={arc(group)}
d={arc(group) || ''}
fill={BASE_HSL[HUE_OPTIONS[index % HUE_OPTIONS.length].id].cssHSLA} // Modify this line to use HUE_OPTIONS if needed
stroke={BASE_HSL[HUE_OPTIONS[index % HUE_OPTIONS.length].id].cssHSLA}
/>
Expand All @@ -69,7 +72,7 @@ export default function ArcChart({ data }: { data: number[][] }) {
return (
<path
key={index}
d={ribbon(d)}
d={ribbonGenerator(d)}
fill={gradientId}
stroke={
BASE_HSL[HUE_OPTIONS[d.target.index % HUE_OPTIONS.length].id]
Expand Down

0 comments on commit abaf4bc

Please sign in to comment.