Skip to content

@sqlrooms/mosaic / generateMosaicChartSpec

Function: generateMosaicChartSpec()

generateMosaicChartSpec(tableName, chartType, settings): Spec

Generates a Mosaic chart specification from chart settings.

Parameters

ParameterTypeDescription
tableNamestring | undefinedThe source table name
chartType"heatmap" | "histogram" | "count-plot" | "line-chart" | "bubble-chart" | "box-plot" | "custom-spec"The type of chart to generate (histogram, line, etc.)
settingsRecord<string, unknown> | { field?: string; } | { field?: string; } | { x?: string; xInterval?: "second" | "minute" | "hour" | "day" | "week" | "month" | "quarter" | "year"; yFields?: object[]; } | { x?: string; y?: string; size?: string; } | { x?: string; y?: string; } | { x?: string; y?: string; } | { vgPlotSpec?: unknown; }Chart-specific settings matching the chart type

Returns

Spec

A Mosaic Spec object

Throws

If tableName is undefined

Throws

If chartType is not recognized

Throws

If spec creation fails (wraps original error from createSpec)

Example

ts
const spec = generateMosaicChartSpec('sales', 'histogram', { field: 'amount' });