Apache Superset Event Flow chart plugin that visualizes and compares event durations in a shared timeline view.
npx @tessl/cli install tessl/npm-superset-ui--legacy-plugin-chart-event-flow@0.18.0The @superset-ui/legacy-plugin-chart-event-flow package provides an Event Flow chart plugin for Apache Superset. It visualizes and compares the lengths of time different activities take in a shared timeline view, enabling users to understand temporal relationships and duration patterns across multiple events or processes.
npm install @superset-ui/legacy-plugin-chart-event-flowimport EventFlowChartPlugin from "@superset-ui/legacy-plugin-chart-event-flow";For CommonJS:
const EventFlowChartPlugin = require("@superset-ui/legacy-plugin-chart-event-flow");import EventFlowChartPlugin from "@superset-ui/legacy-plugin-chart-event-flow";
// Register the plugin with Superset
new EventFlowChartPlugin().configure({ key: "event-flow" }).register();Then use it via SuperChart:
import { SuperChart } from "@superset-ui/core";
<SuperChart
chartType="event-flow"
width={600}
height={600}
formData={{
// Required properties
allColumnsX: "event_name",
entity: "user_id",
minLeafNodeEventCount: 1,
// Optional properties (available through control panel)
orderByEntity: true,
rowLimit: 1000,
adhocFilters: [],
allColumns: ["metadata_field"],
}}
queriesData={[{
data: [
{ user_id: "123", event_name: "login", __timestamp: 1640995200000 },
{ user_id: "123", event_name: "click", __timestamp: 1640995260000 },
// ... more event data
],
}]}
/>The plugin follows Superset's ChartPlugin architecture with several key components:
Main plugin class for registering the Event Flow chart with Superset.
/**
* Event Flow Chart Plugin for Apache Superset
* Extends ChartPlugin to provide Event Flow visualization capabilities
*/
export default class EventFlowChartPlugin extends ChartPlugin {
constructor();
}The plugin is configured with:
loadChart: Lazy-loaded EventFlow componentloadTransformProps: Lazy-loaded data transformation functionmetadata: Chart metadata including name, description, and settingscontrolPanel: Form control configurationReact component that renders the Event Flow visualization.
/**
* Props interface for the EventFlow component
*/
interface EventFlowProps {
/** Chart data as an array of time series records */
data: TimeseriesDataRecord[];
/** Chart height in pixels */
height: number;
/** Chart width in pixels */
width: number;
/** Initial minimum event count filter for leaf nodes */
initialMinEventCount: number;
}
/**
* Event Flow chart component that renders timeline visualization
* @param data - Chart data as an array of time series records
* @param initialMinEventCount - Initial minimum event count filter for leaf nodes
* @param height - Chart height in pixels (default: 400)
* @param width - Chart width in pixels (default: 400)
* @returns React component rendering the event flow chart
*/
export default function EventFlow({
data,
initialMinEventCount,
height = 400,
width = 400,
}: EventFlowProps): JSX.Element;Function that transforms Superset chart properties into EventFlow component props.
/**
* Form data interface for Event Flow chart configuration
* Core properties used by transformProps: allColumnsX, entity, minLeafNodeEventCount
* Additional properties available through Superset's control panel
*/
interface EventFlowFormData {
/** Column name for event names (required) */
allColumnsX: string;
/** Column name for entity identifier (e.g., user ID) (required) */
entity: string;
/** Minimum event count for leaf nodes to be initially visible (required) */
minLeafNodeEventCount: number;
/** Whether to order results by entity ID (optional, available in control panel) */
orderByEntity?: boolean;
/** Maximum number of events to return (optional, standard Superset control) */
rowLimit?: number;
/** Adhoc filter configurations (optional, standard Superset control) */
adhocFilters?: any[];
/** Additional metadata columns (optional, available in control panel) */
allColumns?: string[];
}
/**
* Extended chart props interface including Event Flow specific form data
*/
interface EventFlowChartProps extends ChartProps {
formData: EventFlowFormData;
queriesData: {
data: TimeseriesDataRecord[];
}[];
}
/**
* Transforms Superset chart properties into EventFlow component props
* @param chartProps - Superset chart properties including form data and query results
* @returns Props object for EventFlow component or null data object if no data
*/
export default function transformProps(chartProps: ChartProps): {
data: TimeseriesDataRecord[] | null;
height: number;
width: number;
initialMinEventCount?: number;
};Configuration object that defines the form controls available in Superset's chart configuration UI.
/**
* Control panel configuration for Event Flow chart
* Defines the form controls and sections available in Superset's chart builder
*/
declare const controlPanel: ControlPanelConfig;The control panel includes sections for:
Key form controls:
entity: Entity ID column (e.g., user ID)all_columns_x: Event name column selectionmin_leaf_node_event_count: Minimum leaf node event count (1-10)order_by_entity: Checkbox to ensure proper entity orderingrow_limit: Maximum number of events to returnall_columns: Multi-select for additional metadata columns/**
* Time series data record structure expected by the chart
*/
interface TimeseriesDataRecord {
/** Timestamp of the event (required for temporal positioning) */
__timestamp: number;
/** Additional data fields as key-value pairs */
[key: string]: any;
}
/**
* Chart metadata configuration
*/
interface ChartMetadata {
category: string;
credits: string[];
description: string;
name: string;
tags: string[];
thumbnail: string;
useLegacyApi: boolean;
}
/**
* Superset chart properties base interface
*/
interface ChartProps {
formData: any;
queriesData: any[];
width: number;
height: number;
}
/**
* Control panel configuration structure
*/
interface ControlPanelConfig {
controlPanelSections: any[];
controlOverrides: any;
}The package exports the following TypeScript interfaces for advanced usage:
/**
* Props interface for the EventFlow component
*/
export interface EventFlowProps {
data: TimeseriesDataRecord[];
height: number;
width: number;
initialMinEventCount: number;
}
/**
* Form data interface for Event Flow chart configuration
* Core properties used by transformProps: allColumnsX, entity, minLeafNodeEventCount
* Additional properties available through Superset's control panel
*/
export interface EventFlowFormData {
allColumnsX: string;
entity: string;
minLeafNodeEventCount: number;
orderByEntity?: boolean;
rowLimit?: number;
adhocFilters?: any[];
allColumns?: string[];
}
/**
* Extended chart props interface including Event Flow specific form data
*/
export interface EventFlowChartProps extends ChartProps {
formData: EventFlowFormData;
queriesData: {
data: TimeseriesDataRecord[];
}[];
}The EventFlow component handles cases where no data is available by displaying a "Sorry, there appears to be no data" message. The transformProps function returns a null data object when no valid data is present, which the component handles gracefully.
For malformed data, the @data-ui/event-flow library's cleanEvents function is used to sanitize and validate the data structure before rendering.