How to create a horizontal bar in Chart JS. In this post we will cover how to create a horizontal bar chart. Creating a horizontal bar chart in Chart JS is not that much different compare to a bar chart. In essence it is a bar chart with a 90 degree angle. Watch this video:
Horizontal Bar Chart in Chart JS
To make a horizontal bar chart you will need to understand what actually happens. We will use the namespace indexAxis to swap the values from the x-axis to the y-axis and visa verse. By swapping them the bar chart basically changes at an angle of 90 degrees. The y-axis get the labels and the bars start a the left and move to the right depending on their values.
So in essence it is just a bar chart where the x and y scales or axis has been switched. Know this gives you a clear picture how Chart JS works under the hood.