Monday, August 16, 2021

HOW TO MAKE A BAR CHART

 



How to Make a Bar Chart

by: Arnel Lopez Cadelina

 

Bar charts are so well accepted that they are the default chart type Tableau creates when you double-click on a measure from within the Data pane, which is the first method for creating a bar chart in Tableau. The bar charts were introduced in 1786 by William Playfair in his “The Commercial and Political Atlas”. The bar charts are being used for more than two centuries and are still an essential option for any visual analytics project today. Playfair’s bar charts are so effective because they leverage the preattentive attribute of height (when the chart is in a vertical orientation) or length (when the chart is in a horizontal orientation), which humans are extremely efficient at comparing.

 In Tableau Public users can automatically produce a bar chart when a dimension is a drag to the Row shelf and measure to the Column shelf. Users can also use the bar chart option present in the Show Me button. Various types of bar charts can be created by using a dimension and a measure in Tableau.

 Simple Bar Chart

 From the Sample-Superstore, choose the dimension, take the sub-category to the columns shelf, and sales to the rows shelf. Shown in the screenshot below is a simple vertical bar chart.

 


Figure 28. Simple Bar Chart.

 


Bar Chart with Color Range

 Colors can be applied to the bars based on their ranges. The longer bars get darker shades and the smaller bars get the lighter shades. In Tableau Public, users can do this by dragging the profit field to the color palette under the Marks Pane. If users want to distinguish the Category, drag the Category in the Marks Card and choose Color.

 


 Figure 29. Bar Chart with Color Range.

 

Swapping the Rows and Columns

 In Tableau Public users can swap the rows and columns to convert the vertical bar chart to a horizontal bar chart. Users can do this by clicking the “Swap Rows and Columns” button.

 Then users can convert the bar chart in ascending or descending order by clicking the “Sorted” button is shown below.

 
Figure 30Swap Rows and Columns Button.


Figure 31. Horizontal Bar Chart.

Figure 33. Sorted Horizontal Bar Chart.

 Stacked Bar Chart

 Users can add another dimension to the bar chart to produce a stacked bar chart, which shows different colors in each bar. Drag the dimension field named segment to the Marks pane and drop it in colors. The following chart appears which shows the distribution of each segment in each bar. Stacked bars are useful when you want to understand part-to-whole relationships.

 

 Figure 34. Stacked Bar Chart.

 


One Step Further: Add Totals to Stacked Bars

Users can add a total label at the top of every bar even when the bars are subdivided as in the view you just created. In the following procedure, you will technically be adding a reference line. But by configuring that "line" in a certain way, you end up with the labels you want.

1.    From the Analytics pane, drag a Reference Line into the view and drop it on Cell.





Figure 35. Reference Line.

2.    In the Edit Line, Band, or Box dialog box, set the aggregation for SUM(Sales) to Sum, set Label to Value, and set Line under Formatting to None:

Figure 36. Editing the Reference Line.

Then click OK to close the Edit Reference Line, Band, or Box dialog box. Your view now has currency totals at the top of each bar:





Figure 37. Stacked Bars with Total.

You may need to adjust the view to make it look just right. If the bars are too narrow, the numbers are truncated; to fix this, press Ctrl + Right on the keyboard to make the bars wider. Or if you want to center the totals over the bars—by default, they are left-aligned. Do the following:

3.    Right-click any of the totals on the bar chart and select Format.

4.    In the Format window, in the Reference Line Label area, open the Alignment control and select the Center option for Horizontal alignment:

Figure 38. Reference Line Alignment Control.

No comments:

Post a Comment