Legacy country map visualization plugin for Apache Superset that creates interactive choropleth-style maps for displaying geographical data across various countries and regions.
npx @tessl/cli install tessl/npm-superset-ui--legacy-plugin-chart-country-map@0.18.0A legacy country map visualization plugin for Apache Superset that creates interactive choropleth-style maps for displaying geographical data across various countries and regions. This plugin enables users to visualize metrics across a country's principal subdivisions (states, provinces, etc.) with hover interactions and zoom capabilities.
npm install @superset-ui/legacy-plugin-chart-country-mapimport CountryMapChartPlugin, { countries } from "@superset-ui/legacy-plugin-chart-country-map";For CommonJS:
const CountryMapChartPlugin = require("@superset-ui/legacy-plugin-chart-country-map").default;
const { countries } = require("@superset-ui/legacy-plugin-chart-country-map");import CountryMapChartPlugin from "@superset-ui/legacy-plugin-chart-country-map";
// Register the plugin with Superset
const plugin = new CountryMapChartPlugin();
// Access country mappings for configuration
import { countries } from "@superset-ui/legacy-plugin-chart-country-map";
console.log(countries.usa); // Returns USA GeoJSON data path
// For country options, you need to import directly from countries module
// or access via separate import since it's not re-exported from main indexThe plugin follows Superset's chart plugin architecture:
CountryMapChartPlugin that extends Superset's ChartPlugin base classCountryMap) wrapped in React (ReactCountryMap)transformProps function that converts Superset data format to chart propsMain plugin class for registering the country map visualization with Superset.
/**
* Main chart plugin class for country map visualization
* Extends ChartPlugin from @superset-ui/core
*/
class CountryMapChartPlugin extends ChartPlugin {
constructor();
}
export default CountryMapChartPlugin;Access to country mappings and configuration options for building country selection interfaces.
/**
* Country mappings object - contains imported GeoJSON data for each supported country
* This is the countries object from countries.ts, re-exported as named export
*/
export const countries: Record<string, any>;For advanced usage, the countries module also exports additional utilities that are not re-exported from the main index:
/**
* Array of [value, label] pairs for UI select controls
* Available as named export from '@superset-ui/legacy-plugin-chart-country-map/lib/countries'
* Generated from country keys with proper capitalization
*/
export const countryOptions: Array<[string, string]>;The core chart component props interface (used internally by the plugin). Note: The actual implementation uses JavaScript with PropTypes validation, not TypeScript.
/**
* Props interface for the CountryMap component (based on PropTypes)
*/
interface CountryMapProps {
/** Visualization data with country IDs and metrics */
data: Array<{
country_id: string;
metric: number;
}>;
/** Chart width in pixels */
width: number;
/** Chart height in pixels */
height: number;
/** Country identifier for map selection */
country: string;
/** Color scheme identifier for linear scaling */
linearColorScheme: string;
/** Number formatting specification */
numberFormat: string;
/** Base URL for map data (optional) */
mapBaseUrl?: string;
}Transform function that converts Superset chart properties to component props.
/**
* Transforms Superset chart properties to CountryMap component props
* @param chartProps - Raw chart properties from Superset
* @returns Transformed props for CountryMap component
*/
function transformProps(chartProps: ChartPropsConfig): CountryMapProps;
interface ChartPropsConfig {
width: number;
height: number;
formData: {
linearColorScheme: string;
numberFormat: string;
selectCountry: string;
colorScheme?: string;
sliceId?: string;
};
queriesData: Array<{
data: Array<{
country_id: string;
metric: number;
}>;
}>;
}Control panel configuration for chart customization in Superset UI.
/**
* Control panel configuration object for Superset UI
*/
interface ControlPanelConfig {
controlPanelSections: Array<ControlSection>;
controlOverrides: Record<string, ControlOverride>;
}
interface ControlSection {
label: string;
expanded: boolean;
controlSetRows: Array<Array<string | ControlConfig>>;
tabOverride?: string;
}
interface ControlConfig {
name: string;
config: {
type: string;
label: string;
default?: any;
choices?: Array<[string, string]>;
description: string;
validators?: Array<Function>;
renderTrigger?: boolean;
freeForm?: boolean;
};
}
const controlPanel: ControlPanelConfig;
// Note: controlPanel is used internally by the plugin but not exported from main indexThe plugin includes GeoJSON data for 62+ countries and regions:
The plugin registers with the following metadata:
useLegacyApi: true)Input data should be formatted as an array of objects with:
interface ChartDataPoint {
/** ISO 3166-2 code for the region/subdivision */
country_id: string;
/** Numeric value to visualize */
metric: number;
}d3@^3.5.17 - D3.js library for data visualizationd3-array@^2.0.3 - D3 array utilities for data processingprop-types@^15.6.2 - React prop types validation@superset-ui/chart-controls@* - Superset chart control components@superset-ui/core@* - Superset core utilities and base classes