or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

index.md
tile.json

tessl/npm-superset-ui--legacy-plugin-chart-event-flow

Apache Superset Event Flow chart plugin that visualizes and compares event durations in a shared timeline view.

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/@superset-ui/legacy-plugin-chart-event-flow@0.18.x

To install, run

npx @tessl/cli install tessl/npm-superset-ui--legacy-plugin-chart-event-flow@0.18.0

index.mddocs/

Superset UI Legacy Plugin Chart Event Flow

The @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.

Package Information

  • Package Name: @superset-ui/legacy-plugin-chart-event-flow
  • Package Type: npm
  • Language: TypeScript
  • Installation: npm install @superset-ui/legacy-plugin-chart-event-flow

Dependencies

  • @data-ui/event-flow: "^0.0.84" - Core event flow visualization library
  • prop-types: "^15.6.2" - Runtime type checking

Peer Dependencies

  • react: "^15 || ^16" - React framework
  • @superset-ui/chart-controls: "*" - Superset chart control components
  • @superset-ui/core: "*" - Core Superset functionality

Core Imports

import EventFlowChartPlugin from "@superset-ui/legacy-plugin-chart-event-flow";

For CommonJS:

const EventFlowChartPlugin = require("@superset-ui/legacy-plugin-chart-event-flow");

Basic Usage

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
    ],
  }]}
/>

Architecture

The plugin follows Superset's ChartPlugin architecture with several key components:

  • ChartPlugin Class: Main plugin class that extends Superset's ChartPlugin base class
  • Chart Component: React component (EventFlow) that renders the actual visualization using @data-ui/event-flow
  • Transform Props: Data transformation function that converts Superset's format to the chart component's expected format
  • Control Panel: Configuration UI that defines the form controls for chart settings
  • Lazy Loading: Chart component and transform function are loaded on-demand for performance

Capabilities

Chart Plugin Registration

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 component
  • loadTransformProps: Lazy-loaded data transformation function
  • metadata: Chart metadata including name, description, and settings
  • controlPanel: Form control configuration

Event Flow Component

React 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;

Data Transformation

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;
};

Control Panel Configuration

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:

  • Legacy Regular Time: Standard time-based controls
  • Event Definition: Entity ID and event name column selection
  • Query: Filter controls including adhoc filters and row limits
  • Additional Metadata: Optional metadata column selection

Key form controls:

  • entity: Entity ID column (e.g., user ID)
  • all_columns_x: Event name column selection
  • min_leaf_node_event_count: Minimum leaf node event count (1-10)
  • order_by_entity: Checkbox to ensure proper entity ordering
  • row_limit: Maximum number of events to return
  • all_columns: Multi-select for additional metadata columns

Types

/**
 * 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;
}

Exported Interfaces

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[];
  }[];
}

Error Handling

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.