A comprehensive word cloud chart plugin for Apache Superset that creates interactive visualizations from text frequency data
—
Configuration system for integrating the encodable library with Superset's color schemes, formatters, and scales to enable seamless visual encoding in word cloud visualizations.
Main configuration function that sets up encodable library integration with Superset's theming and formatting systems.
/**
* Configures the encodable library with Superset-specific resolvers
* Sets up number formatting, time formatting, color schemes, and color scales
* Must be called before using encodable features in the word cloud
*/
function configureEncodable(): void;Usage:
import { configureEncodable } from '@superset-ui/plugin-chart-word-cloud';
// Configure encodable (typically done once during plugin initialization)
configureEncodable();
// Now encodable features work with Superset's theming systemThis function is automatically called during plugin initialization, so manual invocation is typically not required.
The configuration sets up four key resolvers that bridge encodable with Superset's systems:
Integrates Superset's number formatting system with encodable.
/**
* Number format resolver using Superset's formatting system
* Enables consistent number formatting across charts
*/
type NumberFormatResolver = (format?: string) => (value: number) => string;Features:
getNumberFormatter from @superset-ui/coreIntegrates Superset's time formatting with support for local/UTC time zones.
/**
* Time format resolver with local time support
* @param options - Formatting options
* @param options.format - Time format string (optional)
* @param options.formatInLocalTime - Whether to format in local time (default: false)
* @returns Configured time formatter function
*/
type TimeFormatResolver = (options?: {
format?: string;
formatInLocalTime?: boolean;
}) => (value: Date | number) => string;Features:
LOCAL_PREFIX)Usage Example:
// UTC time formatting (default)
const utcFormatter = timeFormat({ format: '%Y-%m-%d' });
// Local time formatting
const localFormatter = timeFormat({
format: '%Y-%m-%d %H:%M',
formatInLocalTime: true
});Integrates Superset's color scheme registries for both categorical and sequential color schemes.
/**
* Color scheme resolver supporting categorical and sequential schemes
* @param options - Color scheme options
* @param options.name - Scheme name (optional)
* @param options.type - Scheme type: 'categorical' or 'sequential' (default: 'categorical')
* @returns Color scheme configuration or undefined if not found
*/
type ColorSchemeResolver = (options?: {
name?: string;
type?: 'categorical' | 'sequential';
}) => ColorScheme | undefined;
interface ColorScheme {
type: 'categorical' | 'sequential';
// Additional scheme properties from Superset registries
}Supported Schemes:
getCategoricalSchemeRegistry() from Superset
getSequentialSchemeRegistry() from Superset
Usage Example:
// Get categorical color scheme
const categorical = colorSchemeResolver({
name: 'category10',
type: 'categorical'
});
// Get sequential color scheme
const sequential = colorSchemeResolver({
name: 'viridis',
type: 'sequential'
});Integrates Superset's categorical color namespace system for consistent color assignment.
/**
* Categorical color scale resolver using Superset's color namespace
* Ensures consistent colors across charts and dashboards
* @param options - Color scale options
* @param options.name - Color scheme name (optional)
* @param options.namespace - Color namespace for consistency (optional)
* @returns Categorical color scale function
*/
type CategoricalColorScaleResolver = (options?: {
name?: string;
namespace?: string;
}) => CategoricalColorScale;
type CategoricalColorScale = (value: string, sliceId?: number) => string;Features:
CategoricalColorNamespace.getScale()Usage Example:
// Get color scale with namespace
const colorScale = colorScaleResolver({
name: 'superset_colors',
namespace: 'dashboard_colors'
});
// Use color scale
const color1 = colorScale('category_a', 123); // Returns consistent color
const color2 = colorScale('category_b', 123); // Returns different consistent colorThe configuration is applied to the global Encodable instance:
Encodable
.setNumberFormatResolver(getNumberFormatter)
.setTimeFormatResolver(timeFormat)
.setColorSchemeResolver(colorSchemeResolver)
.setCategoricalColorScaleResolver(colorScaleResolver);The configuration integrates with these Superset core systems:
// Number formatting
import { getNumberFormatter } from '@superset-ui/core';
// Time formatting
import {
getTimeFormatter,
getTimeFormatterRegistry,
LOCAL_PREFIX
} from '@superset-ui/core';
// Color schemes
import {
getCategoricalSchemeRegistry,
getSequentialSchemeRegistry
} from '@superset-ui/core';
// Color namespace
import { CategoricalColorNamespace } from '@superset-ui/core';import {
Encodable,
ColorSchemeResolver,
TimeFormatResolver,
CategoricalColorScaleResolver,
defaultColorSchemeResolver,
addPrefix
} from 'encodable';configureEncodable() is called during plugin constructionThis configuration ensures that word cloud visualizations integrate seamlessly with Superset's visual design system and maintain consistency with other chart types in dashboards.
Install with Tessl CLI
npx tessl i tessl/npm-superset-ui--plugin-chart-word-cloud