  {
    "$schema": "https://vega.github.io/schema/vega/v4.json",
    "width": 600,
    "height": 360,
    "autosize": "fit",
    "title": {
      "text": "SCATTER PLOT",
      "anchor": "start",
      "color": "#485465",
      "fontSize": 13,
      "fontWeight": 900,
      "font": "roboto"
    },
    "signals": [
      {
        "name": "zero",
        "value": 0
      },
      {
        "name": "two_PI",
        "value": 6.29
      },
      {
        "name": "sort", "value": true
      }
    ],
    "data": [
      {
        "name": "table",
        "url": "<%= dataset_url %>",
        "transform": [
          {
            "type": "pie",
            "field": "<%= data_mapper.column_1 %>",
            "startAngle": {
              "signal": "zero"
            },
            "endAngle": {
              "signal": "two_PI"
            },
            "sort": {"signal": "sort"}
          },
          {
            "type": "joinaggregate",
            "fields": ["<%= data_mapper.column_1 %>"],
            "ops": ["sum"],
            "as": ["total"]
          }
        ]
      }
    ],
    "scales": [
      {
        "name": "text_to_color",
        "type": "ordinal",
        "domain": {
          "data": "table",
          "field": "<%= data_mapper.column_2 %>"
        },
        "range": "category"
      },
      {
        "name": "number_to_color",
        "type": "linear",
        "domain": {
          "data": "table",
          "field": "<%= data_mapper.column_1 %>"
        },
        "range": {
          "scheme": "blues"
        }      
      }
    ],
    "marks": [
      {
        "name": "arc-0",
        "type": "arc",
        "from": {
          "data": "table"
        },
        "encode": {
          "update": {
            "fill": {
              "scale": "text_to_color",
              "field": "<%= data_mapper.column_2 %>"
            },
            "x": {
              "signal": "width / 2"
            },
            "y": {
              "signal": "height / 2"
            },
            "startAngle": {
              "field": "startAngle"
            },
            "endAngle": {
              "field": "endAngle"
            },
            "outerRadius": {
              "signal": "width / 4.5"
            },
            "innerRadius": {
              "signal": "width / 6"
            },
            "stroke": {
              "value": "#fff"
            },
            "opacity": {
              "value": 0.9
            },
            "tooltip": {"signal": "datum"}
          }
        }
      },
      {
        "name": "category_labels",
        "type": "text",
        "from": {
          "data": "table"
        },
        "encode": {
          "update": {
            "font": {
              "value": "Roboto"
            },
            "fill": {
              "value": "#800040"
            },
            "opacity": {"signal": "datum.endAngle < 1 ? 0: 1"},
            "fontSize": {
              "value": 12
            },
            "x": {
              "signal": "width / 2"
            },
            "y": {
              "signal": "height / 2"
            },
            "radius": {
              "signal": "width/4"
            },
            "theta": {
              "signal": "(datum['startAngle'] + datum['endAngle'])/2"
            },
            "text": {
              "signal": "datum['<%= data_mapper.column_2 %>'] + ', ' + format(datum['<%= data_mapper.column_1 %>']/datum['total'], '.0%')"
            },
            "baseline": {
              "value": "middle"
            },
            "align": {
              "signal": "(datum.startAngle + datum.endAngle)/2 > 0 && (datum.startAngle + datum.endAngle)/2 < 3.14 ? 'left' : 'right' "
            }
          }
        }
      }
    ]
  }
