Few months ago I needed to create a stacked bar chart and ran into issues (Perspective 8.0.14 Time Series Bar Chart width - #3 by arun1). There are few posts here but they don’t give a full picture. Here are the steps that I took to create one:
- First it is worthwhile to note that we need to use the XY chart and not the TimeSeries chart because the width of the bar chart is calculated automatically based on the amount of data in the x-axis so if you have sparse data in a wide time range then this bar chart will end up as thin vertical lines. (Perspective 8.0.14 Time Series Bar Chart width - #2 by jball). See Note 2 in the end
- The dataset needs to be such that the different categories need to have their own columns. For example if there are 3 categories of alarms that can occur on any day then the dataset should have 3 separate columns each containing the total number of alarms of one category:
- To keep things simple, let’s start with the dataset that comes with default XY Chart when you drag it in from the Perspective Components window. The default XY chart will look like this:
Our goal is to convert the above plot such that both Process and Outside Temp are represented as bars, one on top of the other, aka a stacked bar chart. If we are successful it look like this:
- Click on the chart, go to the Series 0 and 1 and configure them to be plotted on the same yAxis as shown below:
and
- Change both Series 0 and 1 ‘render’ property from Line to Column:
- All the above steps will result in:
- Since we have selected Column, we can now drill into column property to get to column/appearance/stacked and check the box:
- Only when both the series have their stacked property checked, the chart will display the proper stacked bar chart
Notes:
i. One of the Inductive programmers has opened a ticket to allow the user to specify the Bar chart width. Not sure if it has been addressed
ii. The default TimeSeries Chart of type Bar does look like a stacked bar chart but has limitations if the time axis range is too wide:
The same data over a wider time range does not look like bar graph because the bars are too thin:
Hope this was helpful.
Thanks
