Total serology test numbers

API
Vega-Lite error
The graphic does not refer to its dataset.
{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "data": {
    "url": "https://datagraphics.dc.scilifelab.se/api/dataset/6d6f551abc10413a97a6ab64ebac46bd.csv"
  },
  "transform": [
    {
      "calculate": "if(datum.class === 'R&D', 'R&D*', datum.class)",
      "as": "classUpdated"
    },
    {
      "calculate": "if(datum.class === 'positive', datum.count, 0)",
      "as": "onlyPositive"
    },
    {
      "calculate": "if(datum.class === 'negative', datum.count, 0)",
      "as": "onlyNegative"
    },
    {
      "joinaggregate": [
        {
          "op": "sum",
          "field": "onlyPositive",
          "as": "onlyPositiveSum"
        },
        {
          "op": "sum",
          "field": "onlyNegative",
          "as": "onlyNegativeSum"
        }
      ]
    },
    {
      "calculate": "datum.onlyPositiveSum/((datum.onlyPositiveSum+datum.onlyNegativeSum)/100)",
      "as": "frPos"
    }
  ],
  "hconcat": [
    {
      "width": 500,
      "height": 60,
      "title": "Total number of tests",
      "encoding": {
        "y": {
          "field": "classUpdated",
          "axis": {
            "title": null
          },
          "type": "nominal",
          "sort": [
            "positive",
            "negative",
            "R&D*"
          ]
        },
        "x": {
          "field": "count",
          "aggregate": "sum",
          "type": "quantitative",
          "title": null,
          "scale": {
            "padding": 10
          }
        },
        "color": {
          "field": "classUpdated",
          "legend": null,
          "type": "nominal",
          "scale": {
            "domain": [
              "negative",
              "positive",
              "R&D*"
            ],
            "range": [
              "#8fd7f9",
              "#ef9292",
              "#c7c7c7"
            ]
          }
        }
      },
      "layer": [
        {
          "mark": {
            "type": "bar"
          }
        },
        {
          "mark": {
            "type": "text",
            "align": "left",
            "baseline": "middle",
            "dx": 3,
            "fill": "black"
          },
          "encoding": {
            "text": {
              "field": "count",
              "aggregate": "sum",
              "type": "quantitative"
            }
          }
        }
      ]
    },
    {
      "title": "Sum total",
      "width": 100,
      "height": 60,
      "mark": {
        "type": "text",
        "baseline": "middle",
        "fontSize": 14,
        "fill": "black"
      },
      "encoding": {
        "text": {
          "field": "count",
          "aggregate": "sum",
          "type": "quantitative"
        }
      }
    },
    {
      "title": "Proportion positive",
      "width": 100,
      "height": 60,
      "mark": {
        "type": "text",
        "baseline": "middle",
        "fontSize": 14,
        "fill": "black"
      },
      "encoding": {
        "text": {
          "field": "frPos",
          "aggregate": "mean",
          "type": "quantitative",
          "format": ".2f"
        }
      }
    }
  ]
}
Owner: arnold
Modified 2024-02-19T07:06:54.211Z
Created 2021-01-12T15:34:13.175Z

DataGraphics 1.0.4