iCHEF / transcharts

Chart library built with React
https://ichef.github.io/transcharts/
Apache License 2.0
2 stars 0 forks source link

[Feature] Support drawing the horizontal bar chart #40

Closed hsunpei closed 5 years ago

hsunpei commented 5 years ago

Purpose

Previously, we can only draw vertical bar charts. Since horizontal bar charts are particularly useful on mobile devices, it is desirable to have it supported.

This PR realize drawing the horizontal bar chart by analyzing the data types of the X and Y axis: if the data type of the x-axis is quantitative, it should draw a horizontal chart, and draw the bars from the y-axis instead (via passing down the prop drawFromXAxis={false}).

Transchart 2019-07-23 16-43-56

Additionally, to make the charts which have both positive and negative value on the quantitative axis more readable, it adds a gray auxiliary line at zero-value.

Changes

Screenshots

Horizontal chart

Transchart 2019-07-23 16-56-33

Original vertical chart => Transposed horizontal chart

Displaying tooltips

screencast 2019-07-23 17-30-00