Custom Graph リファレンス

Custom Graph で利用可能な Geometry と Statistics の一覧です。各項目の詳細は、レイヤー設定内のヘルプボタン(?)で確認できます。

テーブル内の Description はアプリ UI の表記と一致させるため英語で記載しています。

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 statistic 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 statistic.
Vertical Line (Reference)Fixed vertical reference line. Configure style in the layer settings.
Horizontal Line (Reference)Fixed horizontal reference line. Configure style in the layer settings.
ContourDraws a curve from a series of points. Used for Cook's distance contours in regression diagnostics.
Density 2D2D kernel density estimation as contour lines. For 1D density curves, use the Density (KDE) statistic.
Text (Label)Displays text labels at data points. Requires the Label aesthetic.
Label (Annotation)Displays text boxes with leader lines at data points. Includes automatic collision avoidance.

Geometry と aesthetic の互換性

各 Geometry は特定の aesthetic(位置・色・サイズなどの視覚マッピング)のみを受け付けます。対応していない aesthetic を指定しても効果はありません。

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

R = required(必須), ○ = optional(指定時に追加の動作が発生), • = supported(対応)

  • Required の aesthetic はカラムへのマッピングか Statistics による供給が必要です。
  • color と fill の違い: Bar と Tile は塗りつぶしに fill を使います(color ではありません)。Area は両方を受け付けます — color は輪郭線、fill は塗りつぶしです。Ribbon は輪郭線を描画せず、color が塗りつぶし色を決めます。Ribbon の fill は threshold カラースケールを使う場合にのみ参照されます。Crossbar と Box Plot は矩形の塗りつぶしに fill を、線の色(Box Plot では箱の枠線・ひげ・中央値線・ひげの外の点)に color を使います。
  • stroke: Point のみが対応しています。ポイントの輪郭色を設定します。
  • shape: Box Plot では、割り当てた列の水準ごとに箱が分割され(color や fill と同様)、ひげの外の点が水準ごとに異なるマーカー形状で描かれます。size はひげの外の点にのみ適用されます。
  • ymin / ymax: Line は両方が存在するとインターバルバンドを描画します。Ribbon・Errorbar・Crossbar・Box Plot では必須です。
  • q1 / q3: Box Plot は箱の上端と下端に四分位数を必要とします。この 2 つはカラムにマッピングできないため表に列がなく、Boxplot statistic の出力だけが供給元です。
  • label: Text ではカラムへのマッピングが必須です。Label では aes.label か geom.defaults.labelContent のどちらかが必要です。
  • weight: どの Geometry の描画にも影響しないため表に列がありません。行の頻度重み(その行が何行分の観測に相当するか)を数値カラムで指定し、重みに対応した Statistics(ROC Curve)だけが読み取ります。tooltip の $n は重みを合計せず、計算に使った行数を数えます。

Geometry と position の互換性

各 Geometry が受け付ける position(位置調整)は異なります。各 position type の意味は Position を参照してください。表にない position type を tabs.addGraphLayer / tabs.updateGraphLayer で指定すると INVALID_INPUT エラーになります。position を省略した場合のデフォルトは bar が stack、それ以外の geom が 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
contouridentity
density2didentity
textidentity
labelidentity

position は Geometry だけでなく Statistics とも組み合わせが検証されます。次の表に載っている Statistics は、記載された position とだけ組み合わせられます。表にない Statistics はすべての position を使えます。実際に指定できるのは Geometry 側の許容 position との共通部分で、共通部分にない position を指定すると同じく INVALID_INPUT エラーになります。stack と fill は y の値だけを積み上げ・正規化し、Boxplot stat が出力する箱とひげの値はそのまま残るため、軸の表記とグラフの内容が食い違います。Boxplot stat がこれらの position と組み合わせられないのはこのためです。

StatisticsAllowed positions
Boxplot (Quartiles + Whiskers)identity, dodge, jitter

Geometry と連続カラースケール

連続カラースケール(sequential と diverging)を割り当てたチャネルは、系列を分けません。Line・Area・Step・Ribbon はレイヤーごとに 1 本のパスを描き、色は X 軸に沿って変化するグラデーションになります。flipped 座標系では Y 軸に沿います。グラデーションの色は各データ点の位置でその点の値から決まり、点と点の間は補間されます。値ごとにパスを分けると、値が行ごとに異なる列では 1 点だけのパスばかりになります。長さを持たないパスは描画されないため、値ごとには分けません。

値ごとにパスを分けたい場合は、そのチャネルの scaleType を categorical にします。

Area の position stack と fill は系列を 1 つずつ積み上げるため、連続カラースケールでは成立しません。MIDAS はこの構成のレイヤーを position identity として描画し、グラフの上に警告を表示します。Bar は点ごとに矩形を描くので、連続カラースケールでも積み上げます。

Statistics(統計変換)

StatisticsDescription
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 Y values by X using mean, sum, median, min, max, standard deviation, or variance.
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 group. Use with the Box Plot geometry.
Survival (Kaplan-Meier)Computes Kaplan-Meier survival estimates. Map the time to X (positive values) and the event indicator to Y (1 = event, 0 = censored). If X contains zero or negative values or Y contains values other than 0 and 1, no curve is drawn and the layer warning lists which values appear in how many rows.
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 data by Y values in descending 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 theoretical quantiles.
Transform (Linear)Applies linear transformation (multiply and add) to Y values.

Statistics のパラメータ

各 Statistic は tabs.addGraphLayer / tabs.updateGraphLayer の stats 配列に params オブジェクトを渡します。以下の表は各 Statistic のパラメータ名、TypeScript 型、デフォルト値、説明の一覧です。

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

型の記法: A | B は A か B のどちらかを指定、T[] は T の配列、フィールド名末尾の ?(例: p?)は省略可能を表します。各 Statistic の前提・限界・ユースケースの詳細は Custom Graph を参照してください。

Identity (No transformation)

No parameters.

Bin (Histogram)

NameTypeDefaultDescription
binsnumber30Number of bins (1-100). Ignored when binwidth is specified.
binwidthnumber—Width of each bin in X-axis units (must be positive). 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. Bins are aligned so that one edge falls on this value.
centernumber—Position of a bin center in X-axis units. Takes precedence over boundary.

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. '1min' through '1week' are fixed-width intervals; '1month', '3month', and '1year' bin by calendar boundaries in the viewer's local time (start of month, quarter, or year), so bin widths follow the calendar (e.g. 28-31 days for months) and observations near a boundary can fall into a different bin when the graph is viewed in a different time zone.
yScale'count' | 'density' | 'proportion''count'Y-axis scale: 'count' reports bin counts (with calendar intervals the bins span unequal durations, so 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 width in milliseconds; calendar intervals use each bin's actual width, 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 with calendar intervals 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). When a grouping aesthetic (color, fill, etc.) is mapped, a separate curve is fit per group.
sebooleantrueWhen true, emits ymin/ymax for an interval band (Line geom draws the band automatically). The name follows ggplot2's se argument, but the emitted values are the interval endpoints (ymin/ymax), not a standard error.
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 (must be positive when specified). When omitted, bandwidth is selected automatically 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. Only Gaussian is supported.
yScale'density' | 'count''density'Y-axis scale: 'density' reports probability density (area equals 1; with a categorical aesthetic such as color, the curve of each group reaches an area of 1 on its own). '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. A group whose values are all identical has a binwidth of 0, so no 'count' curve is drawn for it and the group is reported in the diagnostics.

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, fills missing X × Y combinations with 0 before aggregation. Intended for count-like aggregations; with 'mean' or 'median' the zero-fill biases the result.

Boxplot (Quartiles + Whiskers)

NameTypeDefaultDescription
coefnumber1.5Whisker length as a multiple of the IQR (must be non-negative). 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 (upper control limit, UCL), and -3 at mean − 3 × SD (lower control limit, LCL). No line is drawn for a group whose SD cannot be computed (a single observation, or values whose range is too wide for double precision); the graph warning names the group.
labelstring'Mean: {value}'Label 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'Sort direction applied to Y values.
limitnumber—Keep only the top N categories after sorting (a positive integer). Omit to keep all categories.
displayOrder'alphabetical'—Re-sorts the kept categories by category name, in Unicode code point order (all uppercase letters come before all lowercase letters). 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' passes through the first and third quartiles, taken as order statistics without interpolation (so they can differ from the interpolated 'quantile' summary); use it for raw data on its original scale. 'identity' is y = x; use it only when the input is already standardized (e.g., z-scores centered at 0 and scaled by SD).

Transform (Linear)

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

Palettes(パレット)

layers[].scales の color / fill aesthetic で paletteId に指定できる値の一覧です。API での設定方法は Agent API を参照してください。

Categorical

カテゴリカル変数の色分けに使います。scaleType: 'categorical' で指定します。

IDNameColors
midas-defaultMIDAS Default12
tableau10Tableau 1010
d3-category10D3 Category1010

デフォルトは midas-default です。

Sequential

連続変数や順序尺度の変数に使います。scaleType: 'sequential' で指定します。

scaleType: 'categorical' と 'threshold' でも使用できます。カテゴリ数または閾値で区切られた領域数ぶんの色をパレット全域から等間隔にサンプリングします。

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

デフォルトは blues です。Viridis、Plasma、Inferno、Magma は知覚的に均一で色覚多様性に配慮したパレットです。

Diverging

中心値からの乖離を両方向に表す変数に使います。scaleType: 'diverging' で指定します。

scaleType: 'threshold' でも使用できます。閾値で区切られた領域数ぶんの色をパレット全域から等間隔にサンプリングします。

IDNameColors
rdbuRed-Blue11
brbgBrown-Teal11

デフォルトは rdbu です。

scaleType と paletteId の互換性

scaleType使用可能な paletteId
categoricalCategorical パレット + Sequential パレット
sequentialSequential パレットのみ
divergingDiverging パレットのみ
thresholdSequential パレット + Diverging パレット

threshold では thresholdColors で色を直接指定することもできます。thresholdColors を指定するとそれが優先され、省略すると paletteId のパレット全域から閾値で区切られた領域数ぶんの色を等間隔にサンプリングします。

Graph Builder の UI で scaleType を切り替えると、非互換になったパレットはその scaleType の既定パレットに自動でリセットされ、グラフはそのまま描画されます。API で非互換の paletteId を直接指定した場合は、描画時にエラーになりグラフが表示されません。

この互換性の判定には実効のスケール種別を使います。数値でない列に sequential / diverging を指定した場合、実効種別は categorical になるため、指定した種別の上では適合するパレットでもエラーになることがあります。エラーメッセージには実効種別へ解決された経緯が示されます。

Geometry の固定設定

aesthetic はカラムを視覚属性にマッピングします。データに依存しない固定の色・サイズ・不透明度は aes ではなく geom.defaults に置きます。Graph Builder の UI では、これらはレイヤーの Geometry セクションで設定します。

  • 固定色: 線・点・文字の色は geom.defaults の color、bar・area・tile・ribbon・crossbar・boxplot の塗りつぶし色は geom.defaults の fill に CSS カラー文字列を指定します。tile の枠線色は geom.defaults の stroke です。crossbar と boxplot の線色(枠線・中心線・ひげ)も stroke で指定します(geom.defaults に color キーはありません)
  • 固定サイズ: geom.defaults の size(point の半径)、strokeWidth(線を描く Geometry の線幅)、fontSize(text・label)に指定します。どの Geometry がどのキーを持つかは Geometry ごとの geom.defaults キー の表で確認できます
  • 固定不透明度: geom.defaults の alpha に指定します。0 が完全透明、1 が完全不透明です
await window.midas.tabs.addGraphLayer(tabId, {
  geom: { type: 'point', defaults: { color: '#3366CC', size: 8, alpha: 0.5 } },
  aes: { x: 'weight', y: 'height' }
});

固定値を aes に渡すと(例: aes.color: { fixedColor: ... } や aes.size: 8)INVALID_INPUT エラーになります。aes.* はカラム名のみを受け付けます。

Geometry ごとの geom.defaults キー

geom.defaults に指定できるキーは Geometry ごとに異なります。以下の表は各 Geometry のキー名、型、範囲、既定値、説明の一覧です。Graph Builder の UI でレイヤーの Geometry セクションに並ぶ項目と同じ集合で、省略したキーは既定値で描画します。Range 列は Graph Builder の UI で選べる範囲です。

構造を持つ 2 つの設定は表に含まれません。Contour の points は曲線を構成する { x, y } の配列で、Agent API からのみ指定できます。Label の labelContent は Statistics の出力をラベルにする設定で、Statistics と Label の連携 で説明します。

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 the fill 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 the fill 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).

Contour

KeyTypeRangeDefaultDescription
strokeWidthnumber1–51.5Line width in pixels.
lineType'solid' | 'dashed' | 'dotted'—'solid'Dash pattern of the line.
colorstring (CSS color)—'#888888'Line color of the curve. Any CSS color string.
alphanumber0–10.6Opacity 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.
levelsnumber2–2010Number of contour levels.
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).

複数レイヤーに異なる固定色を設定する

各系列を個別のレイヤーとして追加し、それぞれに geom.defaults.color を設定します。

// レイヤー 1: 実測値(青)
await window.midas.tabs.addGraphLayer(tabId, {
  geom: { type: 'line', defaults: { color: '#3366CC' } },
  aes: { x: 'date', y: 'actual' }
});

// レイヤー 2: 予測値(赤)
await window.midas.tabs.addGraphLayer(tabId, {
  geom: { type: 'line', defaults: { color: '#CC3333' } },
  aes: { x: 'date', y: 'predicted' }
});

代替手段: カテゴリカル色分け

データが long 形式(1行1観測値、グループ列あり)の場合、固定色の代わりにグループ列を color にマッピングします。パレットが各グループに自動で色を割り当てます。

// long 形式: 各行に "series" 列("actual" や "predicted")がある
await window.midas.tabs.addGraphLayer(tabId, {
  geom: { type: 'line' },
  aes: { x: 'date', y: 'value', color: 'series' }
});

系列数が動的に変わる場合や、複数グラフでパレット色をそろえたい場合は、この方法を使います。

Statistics と Label の連携

レイヤーで Statistics(Count、Summary、Bin 等)を使用すると、元のカラム値が集約結果に置き換わります。aes.label のカラムマッピングでは変換後のデータから元の値を参照できません。集約値をラベルとして表示するには、aes.label の代わりに geom.defaults.labelContent を設定します。

labelContent は $ プレフィックス付きの stat 出力変数を参照します。

変数説明
$ystat 変換後の Y 値(count、mean 等)。position が fill のレイヤーでは各 X 位置の値の絶対値合計に対する割合になり、tooltip で format を省略するとパーセント形式で表示されます
$xX 値(ビン中心、カテゴリ名)
$nその点の統計量が計算に使った観測数を表す(欠損は除く)。Count・Bin・Summary・Boxplot などが対象で、Smooth(回帰曲線)では出力しない
$xminビンの下限(Bin stat・Time Bin stat)
$xmaxビンの上限(Bin stat・Time Bin stat)
$yminインターバルの下限
$ymaxインターバルの上限
$q1第 1 四分位数(Boxplot stat)
$q3第 3 四分位数(Boxplot stat)
// Summary の平均値をラベルとして表示する
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' }
});

labelContent オブジェクトのプロパティ:

プロパティ型説明
fieldstring$ プレフィックス付き変数(上表参照)、またはカラム名かカラム ID。カラム名は大文字小文字を区別せずに解決されます
formatstringd3-format 書式指定(省略時はデータ型から自動推定)。代表的な書式: .1f(小数1桁)、.0%(パーセント、小数なし)、,.0f(桁区切り)
prefixstringフォーマット値の前に付加するテキスト
suffixstringフォーマット値の後に付加するテキスト

field に指定した変数や列の値がレイヤーのどの点でも取れないとき、MIDAS はそのレイヤーのラベルを 1 つも描かず、グラフの上に警告を表示します。警告には指定した列の名前または変数と、そのレイヤーで値を取れる変数の一覧が入ります。集約は元の列の値を点に残さないため、Statistics を使うレイヤーで元データの列を指定するとこの状態になります。

座標系

座標系はグラフレベルの設定で、tabs.configureGraph または reports.addGraph の coordinates フィールドに指定します。

  • 'cartesian'(デフォルト)— 標準的な直交座標系
  • 'flipped' — X 軸と Y 軸を入れ替えます。カテゴリラベルが長い横棒グラフで読みやすくなります

GUI では Graph Builder の Coordinate System セクションに対応します。表示例は Custom Graph: 軸の入れ替え を参照してください。

flipped 座標系での scales.x / scales.y

flipped 座標系では aes.y のデータが物理 X 軸(横)に、aes.x のデータが物理 Y 軸(縦)に描画されます。scales.x / scales.y の設定は、すべての項目(type、domain、ticks、zoomEnabled、title など)がデータの軸に追従します。scales.x は aes.x のデータの軸(flipped では縦軸)を、scales.y は aes.y のデータの軸(flipped では横軸)を制御します。

// 横棒グラフ: aes.x にカテゴリ、aes.y に数値をマッピングした場合
await window.midas.tabs.configureGraph(tabId, {
  coordinates: 'flipped',
  scales: {
    x: { title: 'Product' },      // aes.x の軸 — flipped では縦軸に表示
    y: { title: 'Sales (USD)' }   // aes.y の軸 — flipped では横軸に表示
  }
});

副 Y 軸(scales.y2)は flipped 座標系では無効になります。

See also