This demo shows the side-by-side stacked bar series that allows you to visualize data as bars stacked in different groups. This series type is useful when you compare values of an individual series with the total values of groups.
The side-by-side stacked bar chart contains series with the same argument field. In this demo, the data source array consists of the objects with the same field structure. Assign the
state field to the argumentField property of the commonSeriesSettings object to specify the common argument for the series. Then, define the series array of objects. In each object, specify the valueField property and use the stack property to group the series in stacks depending on the stack property values.
The customizeLegend function allows you to change the order, text, and visibility of legend items. This demo uses the array.splice method in the customizeItems function to sort the legend items. If you want to customize the legend border, use properties collected in the border object.
To allow users to export your side-by-side stacked bar chart into a PNG, JPEG, PDF, and SVG file or print the chart, set the export.enabled property to true. Since the export functionality is enabled in this demo, you can click the hamburger button in the chart to invoke a drop-down menu with export and print commands.