Skip to content

Is there an easy way to color Pie Chart #1177

Answered by moyicat
moyicat asked this question in Q&A
Discussion options

You must be logged in to vote

Figured it out by looking into the <Pie /> code. But still confused that it doesn't seem to be using <Arc /> but goes to build <path> directly, is that by design?

Updated working code

<Pie
  data={letters}
  pieValue={frequency}
  pieSortValues={() => -1}
  outerRadius={radius}
  innerRadius={radius - donutThickness}
>
  {(pie) => {
    console.log(pie);
    return (
      <Group className="visx-pie-arcs-group">
        {pie.arcs.map((arc, i) => (
          <g key={`pie-arc-${i}`}>
            <path
              d={pie.path(arc) || ""}
              fill={getLetterFrequencyColor(arc.data.letter)}
            />
          </g>
        ))}
      </Group>
    );
  }}
</Pie>

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@williaster
Comment options

@moyicat
Comment options

@williaster
Comment options

Answer selected by williaster
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants