2 100% Stacked Column Chart - Charticulator

Hi @rit372002. Here’s a rough first try using Deneb using a horizontal concatenation of 2 column charts (actually simple bar charts with “x” and “y” reversed):

Only did a proof-of concept, as you noted that you may end-up using Charticulator, nevertheless, if further Deneb development is desired, you’ll want to address:

  • formatting the Y-axis as a percentage
  • centering the X-axis titles
  • decreasing the spacing between the columns as desired
  • adding a “transform” block to calculate the percentages
  • adding “text” marks for the percentages in the columns

The Deneb code I used is:

{
  "data": {"name": "dataset"},
  "hconcat": [
    {
      "mark": {
        "type": "bar",
        "width": 40,
        "tooltip": true
      },
      "encoding": {
        "x": {
          "field": "Employee Type",
          "type": "nominal",
          "axis": {"labelAngle": 0}
        },
        "y": {
          "aggregate": "sum",
          "field": "Employee Count",
          "title": "Percent",
          "stack": "normalize",
          "axis": {"offset": 25}
        },
        "color": {"field": "Gender"},
        "opacity": {
          "condition": {
            "test": {
              "field": "__selected__",
              "equal": "off"
            },
            "value": 0.3
          },
          "value": 1
        }
      }
    },
    {
      "mark": {
        "type": "bar",
        "width": 40,
        "tooltip": true
      },
      "encoding": {
        "x": {
          "field": "Employee Type",
          "type": "nominal",
          "axis": null
        },
        "y": {
          "aggregate": "sum",
          "field": "Employees Receiving Bonus",
          "stack": "normalize",
          "axis": null
        },
        "color": {"field": "Gender"},
        "opacity": {
          "condition": {
            "test": {
              "field": "__selected__",
              "equal": "off"
            },
            "value": 0.3
          },
          "value": 1
        }
      }
    }
  ]
}

Hope it helps
Greg
eDNA Forum - 2 100% Stacked Bar Charts.pbix (1.3 MB)

4 Likes