CtrlK
CommunityDocumentationLog inGet started
Tessl Logo

tessl/npm-lightdash--common

tessl install tessl/npm-lightdash--common@0.2231.5

Shared TypeScript library for the Lightdash platform containing common types, utilities, and business logic for analytics workflows

Agent Success

Agent success rate when using this tile

72%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.09x

Baseline

Agent success rate without this tile

66%

task.mdevals/scenario-19/

Dual Y-Axis Chart Configuration System

A system for configuring charts with dual y-axes where different series can be independently assigned to either the left or right y-axis.

Capabilities

Configure dual y-axis display

  • Creates a CartesianChartDisplay configuration with two y-axes @test
  • Assigns series to left y-axis (AxisSide.LEFT) @test
  • Assigns series to right y-axis (AxisSide.RIGHT) @test
  • Sets independent formatting for each y-axis @test

Generate ECharts specification with dual axes

  • Generates ECharts spec with yAxis array containing two axis configurations @test
  • Maps series to correct y-axis using yAxisIndex property @test
  • Applies different chart types (line, bar) to different axes @test

Filter series by axis assignment

  • Identifies series assigned to left y-axis @test
  • Identifies series assigned to right y-axis @test
  • Handles default axis assignment when whichYAxis is undefined @test

Implementation

@generates

API

import { CartesianChartDisplay, AxisSide } from '@lightdash/common';

/**
 * Creates a CartesianChartDisplay configuration with dual y-axes.
 *
 * @param leftAxisLabel - Label for the left y-axis
 * @param rightAxisLabel - Label for the right y-axis
 * @param seriesConfig - Object mapping series IDs to their display configuration
 * @returns CartesianChartDisplay configuration object
 */
export function createDualAxisDisplay(
  leftAxisLabel: string,
  rightAxisLabel: string,
  seriesConfig: Record<string, {
    label: string;
    whichYAxis: AxisSide;
    type?: 'line' | 'bar';
    color?: string;
  }>
): CartesianChartDisplay;

/**
 * Generates a simplified ECharts specification from a CartesianChartDisplay config.
 * Should create an object with yAxis array and series array with yAxisIndex.
 *
 * @param display - CartesianChartDisplay configuration
 * @param seriesIds - Array of series IDs to include in the spec
 * @returns Simplified ECharts spec with yAxis and series arrays
 */
export function generateEChartsSpec(
  display: CartesianChartDisplay,
  seriesIds: string[]
): {
  yAxis: Array<{ position: string; name: string }>;
  series: Array<{ id: string; yAxisIndex: number; type: string }>;
};

/**
 * Filters series IDs by their assigned y-axis.
 * Series without whichYAxis property default to left axis (AxisSide.LEFT).
 *
 * @param display - CartesianChartDisplay configuration
 * @param seriesIds - Array of series IDs to filter
 * @param targetAxis - The axis to filter by (AxisSide.LEFT or AxisSide.RIGHT)
 * @returns Array of series IDs assigned to the target axis
 */
export function filterSeriesByAxis(
  display: CartesianChartDisplay,
  seriesIds: string[],
  targetAxis: AxisSide
): string[];

Dependencies { .dependencies }

@lightdash/common { .dependency }

Provides types and utilities for BI chart configuration including CartesianChartDisplay and AxisSide enum.

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/@lightdash/common@0.2231.x
tile.json