JavaScript Stacked Bar Chart

This example shows creation of a Stacked Bars Chart.

The stacked bar chart (aka stacked bar graph) extends the standard bar chart from looking at numeric values across one categorical variable to two. Each bar in a standard bar chart is divided into a number of sub-bars stacked end to end, each one corresponding to a level of the second categorical variable.

Here's the creation of a Stacked Bar Chart with LightningChart JS.

// Create Chart.
const barChart = lightningChart().BarChart()

// Add categories and subCategory & values.
barChart.setDataStacked(
    ['category1', 'category2', 'category2'],
    [
        { subCategory: 'subCategory 1', values: [1, 51, 43] },
        { subCategory: 'subCategory 2', values: [66, 18, 1] },
        { subCategory: 'subCategory 3', values: [1, 7, 20] },
    ],
)