Skip to content

Rechart

gyim1345 edited this page Nov 27, 2020 · 5 revisions

RechartsλŠ” React 및 D3으둜 μž‘μ„±λœ 차트 λΌμ΄λΈŒλŸ¬λ¦¬λ‹€.

이 라이브러리의 μ£Όμš” λͺ©μ μ€ 고톡 없이 λ¦¬μ•‘μ…˜ μ• ν”Œλ¦¬μΌ€μ΄μ…˜μ—μ„œ 차트λ₯Ό μž‘μ„±ν•  수 μžˆλ„λ‘ λ„μ™€μ£ΌλŠ” 것이닀.

Rechart의 μ£Όμš” 원칙은 λ‹€μŒκ³Ό κ°™λ‹€.

  1. React component둜 μ‰½κ²Œ μ‚¬μš©.
  2. Native SVG 지원, 일뢀 D3 submodules에 ν•œν•΄ κ²½λŸ‰ν™”
  3. Declarative components이고, 차트의 componentλŠ” μˆœμˆ˜ν•˜κ²Œ presentational ν•˜λ‹€.

단, 이 라이브러리 μ‚¬μš©μ‹œ μ™ΈλΆ€ 라이브러리 d3-scaleκ³Ό d3-scale-chromatic에 μ˜μ‘΄μ μ΄λ‹€.

예)

<PieChart width={400} height={325}>
  <Legend paylodUniqBy />
  <Pie
    data={data}
    dataKey="value"
    cx={200}
    cy={125}
    startAngle={180}
    endAngle={-180}
    innerRadius={60}
    outerRadius={70}
    label={renderLabelContent}
    paddingAngle={5}
    isAnimationActive={true}
  >
    {data.map((entry, index) => (
      <Cell key={`slice-${index}`} fill={colors[index % 10]} />
    ))}
    <Label width={50} position="center">
      μ§€μΆœ
    </Label>
  </Pie>
</PieChart>

chart

Clone this wiki locally