Computations

Gladly provides two types of computations for transforming data:

  1. Computed attributes — transform a single column into a new column of the same length
  2. Transforms — transform an entire dataset into a new dataset (possibly with different length and columns)

Computed Attributes

A computed attribute transforms a single column into a new column with the same length but different values. It runs on the GPU and can be used wherever an expression is accepted in layer parameters.

Use case: Applying a mathematical function to every value in a column, e.g., computing a histogram, smoothing with a kernel, normalizing, etc.

Usage

{ points: { xData: { histogram: { input: "raw_data", bins: 50 } } } }

Available Computed Attributes

histogram

Computes a histogram texture from input data.

Parameter Type Required Description
input expression yes Input data column
bins number no Number of bins (default: auto)

filteredHistogram

Computes a histogram that automatically updates when a filter axis changes. Used internally by the histogram layer.

Parameter Type Required Description
input expression yes Input data column (normalized to [0,1])
filterValues expression yes Raw filter column values
filterAxisId string yes Quantity kind of the filter axis
bins number no Number of bins

kde

Kernel density estimation — smooths a histogram into a continuous density estimate.

Parameter Type Required Description
input expression yes Input data column
bins number no Number of output bins
bandwidth number no Gaussian sigma in bins (default: 5)

filter1D

Generic 1D convolution filter.

Parameter Type Required Description
input expression yes Input data column
kernel expression yes 1D kernel weights

lowPass

Low-pass filter (Gaussian smoothing).

Parameter Type Required Description
input expression yes Input data column
sigma number no Gaussian sigma (default: 3)
kernelSize number no Kernel size (auto if omitted)

highPass

High-pass filter (original minus low-pass).

Parameter Type Required Description
input expression yes Input data column
sigma number no Gaussian sigma (default: 3)
kernelSize number no Kernel size (auto if omitted)

bandPass

Band-pass filter (difference of two low-pass filters).

Parameter Type Required Description
input expression yes Input data column
sigmaLow number yes Lower frequency cutoff (sigma)
sigmaHigh number yes Upper frequency cutoff (sigma)

convolution

Adaptive convolution with automatic kernel sizing based on data.

Parameter Type Required Description
signal expression yes Input signal column
kernel expression yes Convolution kernel column

fftConvolution

FFT-based convolution for large signals.

Parameter Type Required Description
signal expression yes Input signal column
kernel expression yes Convolution kernel column

linspace

Generates length evenly-spaced values on the GPU. Output values are (i + 0.5) / length for i in [0, length) — i.e. bin centres uniformly covering ]0, 1[. Useful as a normalised x-axis for histogram or KDE output.

Parameter Type Required Description
length integer yes Number of values to generate

range

Generates length consecutive integer values on the GPU: 0, 1, 2, …, length-1. Useful as a point index column for instanced rendering.

Parameter Type Required Description
length integer yes Number of values to generate

random

Generates length pseudorandom values on the GPU. Output values are in ]0, 1[. Uses a deterministic hash keyed by index and seed, so the same seed always produces the same sequence.

Parameter Type Required Description
length integer yes Number of values to generate
seed integer no Integer seed for reproducibility (default: random each run)

glslExpr

Composes a new column as a GLSL expression over one or more named input columns. The expression runs in the vertex shader — no extra GPU pass is needed.

Parameter Type Required Description
expr string yes GLSL expression; reference named inputs as {name} placeholders
inputs object no Map of placeholder names to input column expressions
// Compute the vector magnitude from two columns
{
  points: {
    xData: "time",
    yData: { glslExpr: { expr: "sqrt({vx}*{vx} + {vy}*{vy})", inputs: { vx: "vel_x", vy: "vel_y" } } }
  }
}

Transforms

A transform transforms an entire dataset into a new dataset. The output can have a different length and different columns than the input. Transforms are specified in config.transforms and produce new data columns accessible via data.transformName.columnName.

Use case: Computing aggregations (histograms, FFTs), creating derived datasets, pre-processing before visualization.

How Transforms Differ from Computed Attributes

Aspect Computed Attribute Transform
Output Single column, same length as input Entire dataset, possibly different length and columns
Specification Inline in layer parameters In config.transforms array
Access Used directly in layer params Access via data.transformName.columnName
Example vData: { histogram: { input: "x", bins: 50 } } transforms: [{ name: "hist", transform: { HistogramData: {...} } }]

A transform can consist of multiple computed attributes if the transform type is elementwise — see ElementwiseData below.

Usage

config: {
  transforms: [
    {
      name: "histogram",
      transform: {
        HistogramData: {
          input: "temperature",
          bins: 50,
          filter: "depth"
        }
      }
    }
  ]
}

Then access via data.histogram.binCenters and data.histogram.counts.

Available Transforms

HistogramData

Computes a histogram with bin centers and counts. Supports reactive filtering.

Parameter Type Required Description
input string yes Input data column name
bins integer no Number of bins (0 for auto)
filter expression no Filter column — registers a filter axis

Output columns:


FftData

Computes Fast Fourier Transform with real and imaginary outputs.

Parameter Type Required Description
input string yes Input signal column name
inverse boolean no Perform inverse FFT (default: false)

Output columns:


ElementwiseData

Performs element-wise operations on multiple columns. A transform that consists of multiple computed attributes — each output column is computed independently from input columns using the same length.

Parameter Type Required Description
dataLength integer no Override output length (auto-detected)
columns array yes Array of column mappings

Each column mapping has: | Property | Type | Description | |———-|——|————-| | dst | string | Output column name | | src | computed attribute expression | Input expression — see computed attributes above |

Output columns:


Expression Syntax

Expressions can be:

  1. Plain column name (string):
    xData: "temperature"
    
  2. Computed attribute (object with single key):
    xData: { histogram: { input: "raw", bins: 50 } }
    
  3. Computed data (transform output):
    xData: "histogram.binCenters"  // after transform named "histogram"
    
  4. Transform specification (object in config.transforms):
    config: {
      transforms: [
        { name: "myHist", transform: { HistogramData: { input: "data", bins: 20 } } }
      ]
    }
    // Results in data.myHist.binCenters and data.myHist.counts
    

For writing custom computations see Computations.