# ChoroplethSVG Examples

**Visualization Reference:** undefined

## Loaded as a literal SVG

- **Key:** Literal Svg Example

```json
{
  "context": {},
  "options": {},
  "dataSources": {
    "primary": {
      "data": {
        "fields": [
          {
            "name": "foo"
          }
        ],
        "columns": [
          [
            1
          ]
        ]
      }
    }
  }
}
```

## Loaded as a SVG data URI

- **Key:** Data Urisvg Example

```json
{
  "context": {},
  "options": {},
  "dataSources": {
    "primary": {
      "data": {
        "fields": [
          {
            "name": "foo"
          }
        ],
        "columns": [
          [
            1
          ]
        ]
      }
    }
  }
}
```

## Remote SVG Example

- **Key:** Remote Svg Example

```json
{
  "context": {},
  "options": {},
  "dataSources": {
    "primary": {
      "data": {
        "fields": [
          {
            "name": "foo"
          }
        ],
        "columns": [
          [
            1
          ]
        ]
      }
    }
  }
}
```

## Set the background color

- **Key:** Background Color Example

```json
{
  "context": {},
  "options": {
    "backgroundColor": "#00FFFF"
  },
  "dataSources": {
    "primary": {
      "data": {
        "fields": [
          {
            "name": "foo"
          }
        ],
        "columns": [
          [
            1
          ]
        ]
      }
    }
  }
}
```

## Specify match color values for individual region fill colors using areaIds

- **Key:** Area Id Match Color

```json
{
  "context": {
    "matches": [
      {
        "match": "ATX-270-B",
        "value": "#FF7152"
      },
      {
        "match": "N-224",
        "value": "#FC9850"
      },
      {
        "match": "VM-203",
        "value": "#4BEBA8"
      },
      {
        "match": "RF-380",
        "value": "#F4DF7A"
      }
    ]
  },
  "options": {
    "areaIds": "> primary|seriesByIndex(0)",
    "areaValues": "> primary|seriesByIndex(1)",
    "areaColors": "> areaIds|matchValue(matches)"
  },
  "dataSources": {
    "primary": {
      "data": {
        "fields": [
          {
            "name": "buildings"
          },
          {
            "name": "values"
          }
        ],
        "columns": [
          [
            "ATX-270-B",
            "N-224",
            "VM-203",
            "RF-380"
          ],
          [
            10000,
            55000,
            90000,
            75000
          ]
        ]
      }
    }
  }
}
```

## Specify range values for individual region fill colors

- **Key:** Color Ranges Example

```json
{
  "context": {
    "areaColorThresholds": [
      {
        "from": 100000,
        "value": "#4BEBA8"
      },
      {
        "from": 50000,
        "to": 100000,
        "value": "#F4DF7A"
      },
      {
        "from": 1000,
        "to": 50000,
        "value": "#FC9850"
      },
      {
        "to": 1000,
        "value": "#FF7152"
      }
    ]
  },
  "options": {
    "areaIds": "> primary | seriesByIndex(0)",
    "areaValues": "> primary | seriesByIndex(1)",
    "areaColors": "> areaValues | rangeValue(areaColorThresholds)"
  },
  "dataSources": {
    "primary": {
      "data": {
        "fields": [
          {
            "name": "buildings"
          },
          {
            "name": "values"
          }
        ],
        "columns": [
          [
            "ATX-270-B",
            "N-224",
            "VM-203",
            "RF-380"
          ],
          [
            10000,
            55000,
            90000,
            75000
          ]
        ]
      }
    }
  }
}
```

## Specify multiple formatting configs for each individual region fill colors

- **Key:** Multiple Color Ranges Example

```json
{
  "context": {
    "areaColorsConfig": {
      "nameField": "buildings",
      "valueField": "values",
      "formatters": {
        "ATX-270-B": {
          "type": "matchValue",
          "config": [
            {
              "match": 10000,
              "value": "#00FF00"
            },
            {
              "match": 20000,
              "value": "#FF0000"
            }
          ]
        },
        "N-224": {
          "type": "gradient",
          "config": {
            "colors": [
              "#FF7152",
              "#FFEBA8"
            ]
          }
        },
        "VM-203": {
          "type": "rangeValue",
          "config": [
            {
              "from": 80000,
              "value": "#4B4BFF"
            },
            {
              "to": 20000,
              "value": "#FF0000"
            }
          ]
        },
        "RF-380": {
          "type": "rangeValue",
          "config": [
            {
              "from": 80000,
              "value": "#4BEBA8"
            },
            {
              "from": 60000,
              "to": 80000,
              "value": "#F4DF7A"
            },
            {
              "from": 20000,
              "to": 60000,
              "value": "#FC9850"
            },
            {
              "to": 20000,
              "value": "#FF0000"
            }
          ]
        }
      }
    }
  },
  "options": {
    "areaIds": "> primary | seriesByIndex(0)",
    "areaValues": "> primary | seriesByIndex(1)",
    "areaColors": "> primary | multiFormat(areaColorsConfig)"
  },
  "dataSources": {
    "primary": {
      "data": {
        "fields": [
          {
            "name": "buildings"
          },
          {
            "name": "values"
          }
        ],
        "columns": [
          [
            "ATX-270-B",
            "N-224",
            "VM-203",
            "RF-380"
          ],
          [
            10000,
            55000,
            90000,
            75000
          ]
        ]
      }
    }
  }
}
```

## Specify linear gradient for individual region fill colors

- **Key:** Color Gradient Example

```json
{
  "context": {
    "areaColorGradient": {
      "colors": [
        "#FF7152",
        "#4BEBA8"
      ]
    }
  },
  "options": {
    "areaIds": "> primary | seriesByIndex(0)",
    "areaValues": "> primary | seriesByIndex(1)",
    "areaColors": "> areaValues | gradient(areaColorGradient)"
  },
  "dataSources": {
    "primary": {
      "data": {
        "fields": [
          {
            "name": "buildings"
          },
          {
            "name": "values"
          }
        ],
        "columns": [
          [
            "ATX-270-B",
            "N-224",
            "VM-203",
            "RF-380"
          ],
          [
            10000,
            55000,
            90000,
            75000
          ]
        ]
      }
    }
  }
}
```
