Custom Graph Reference

A complete list of the Geometry and Stat types available in Custom Graph. Click the help button (?) in the layer settings for details on each item.

Geometry

GeometryDescription
Point (Scatter)Displays data as individual points.
LineConnects data points with lines. Draws an interval band automatically when ymin/ymax are present.
BarVertical bars for categorical data. Use Fill (not Color) to change bar color.
AreaFilled area under line.
Tile (Heatmap)Grid of colored cells. Use Fill to set cell colors.
Step (Kaplan-Meier)Stair-step line pattern. Used for Kaplan-Meier curves and ECDF.
Ribbon (Confidence Band)Shaded area between ymin and ymax (confidence bands).
Error BarError bars showing ymin to ymax range with caps.
CrossbarRectangle spanning ymin to ymax with a line at y. Combine with the Summary stat to draw an interval around a center value (e.g. mean and mean±SE).
Box PlotBox-and-whisker plot per group: box from Q1 to Q3, median line, whiskers, and individual points beyond the whiskers. Use with the Boxplot stat.
Vertical Line (Reference)Fixed vertical reference line.
Horizontal Line (Reference)Fixed horizontal reference line.
Sloped Line (Reference)Straight reference line y = intercept + slope × x, drawn where it crosses the plot area. The default is y = x. The line does not widen the axis ranges, so it is not visible when it misses the plot area. It ignores column mappings, the layer filter, and the stat. Not drawn when either axis is categorical. On a log or sqrt axis the line can appear curved. When the x or y axis is a date or datetime axis, the values on that axis are milliseconds since 1970-01-01T00:00:00Z.
Density 2D2D kernel density estimation as contour lines. For 1D density curves, use the Density (KDE) stat.
Text (Label)Displays text labels at data points. Requires a column mapped to the Label aesthetic or a Label Content field.
Label (Annotation)Displays text boxes with leader lines at data points.

Geometry–aesthetic compatibility

Each geometry accepts a specific set of aesthetics — visual attributes such as position, color, and size. Mapping an unsupported aesthetic to a geometry has no effect.

Geometryxycolorfillstrokesizeshapealphalinetypeyminymaxlabel
pointRR•••••
lineRR••••○○
barRR••
areaRR•••
tileRR••
stepRR••••
ribbonR•••RR
errorbarR••RR
crossbarRR•••RR
boxplotRR•••••RR
vline••
hline••
abline
density2dRR•
textRR••••
labelRR•••

R = required, ○ = optional (triggers additional behavior when present), • = supported.

  • Required aesthetics must be mapped to a column or provided by a stat.
  • color vs fill: Bar and Tile use fill for their interior color, not color. Area accepts both — color for the outline and fill for the interior. Ribbon draws no outline; it takes its fill color from fill when a column is mapped to fill, and from color otherwise. Crossbar and Box Plot use fill for the rectangle interior and color for the lines (for Box Plot: box outline, whiskers, median line, and the points beyond the whiskers).
  • stroke: Only Point supports stroke, which sets a separate outline color.
  • shape on Box Plot splits the boxes by the mapped column's levels (like color and fill) and draws the points beyond the whiskers with distinct marker shapes. size applies only to the points beyond the whiskers.
  • ymin / ymax: Line draws an interval band when both are present. Ribbon, Errorbar, Crossbar, and Box Plot require them.
  • q1 / q3: Box Plot needs quartiles for the top and bottom edges of the box. They cannot be mapped to a column, so the table lists no column for them, and only the Boxplot stat supplies them.
  • label: Text and Label need either aes.label or geom.defaults.labelContent.
  • group: This aesthetic has no column in the table because it does not change colors, shapes, or line types. Text accepts group.
  • weight: This aesthetic has no column in the table because it does not affect how any Geometry is drawn. It maps a numeric column of frequency weights (how many observations each row stands for), and only stats that support weights (ROC Curve) read it. The $n tooltip variable counts the rows used in the calculation and does not sum the weights.

Geometry–position compatibility

Each Geometry accepts a different set of position adjustments. See Position for what each position type means. Specifying a position type not listed below in tabs.addGraphLayer / tabs.updateGraphLayer returns an INVALID_INPUT error. When position is omitted, bar geom defaults to stack and other geoms default to identity.

GeometryAllowed positions
pointidentity, dodge, jitter
lineidentity
baridentity, stack, dodge, fill
areaidentity, stack, fill
tileidentity
stepidentity
ribbonidentity
errorbaridentity, dodge, jitter
crossbaridentity, dodge
boxplotidentity, dodge
vlineidentity
hlineidentity
ablineidentity
density2didentity
textidentity, dodge, stack, fill
labelidentity

MIDAS validates the position against the stats as well as the geom. The stats listed in the following table can be combined only with the listed positions. Stats not in the table accept every position.

StatAllowed positions
Boxplot (Quartiles + Whiskers)identity, dodge, jitter
QQ (Normal Q-Q Plot)identity, jitter

A layer whose Y is mapped to a column with a nominal or ordinal scale cannot use stack or fill, even when the tables above list them.

Groups

MIDAS splits the points into groups, and stats, positions, and Geometries all process the points group by group. A group is the set of points that share the same values in all the columns mapped to grouping aesthetics. A grouping aesthetic is an aesthetic whose scale is categorical. stroke, shape, linetype, and group are always grouping aesthetics, and color and fill are grouping aesthetics only when the scale MIDAS uses for drawing is categorical. The Agent API reference describes the scale MIDAS uses when scaleType is omitted and when sequential or diverging is specified for a column that is not numeric. A column mapped to a grouping aesthetic that the Geometry does not use for drawing also determines the groups.

Because the points are processed group by group, Line, Step, Area, and Ribbon draw a line or an area for each group. For example, a Line whose color is mapped to a column with three values draws three lines. The Stack, Dodge, and Fill positions stack and place side by side the groups as series.

Geometry and continuous color scales

The identity, sort, transform, cumsum, and qq stats output one point for each input point, so each point gets its color from its own value. Line, Area, Step, and Ribbon color each group with a gradient that varies along the X axis. In a flipped coordinate system it varies along the Y axis. Each data point places a gradient stop at its own position with the color resolved from that point's value, and the color is interpolated between points.

Stats that aggregate points, such as Bin, Density, and Smooth, compute without distinguishing the values of a color or fill with a continuous color scale. To compute each value as a separate group, set that aesthetic's scaleType to categorical.

Bar draws one rectangle per point, so it stacks even with a continuous color scale.

Stat

StatDescription
Identity (No transformation)Passes data through without transformation.
Bin (Histogram)Groups numeric data into bins and counts occurrences.
Time Bin (Datetime Histogram)Groups datetime data into time intervals.
Smooth (Regression)Fits a smoothing curve with linear regression or LOESS. Optionally computes ymin/ymax as either a prediction interval for a new individual observation or a confidence interval for the mean response; Line geom draws the band automatically, Ribbon geom can also be used.
Count (Aggregation)Counts occurrences for each X value.
Density (KDE)Estimates probability density using kernel density estimation.
Summary (Aggregation)Aggregates the values of the aesthetic selected as Input (input, Y by default) with the aggregate function of each output, for each combination of the values of X, of the grouping aesthetics, and of Y when Y is neither the Input nor an output target.
Boxplot (Quartiles + Whiskers)Computes the median, quartiles (linear interpolation), whisker ends (most extreme data values within coef × IQR of the quartiles), and the individual data values beyond the whiskers for each combination of X and the group. Use with the Box Plot geometry.
Survival (Kaplan-Meier)Computes Kaplan-Meier survival estimates. Map the time to X (values of 0 or more) and the event indicator to Y (1 = event, 0 = censored).
ROC CurveComputes ROC curve points (false positive rate vs true positive rate) from binary labels and scores. Ties in the score are merged into one threshold, so the area under the curve matches the AUC computed with ties counted as one half. Map the score to X and the label to Y — 0/1 values, or proportions of positives in [0, 1] for aggregated data. Optionally map a frequency weight (e.g., the number of trials behind each proportion) to Weight.
X MeanCalculates the mean of X values. Use with vline geom to draw a vertical reference line.
X MedianCalculates the median of X values. Use with vline geom to draw a vertical reference line.
Y MeanCalculates the mean of Y values. Use with hline geom to draw a horizontal reference line.
Cumulative Sum (Pareto)Computes cumulative sum of Y values. Combine with Sort and Bar + Line to create Pareto charts.
Sort (Pareto)Sorts categories by the sum of their Y values, in descending or ascending order. Combine with Cumulative Sum to create Pareto charts.
ECDF (Empirical CDF)Computes empirical cumulative distribution function.
QQ (Normal Q-Q Plot)Computes quantiles for a normal Q-Q plot, using Hazen plotting positions ((i - 0.5) / n for the i-th smallest value, i = 1, ..., n) for the theoretical quantiles.
Transform (Linear)Applies linear transformation (multiply and add) to Y values.
Cook's Distance ContourComputes one side of the Cook's distance contour r = ±√(D·p·(1 − h)/h) for a plot of standardized residuals r (y) against leverage h (x). Each residual must be divided by s·√(1 − h), where h is the leverage of its own observation and s is the scale in the definition of the Cook's distance, estimated from all observations (an internally studentized residual, such as the standardized residuals of the regression diagnostics). An observation on the curve then has Cook's distance D = r²·h / (p·(1 − h)); externally studentized residuals do not satisfy this relation. The curve spans leverage from 0.001 to 0.5, widened to the smallest and largest x values strictly between 0 and 1. With a grouping aesthetic, each group gets its own curve, whose range is widened by the x values of that group only. The curve does not widen the axis ranges set by the other layers. Use with the line geom, one layer for each side.

Stat parameters

Each stat accepts a params object in the stats array passed to tabs.addGraphLayer / tabs.updateGraphLayer. The tables below list the parameter name, TypeScript type, default value, and a short description for every stat.

await window.midas.tabs.addGraphLayer('tab_001', {
  geom: { type: 'point' },
  stats: [
    { type: 'smooth', params: { method: 'loess', span: 0.5, interval: 'confidence' } }
  ],
  aes: { x: 'weight', y: 'mpg' }
});

In the type column: A | B means either value is accepted, T[] means an array of T, and a trailing ? on a field name (e.g. p?) marks it as optional. For the full behavior of each stat — assumptions, limits, and worked examples — see Custom Graph.

Identity (No transformation)

No parameters.

Bin (Histogram)

NameTypeDefaultDescription
binsnumber30Number of bins (1-100). Ignored when binwidth is specified. When integerBins applies, determines the bin width instead, so the number of bins can differ. With facets, the bin width and edges are determined from the values of all panels that share the x axis, so a panel whose values cover a narrower range shows fewer bins.
binwidthnumber—Width of each bin in X-axis units (milliseconds for a date or datetime x). Takes precedence over bins.
yScale'count' | 'density' | 'proportion''count'Y-axis scale: 'count' reports bin counts; 'density' reports probability density (bin counts divided by the number of binned observations × binwidth, so the area over equal-width bins equals 1); 'proportion' reports each bin's share of its own group, so the values of every group sum to 1. With a categorical aesthetic such as fill, both 'density' and 'proportion' use a per-group denominator, so each group reaches an area of 1 (density) or a total of 1 (proportion) on its own; stacking groups whose denominators differ produces a total with no interpretation. Both denominators count the observations that were binned, which excludes missing values of the binned column.
boundarynumber—Position of a bin edge in X-axis units (milliseconds since 1970-01-01T00:00:00Z for a date or datetime x). Bins are aligned so that one edge falls on this value. When boundary and center are omitted, the first bin starts at the minimum of the binned values; with facets, at the minimum over all panels that share the x axis.
centernumber—Position of a bin center in X-axis units (milliseconds since 1970-01-01T00:00:00Z for a date or datetime x). Takes precedence over boundary.
integerBinsbooleanfalseWhen true and every binned value is an integer, each bin covers the same number of whole integers: the bin width is binwidth rounded up to an integer, or without binwidth, the range of the values divided by bins and rounded up, and never less than 1; bin edges fall halfway between integers, starting 0.5 below the minimum. Without binwidth, every integer gets its own bin when the range is no larger than bins, and the number of bins can be bins + 1. The last bin can extend past the maximum and then covers fewer observed integers than the other bins. boundary and center are not used in that case. With a width of 1, the bin centers become the axis ticks of ticks.fromLayer; with a wider bin, the axis uses its usual ticks. With facets, the width and edges are determined from the values of all panels that share the x axis, and the range and the integer check cover the values of all those panels. Has no effect when some value is not an integer or when x is a date or datetime column.

Time Bin (Datetime Histogram)

NameTypeDefaultDescription
interval'auto' | '1min' | '5min' | '15min' | '30min' | '1hour' | '6hour' | '12hour' | '1day' | '1week' | '1month' | '3month' | '1year''auto'Time interval for bins. 'auto' chooses based on data range (with facets, the range of all panels that share the x axis), and chooses '1day' or longer for a date column. For a datetime column, every interval bins by boundaries in the viewer's local time, the same boundaries as the time axis ticks: minutes and hours on the local clock, local midnight for '1day', Sunday midnight for '1week', and the start of the month, quarter (January, April, July, October), or year; viewed in a time zone with a different UTC offset, an observation moves to another bin when its local time falls in a different bin there. For a date column, bins follow the calendar dates themselves and do not depend on the time zone. Bin widths follow the calendar (e.g. 28-31 days for months) and, for a datetime column, daylight saving time (e.g. a 23-hour day or a 5-hour '6hour' bin when the clock moves forward).
yScale'count' | 'density' | 'proportion''count'Y-axis scale: 'count' reports bin counts (when bins span unequal durations, such as months, counts reflect both the rate and the length of each bin); 'density' reports probability density (bin counts divided by the number of binned observations × each bin's actual width in milliseconds, so the total area equals 1); 'proportion' reports each bin's share of its own group, so the values of every group sum to 1 (the bin width does not enter, so when bins span unequal durations the share also reflects the length of each bin). With a categorical aesthetic such as fill, both 'density' and 'proportion' use a per-group denominator, so each group reaches an area of 1 (density) or a total of 1 (proportion) on its own; stacking groups whose denominators differ produces a total with no interpretation. Both denominators count the observations that were binned, which excludes missing values of the binned column.

Smooth (Regression)

NameTypeDefaultDescription
method'lm' | 'loess''loess'Smoothing method: 'lm' for ordinary least squares, 'loess' for locally weighted regression (tricube kernel, local linear). A separate curve is fit for each group, a set of points that share the values of the grouping aesthetics (aesthetics with a categorical scale, such as color).
sebooleantrueWhen true, emits ymin/ymax for an interval band (Line geom draws the band automatically).
spannumber0.75LOESS span: fraction of points in each local neighborhood (0.1-1.0). Larger values produce smoother curves. Ignored when method is lm.
levelnumber95Interval level in percent (50-99.99), the same unit as confidenceLevel of models.run(). For example, 95 for a 95% interval. For loess, the interval uses simplified degrees of freedom (df = n - tr(L)) and does not account for smoothing bias, so at large spans the actual coverage can deviate from this nominal level.
interval'confidence' | 'prediction''prediction'Interval type. 'prediction' (the default) is for a new individual observation (wider, includes residual variance); 'confidence' is for the mean response (narrower). See Prediction interval in the glossary for assumptions and limits.

Count (Aggregation)

No parameters.

Density (KDE)

NameTypeDefaultDescription
bandwidthnumber—Kernel bandwidth in X-axis units. When omitted, bandwidth is selected automatically, separately for each group and, with facets, for each panel, by Silverman's rule of thumb (0.9 × min(SD, IQR/1.34) × n^(-1/5); no curve is drawn when this is 0, e.g. a constant middle 50%, identical values, or a single observation), which assumes a roughly normal shape and can oversmooth multimodal data.
kernel'gaussian''gaussian'Kernel function.
yScale'density' | 'count''density'Y-axis scale: 'density' reports the estimated probability density; with a categorical aesthetic such as color, each group's density is estimated from that group alone. 'count' scales density by n × binwidth, where binwidth is computed internally (via Sturges) and may not match a co-plotted Bin layer's Y scale exactly; to overlay a histogram and a density curve on a common scale, set both layers to 'density', which normalizes per group on both sides. The binwidth is computed per group from its own range and observation count, so with a categorical aesthetic the 'count' curves of different groups use different binwidths and their heights are not directly comparable.

Summary (Aggregation)

NameTypeDefaultDescription
outputsSummaryOutputDef[][{ fun: 'mean', to: 'y' }]Output definitions. Each entry is { fun, to, p?, k? }. fun selects the aggregation: 'mean', 'sum', 'median', 'min', 'max', 'sd' (sample SD, n-1 denominator), 'var' (sample variance, n-1 denominator), 'lower_se' (mean - SE, where SE = SD / sqrt(n)), 'upper_se' (mean + SE), 'lower_sd' (mean - SD), 'upper_sd' (mean + SD), 'quantile' (p-quantile with linear interpolation), 'mean_plus_k_sd' (mean + k * SD), 'mean_minus_k_sd' (mean - k * SD). to is the target aesthetic: 'y', 'ymin', or 'ymax' for positions, or 'fill', 'color', 'size', or 'alpha' to drive that scale with the aggregated value. p (0-1) selects the quantile for 'quantile'; when omitted, 0.5 (the median) is used. k (default 1) is the SD multiplier for 'mean_plus_k_sd' / 'mean_minus_k_sd'.
completebooleanfalseWhen true, after aggregation, adds a point whose aggregated value is 0 at each X value that has no data. When the column assigned to Y is used as a position without being aggregated (as in a heatmap), the points are added at the X and Y pairs that have no data. When the grouping aesthetics split the points into groups, the points are added for each group. Ignored with facets, where the facet's complete setting applies.

Boxplot (Quartiles + Whiskers)

NameTypeDefaultDescription
coefnumber1.5Whisker length as a multiple of the IQR. Whiskers extend to the most extreme data values within coef × IQR of the quartiles; data values beyond the whiskers are drawn as individual points.

Survival (Kaplan-Meier)

NameTypeDefaultDescription
confLevelnumber95Confidence level in percent (50-99.99), the same unit as confidenceLevel of models.run(), for the pointwise confidence interval of S(t): each interval holds at a single time point and is not a simultaneous band covering the whole curve. Variance is estimated with Greenwood's formula and the interval is constructed on the log scale, so the lower bound stays positive while S(t) is positive and the upper bound is clipped to 1; at time points where S(t) is exactly 0 or 1 the interval collapses to that value.

ROC Curve

NameTypeDefaultDescription
showReferenceLinebooleantrueWhen true, draws the diagonal reference line y = x, the ROC curve of a classifier that assigns labels independently of the data.

X Mean

NameTypeDefaultDescription
labelstring'Mean: {value}'Label template for the reference line. {value} is replaced with the computed mean.

X Median

NameTypeDefaultDescription
labelstring'Median: {value}'Label template for the reference line. {value} is replaced with the computed median.

Y Mean

NameTypeDefaultDescription
offsetnumber0Number of sample SDs added to the mean; not a raw offset on the Y-axis. SD is the sample standard deviation (n-1) of the plotted Y values (computed per group when a grouping aesthetic is mapped), not a within-subgroup SD. For example, 3 draws a line at mean + 3 × SD, and -3 at mean − 3 × SD.
labelstring'Mean: {value}'; 'Mean + k*SD: {value}' when offset is a positive k, and 'Mean - k*SD: {value}' when offset is -kLabel template for the reference line. {value} is replaced with the computed value.

Cumulative Sum (Pareto)

NameTypeDefaultDescription
normalizebooleanfalseWhen true, scales the cumulative sum so the total equals 100 (percent).

Sort (Pareto)

NameTypeDefaultDescription
order'ascending' | 'descending''descending'Order of the categories by the sum of their Y values.
limitnumber—Keep only the top N categories after sorting. Omit to keep all categories.
displayOrder'alphabetical'—Re-sorts the kept categories into the default category order of the x axis. Only 'alphabetical' is supported; omit to keep the sort order selected by 'order'.

ECDF (Empirical CDF)

No parameters.

QQ (Normal Q-Q Plot)

NameTypeDefaultDescription
showReferenceLinebooleantrueWhen true, draws a reference line to assess deviation from normality.
referenceLineType'q1q3' | 'identity''q1q3'Reference line type. 'q1q3' is the line through (Φ⁻¹(0.25), Q1) and (Φ⁻¹(0.75), Q3), where Φ⁻¹ is the standard normal quantile function and Q1 and Q3 are the sample quartiles with linear interpolation (the same as the 'quantile' summary); use it for raw data on its original scale. When points are split into groups by color, fill, stroke, shape, linetype, or group, each group with 4 or more points gets its own line from its own quartiles. 'identity' is y = x; use it only when the input is already standardized (e.g., z-scores centered at 0 and scaled by SD) within each group.

Transform (Linear)

NameTypeDefaultDescription
multiplynumber1Multiplier applied to Y. For example, -1 flips a histogram for a population pyramid.
addnumber0Offset added after multiplication.

Cook's Distance Contour

NameTypeDefaultDescription
distancenumber0.5Cook's distance D of the contour.
parameterCountnumber2Number of coefficients p of the model, counting the intercept and not counting the dispersion parameter. For a GLM or Linear Regression model, it is diagnosticSummary.nObservations − diagnosticSummary.degreesOfFreedom from models.describe.
residualSign'positive' | 'negative''positive'Side of the contour to draw: positive or negative standardized residuals.

Palettes

Available values for paletteId in the color / fill aesthetic of layers[].scales. See Agent API for how to set palettes via API.

Categorical

For coloring by categorical variables. Use with scaleType: 'categorical'.

IDNameColors
midas-defaultMIDAS Default12
tableau10Tableau 1010
d3-category10D3 Category1010

Default: midas-default.

Sequential

For continuous or ordinal variables. Use with scaleType: 'sequential'.

Also usable with scaleType: 'categorical' and 'threshold'. In those modes, one color per category or threshold region is sampled at equal intervals across the full palette range. In categorical mode, the group of missing values is not counted as a category and is drawn in gray.

IDNameColors
bluesBlues9
greensGreens9
greysGreys9
purplesPurples9
ylorrdYellow-Orange-Red9
viridisViridis10
plasmaPlasma10
infernoInferno10
magmaMagma10

Default: blues. Viridis, Plasma, Inferno, and Magma are perceptually uniform and accommodate color vision diversity.

Diverging

For variables that diverge in both directions from a center value. Use with scaleType: 'diverging'.

Also usable with scaleType: 'threshold'. In that mode, one color per threshold region is sampled at equal intervals across the full palette range.

IDNameColors
rdbuRed-Blue11
brbgBrown-Teal11

Default: rdbu.

scaleType and paletteId compatibility

scaleTypeAccepted paletteId
categoricalCategorical + Sequential palettes
sequentialSequential palettes only
divergingDiverging palettes only
thresholdSequential + Diverging palettes

With threshold, you can also specify colors directly via thresholdColors. When thresholdColors is set, it takes precedence; when omitted, one color per threshold region is sampled at equal intervals across the paletteId palette.

In the Graph Builder UI, switching the scale type automatically resets an incompatible palette to that scale type's default, and the graph keeps rendering.

Compatibility is checked against the effective scale type. When sequential / diverging is specified for a non-numeric column, the effective type becomes categorical, so a palette that matches the specified type in the table above can still fail.

Fixed geometry settings

Aesthetics map a column to a visual attribute. A constant color, size, or opacity that does not depend on data belongs in geom.defaults, not in aes. In the Graph Builder UI these settings are in the layer's Geometry section.

  • Fixed color: Set the line, point, or text color with color in geom.defaults; set the fill color of bar, area, tile, ribbon, crossbar, and box plot with fill (any CSS color string). The border color of tile is stroke. Crossbar and box plot also use stroke for their fixed line color (box outline, center line, and whiskers) — they have no color key in geom.defaults.
  • Fixed size: Set size (point radius), strokeWidth (line width of line-drawing geometries), or fontSize (text, label) in geom.defaults. The tables in geom.defaults keys by geometry show which geometry has which key.
  • Fixed opacity: Set alpha in geom.defaults, where 0 is fully transparent and 1 is fully opaque.
await window.midas.tabs.addGraphLayer(tabId, {
  geom: { type: 'point', defaults: { color: '#3366CC', size: 8, alpha: 0.5 } },
  aes: { x: 'weight', y: 'height' }
});

geom.defaults keys by geometry

The keys accepted in geom.defaults differ by geometry. The tables below list each geometry's key names, types, ranges, default values, and descriptions. They are the same set as the items in the Geometry section of the layer settings in the Graph Builder UI, and a key you omit is drawn with its default value. The Range column is the range selectable in the Graph Builder UI.

One structured setting is not in the tables. The labelContent of Text and Label displays stat output or a column's value, with formatting, as the label and is set in the UI from the Label Content area on the layer card. It is described in Using labels with stats.

Point (Scatter)

KeyTypeRangeDefaultDescription
colorstring (CSS color)—'#4682b4'Point color used when no column is mapped to the color aesthetic. Any CSS color string.
sizenumber1–205Point radius in pixels, used when no column is mapped to the size aesthetic.
alphanumber0–10.7Opacity of the layer, from 0 (fully transparent) to 1 (fully opaque).

Line

KeyTypeRangeDefaultDescription
colorstring (CSS color)—'#4682b4'Line color used when no column is mapped to the color aesthetic. Any CSS color string.
strokeWidthnumber1–52Line width in pixels.
lineType'solid' | 'dashed' | 'dotted'—'solid'Dash pattern of the line.
alphanumber0–10.9Opacity of the layer, from 0 (fully transparent) to 1 (fully opaque).

Bar

KeyTypeRangeDefaultDescription
fillstring (CSS color)—'#4682b4'Bar fill color used when no column is mapped to the fill aesthetic. Any CSS color string.
widthnumber0.1–10.8Bar width as a fraction of the category band width.
alphanumber0–10.8Opacity of the layer, from 0 (fully transparent) to 1 (fully opaque).

Area

KeyTypeRangeDefaultDescription
fillstring (CSS color)—'#4682b4'Fill color of the area used when no column is mapped to either the fill or the color aesthetic. Any CSS color string.
alphanumber0–10.5Opacity of the layer, from 0 (fully transparent) to 1 (fully opaque).

Tile (Heatmap)

KeyTypeRangeDefaultDescription
fillstring (CSS color)—'#cccccc'Cell fill color used when no column is mapped to the fill aesthetic. Any CSS color string.
strokestring (CSS color)—'#ffffff'Border color of each cell. Any CSS color string.
strokeWidthnumber0–50.5Border width of each cell in pixels. 0 draws no border.
alphanumber0–11Opacity of the layer, from 0 (fully transparent) to 1 (fully opaque).

Step (Kaplan-Meier)

KeyTypeRangeDefaultDescription
colorstring (CSS color)—'#4682b4'Line color used when no column is mapped to the color aesthetic. Any CSS color string.
strokeWidthnumber1–52Line width in pixels.
lineType'solid' | 'dashed' | 'dotted'—'solid'Dash pattern of the line.
alphanumber0–10.9Opacity of the layer, from 0 (fully transparent) to 1 (fully opaque).

Ribbon (Confidence Band)

KeyTypeRangeDefaultDescription
fillstring (CSS color)—'#4682b4'Band fill color used when no column is mapped to either the fill or the color aesthetic. Any CSS color string.
curveType'linear' | 'stepAfter' | 'stepBefore'—'linear'How the band edges connect consecutive points: straight segments, or a step that changes after or before each x value.
alphanumber0–10.2Opacity of the layer, from 0 (fully transparent) to 1 (fully opaque).

Error Bar

KeyTypeRangeDefaultDescription
colorstring (CSS color)—'#333333'Color of the bars and caps used when no column is mapped to the color aesthetic. Any CSS color string.
strokeWidthnumber0.5–51.5Width of the bars and caps in pixels.
capWidthnumber0–208Width of the caps at ymin and ymax in pixels. 0 draws no caps.
alphanumber0–10.8Opacity of the layer, from 0 (fully transparent) to 1 (fully opaque).

Crossbar

KeyTypeRangeDefaultDescription
fillstring (CSS color)—'#4682b4'Fill color of the rectangle used when no column is mapped to the fill aesthetic. Any CSS color string.
strokestring (CSS color)—'#333333'Color of the outline and the center line used when no column is mapped to the color aesthetic. Any CSS color string.
widthnumber0.1–10.6Rectangle width as a fraction of the category band width.
strokeWidthnumber0.5–51.5Width of the outline and the center line in pixels.
alphanumber0–10.8Opacity of the layer, from 0 (fully transparent) to 1 (fully opaque).

Box Plot

KeyTypeRangeDefaultDescription
fillstring (CSS color)—'#4682b4'Box fill color used when no column is mapped to the fill aesthetic. Any CSS color string.
strokestring (CSS color)—'#333333'Color of the box outline, the median line, and the whiskers used when no column is mapped to the color aesthetic. Any CSS color string.
widthnumber0.1–10.6Box width as a fraction of the category band width.
strokeWidthnumber0.5–51.5Width of the box outline, the median line, and the whiskers in pixels.
pointSizenumber1–102.5Radius in pixels of the points drawn beyond the whiskers.
alphanumber0–10.8Opacity of the layer, from 0 (fully transparent) to 1 (fully opaque).

Vertical Line (Reference)

KeyTypeRangeDefaultDescription
xinterceptnumber——X value at which the line is drawn. When omitted, a line is drawn at each value of the column mapped to x.
lineType'solid' | 'dashed' | 'dotted'—'dashed'Dash pattern of the line.
colorstring (CSS color)—'#888888'Line color used when no column is mapped to the color aesthetic. Any CSS color string.
strokeWidthnumber1–51Line width in pixels.
alphanumber0–10.7Opacity of the layer, from 0 (fully transparent) to 1 (fully opaque).

Horizontal Line (Reference)

KeyTypeRangeDefaultDescription
yinterceptnumber——Y value at which the line is drawn. When omitted, a line is drawn at each value of the column mapped to y.
lineType'solid' | 'dashed' | 'dotted'—'dashed'Dash pattern of the line.
colorstring (CSS color)—'#888888'Line color used when no column is mapped to the color aesthetic. Any CSS color string.
strokeWidthnumber1–51Line width in pixels.
alphanumber0–10.7Opacity of the layer, from 0 (fully transparent) to 1 (fully opaque).

Sloped Line (Reference)

KeyTypeRangeDefaultDescription
slopenumber—1Slope of the line: the change in y per unit change in x (per millisecond on a date or datetime x axis).
interceptnumber—0Y value of the line at x = 0 (at 1970-01-01T00:00:00Z on a date or datetime x axis).
lineType'solid' | 'dashed' | 'dotted'—'dashed'Dash pattern of the line.
colorstring (CSS color)—'#888888'Line color. Any CSS color string.
strokeWidthnumber1–51Line width in pixels.
alphanumber0–10.7Opacity of the layer, from 0 (fully transparent) to 1 (fully opaque).

Density 2D

KeyTypeRangeDefaultDescription
bandwidth'auto' | number—'auto'Kernel bandwidth as a fraction of the mean of the x and y axis ranges. auto chooses the bandwidth by Scott's rule. The UI offers 0.1 to 2; the API accepts any positive number.
levelsnumber5–3010Approximate number of contour levels. Thresholds are placed at evenly spaced round values from 0 up to the maximum density, so the number drawn can differ from this value.
colorScale'YlOrRd' | 'Blues' | 'Greens' | 'Greys' | 'Purples' | 'Viridis' | 'Plasma'—'YlOrRd'Sequential palette that maps density to color.
visualization'filled-with-lines' | 'filled-only' | 'contour-only'—'filled-with-lines'Whether to draw filled regions, contour lines, or both.
alphanumber0–10.8Opacity of the layer, from 0 (fully transparent) to 1 (fully opaque).

Text (Label)

KeyTypeRangeDefaultDescription
colorstring (CSS color)—'#333333'Text color used when no column is mapped to the color aesthetic. Any CSS color string.
fontSizenumber6–2411Font size in pixels.
fontWeight'normal' | 'bold'—'normal'Weight of the text.
textAnchor'start' | 'middle' | 'end'—'middle'Horizontal alignment of the text relative to the point: the text starts at, is centered on, or ends at the point.
dxnumber-50–500Horizontal offset of the text from the point in pixels.
dynumber-50–50-8Vertical offset of the text from the point in pixels. Negative values move the text up.
alphanumber0–11Opacity of the layer, from 0 (fully transparent) to 1 (fully opaque).

Label (Annotation)

KeyTypeRangeDefaultDescription
colorstring (CSS color)—'#333333'Text color used when no column is mapped to the color aesthetic. Any CSS color string.
fontSizenumber6–2411Font size in pixels.
fontWeight'normal' | 'bold'—'normal'Weight of the text.
backgroundColorstring (CSS color)—'#ffffff'Background color of the text box. Any CSS color string.
backgroundAlphanumber0–10.93Opacity of the text box background, from 0 (fully transparent) to 1 (fully opaque).
borderColorstring (CSS color)—'#cccccc'Border color of the text box. Any CSS color string.
leaderColorstring (CSS color)—'#999999'Color of the leader line from the point to the text box. Any CSS color string.
paddingnumber0–164Space between the text and the edge of the text box in pixels.
offsetDistancenumber10–8030Distance from the point to the text box in pixels.
alphanumber0–11Opacity of the layer, from 0 (fully transparent) to 1 (fully opaque).

Multiple layers with different fixed colors

Add each series as a separate layer with its own geom.defaults.color:

// Layer 1: actual values in blue
await window.midas.tabs.addGraphLayer(tabId, {
  geom: { type: 'line', defaults: { color: '#3366CC' } },
  aes: { x: 'date', y: 'actual' }
});

// Layer 2: predicted values in red
await window.midas.tabs.addGraphLayer(tabId, {
  geom: { type: 'line', defaults: { color: '#CC3333' } },
  aes: { x: 'date', y: 'predicted' }
});

Alternative: categorical color mapping

When data is in long format (one row per observation with a grouping column), map the grouping column to color instead of setting a fixed color. The palette assigns a distinct color to each group automatically.

// Long format: each row has a "series" column ("actual" or "predicted")
await window.midas.tabs.addGraphLayer(tabId, {
  geom: { type: 'line' },
  aes: { x: 'date', y: 'value', color: 'series' }
});

This approach works well when the number of series is dynamic or when you want consistent palette colors across multiple graphs.

Using labels with stats

When a layer uses a stat (Count, Summary, Bin, etc.), the stat replaces original column values with aggregated results. An aes.label column mapping cannot reference the original data after transformation. To display stat-computed values as labels, set geom.defaults.labelContent instead of aes.label.

labelContent references a $-prefixed variable or a column. The variables that hold stat output are:

VariableDescription
$yY value after stat transformation (count, mean, etc.). In a layer whose position is fill, it is the proportion of the sum of absolute values at each x position, and a tooltip field without format shows it as a percentage. A field without label either is labeled % of total (% of total, groups weighted equally when the stat's yScale is density or proportion). In a layer whose position is jitter, it is the value before the shift
$xX value (bin center, category name). In a layer whose position is dodge or jitter, it is the value before the shift
$nNumber of observations the stat used to compute the point's value (missing values excluded). Count, Bin, Summary, Boxplot, and similar stats emit it; Smooth (regression curves) does not
$xminBin lower bound (Bin and Time Bin stats)
$xmaxBin upper bound (Bin and Time Bin stats)
$yminLower bound of interval
$ymaxUpper bound of interval
$q1First quartile (Boxplot stat)
$q3Third quartile (Boxplot stat)

Besides the variables in the table, variables that hold the value assigned to an aesthetic ($color, $fill, $alpha, $label, and others) can also be given. On a point that keeps the value of the column mapped to Label, $label holds that value. Points of a layer without a stat keep it, so giving $label labels each point with that column's value plus prefix and suffix. On points of X Mean, X Median, and Y Mean, $label holds the label text the stat produces.

// Show mean values as labels on a summary chart
await window.midas.tabs.addGraphLayer(tabId, {
  geom: {
    type: 'label',
    defaults: {
      labelContent: { field: '$y', format: '.1f' }
    }
  },
  stats: [{ type: 'summary', params: { outputs: [{ fun: 'mean', to: 'y' }] } }],
  aes: { x: 'category', y: 'value' }
});

The labelContent object accepts these properties:

PropertyTypeDescription
fieldstringA $-prefixed variable (see table above), a column name, or a column ID. Column names are resolved case-insensitively
formatstringd3-format specifier (optional). It applies only to numeric values. Common patterns: .1f (1 decimal), .0% (percent, no decimals), ,.0f (thousands separator)
prefixstringText prepended to the formatted value
suffixstringText appended to the formatted value

In Graph Builder, labelContent is set in the Label Content area of the Geometry section on a Text or Label layer's card. The Field, Format, Prefix, and Suffix inputs correspond to field, format, prefix, and suffix in the table above. When Field names a variable other than $label or a column, the column mapped to Label in the Aesthetics section is not used for the labels. Setting Field back to None removes labelContent, and the column mapped to Label becomes the label again.

Coordinate System

The coordinate system is a graph-level setting, specified in the coordinates field of tabs.configureGraph or reports.addGraph. Available values:

  • 'cartesian' (default) — Standard Cartesian coordinates
  • 'flipped' — Swaps X and Y axes. Useful for horizontal bar charts with long category labels

In the GUI, this corresponds to the Coordinate System section in Graph Builder. See Custom Graph: Flipping Axes for a visual example.

scales.x / scales.y in flipped coordinates

In flipped coordinates, aes.y data appears on the physical X axis (horizontal) and aes.x data on the physical Y axis (vertical). Every scales.x / scales.y setting (type, domain, ticks, zoomEnabled, title, and the rest) follows the data axis: scales.x controls the axis showing aes.x data (the vertical axis when flipped), and scales.y controls the axis showing aes.y data (the horizontal axis when flipped).

// Horizontal bar chart: aes.x mapped to categories, aes.y to values
await window.midas.tabs.configureGraph(tabId, {
  coordinates: 'flipped',
  scales: {
    x: { title: 'Product' },      // axis for aes.x data — vertical when flipped
    y: { title: 'Sales (USD)' }   // axis for aes.y data — horizontal when flipped
  }
});

The secondary Y axis (scales.y2) is disabled in flipped coordinates.

See also