9
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Rechartsのbarchartでバーを横にする

Posted at

Rechartsはreactのグラフ描画のライブラリですがBarChartを横にする場合、layoutをverticalにするとグラフが消えてしまうという問題が起きていました。

この問題の対処はYAxisのtypeをcategoryにし、XAxisのtypeをnumberにすることで解決します。

<BarChart
        width={400}
        height={200}
        layout="vertical"
        data={data}>
        <XAxis type="number"/>
        <YAxis   dataKey="name" type="category" />
        <Bar dataKey="pv" fill="#8884d8" />
        <Bar dataKey="uv" fill="#82ca9d" />
        <Bar dataKey="amt" fill="#74ca1d" />
</BarChart>

3時間くらい嵌りました‥。

9
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?