Custom Graph リファレンス
Custom Graph で利用可能な Geometry と Statistics の一覧です。各項目の詳細は、レイヤー設定内のヘルプボタン(?)で確認できます。
テーブル内の Description はアプリ UI の表記と一致させるため英語で記載しています。
Geometry(形状)
| Geometry | Description |
|---|---|
| Point (Scatter) | Displays data as individual points. |
| Line | Connects data points with lines. Draws an interval band automatically when ymin/ymax are present. |
| Bar | Vertical bars for categorical data. Use Fill (not Color) to change bar color. |
| Area | Filled 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 Bar | Error bars showing ymin to ymax range with caps. |
| Crossbar | Rectangle 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 Plot | Box-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. |
| Contour | Draws a curve from a series of points. Used for Cook's distance contours in regression diagnostics. |
| Density 2D | 2D 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 を指定しても効果はありません。
| Geometry | x | y | color | fill | stroke | size | shape | alpha | linetype | ymin | ymax | label |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| point | R | R | • | • | • | • | • | |||||
| line | R | R | • | • | • | • | ○ | ○ | ||||
| bar | R | R | • | • | ||||||||
| area | R | R | • | • | • | |||||||
| tile | R | R | • | • | ||||||||
| step | R | R | • | • | • | • | ||||||
| ribbon | R | • | • | • | R | R | ||||||
| errorbar | R | • | • | R | R | |||||||
| crossbar | R | R | • | • | • | R | R | |||||
| boxplot | R | R | • | • | • | • | • | R | R | |||
| vline | • | • | ||||||||||
| hline | • | • | ||||||||||
| contour | R | R | • | • | ||||||||
| density2d | R | R | • | |||||||||
| text | R | R | • | • | • | R | ||||||
| label | R | R | • | • | • |
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 です。
| Geometry | Allowed positions |
|---|---|
| point | identity, dodge, jitter |
| line | identity |
| bar | identity, stack, dodge, fill |
| area | identity, stack, fill |
| tile | identity |
| step | identity |
| ribbon | identity |
| errorbar | identity, dodge, jitter |
| crossbar | identity, dodge |
| boxplot | identity, dodge |
| vline | identity |
| hline | identity |
| contour | identity |
| density2d | identity |
| text | identity |
| label | identity |
position は Geometry だけでなく Statistics とも組み合わせが検証されます。次の表に載っている Statistics は、記載された position とだけ組み合わせられます。表にない Statistics はすべての position を使えます。実際に指定できるのは Geometry 側の許容 position との共通部分で、共通部分にない position を指定すると同じく INVALID_INPUT エラーになります。stack と fill は y の値だけを積み上げ・正規化し、Boxplot stat が出力する箱とひげの値はそのまま残るため、軸の表記とグラフの内容が食い違います。Boxplot stat がこれらの position と組み合わせられないのはこのためです。
| Statistics | Allowed 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(統計変換)
| Statistics | Description |
|---|---|
| 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 Curve | Computes 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 Mean | Calculates the mean of X values. Use with vline geom to draw a vertical reference line. |
| X Median | Calculates the median of X values. Use with vline geom to draw a vertical reference line. |
| Y Mean | Calculates 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)
| Name | Type | Default | Description |
|---|---|---|---|
bins | number | 30 | Number of bins (1-100). Ignored when binwidth is specified. |
binwidth | number | — | 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. |
boundary | number | — | Position of a bin edge in X-axis units. Bins are aligned so that one edge falls on this value. |
center | number | — | Position of a bin center in X-axis units. Takes precedence over boundary. |
Time Bin (Datetime Histogram)
| Name | Type | Default | Description |
|---|---|---|---|
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)
| Name | Type | Default | Description |
|---|---|---|---|
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. |
se | boolean | true | When 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. |
span | number | 0.75 | LOESS span: fraction of points in each local neighborhood (0.1-1.0). Larger values produce smoother curves. Ignored when method is lm. |
level | number | 95 | Interval 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)
| Name | Type | Default | Description |
|---|---|---|---|
bandwidth | number | — | 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)
| Name | Type | Default | Description |
|---|---|---|---|
outputs | SummaryOutputDef[] | [{ 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'. |
complete | boolean | false | When 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)
| Name | Type | Default | Description |
|---|---|---|---|
coef | number | 1.5 | Whisker 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)
| Name | Type | Default | Description |
|---|---|---|---|
confLevel | number | 95 | Confidence 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
| Name | Type | Default | Description |
|---|---|---|---|
showReferenceLine | boolean | true | When true, draws the diagonal reference line y = x, the ROC curve of a classifier that assigns labels independently of the data. |
X Mean
| Name | Type | Default | Description |
|---|---|---|---|
label | string | 'Mean: {value}' | Label template for the reference line. {value} is replaced with the computed mean. |
X Median
| Name | Type | Default | Description |
|---|---|---|---|
label | string | 'Median: {value}' | Label template for the reference line. {value} is replaced with the computed median. |
Y Mean
| Name | Type | Default | Description |
|---|---|---|---|
offset | number | 0 | Number 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. |
label | string | 'Mean: {value}' | Label template for the reference line. {value} is replaced with the computed value. |
Cumulative Sum (Pareto)
| Name | Type | Default | Description |
|---|---|---|---|
normalize | boolean | false | When true, scales the cumulative sum so the total equals 100 (percent). |
Sort (Pareto)
| Name | Type | Default | Description |
|---|---|---|---|
order | 'ascending' | 'descending' | 'descending' | Sort direction applied to Y values. |
limit | number | — | 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)
| Name | Type | Default | Description |
|---|---|---|---|
showReferenceLine | boolean | true | When 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)
| Name | Type | Default | Description |
|---|---|---|---|
multiply | number | 1 | Multiplier applied to Y. For example, -1 flips a histogram for a population pyramid. |
add | number | 0 | Offset added after multiplication. |
Palettes(パレット)
layers[].scales の color / fill aesthetic で paletteId に指定できる値の一覧です。API での設定方法は Agent API を参照してください。
Categorical
カテゴリカル変数の色分けに使います。scaleType: 'categorical' で指定します。
| ID | Name | Colors |
|---|---|---|
midas-default | MIDAS Default | 12 |
tableau10 | Tableau 10 | 10 |
d3-category10 | D3 Category10 | 10 |
デフォルトは midas-default です。
Sequential
連続変数や順序尺度の変数に使います。scaleType: 'sequential' で指定します。
scaleType: 'categorical' と 'threshold' でも使用できます。カテゴリ数または閾値で区切られた領域数ぶんの色をパレット全域から等間隔にサンプリングします。
| ID | Name | Colors |
|---|---|---|
blues | Blues | 9 |
greens | Greens | 9 |
greys | Greys | 9 |
purples | Purples | 9 |
ylorrd | Yellow-Orange-Red | 9 |
viridis | Viridis | 10 |
plasma | Plasma | 10 |
inferno | Inferno | 10 |
magma | Magma | 10 |
デフォルトは blues です。Viridis、Plasma、Inferno、Magma は知覚的に均一で色覚多様性に配慮したパレットです。
Diverging
中心値からの乖離を両方向に表す変数に使います。scaleType: 'diverging' で指定します。
scaleType: 'threshold' でも使用できます。閾値で区切られた領域数ぶんの色をパレット全域から等間隔にサンプリングします。
| ID | Name | Colors |
|---|---|---|
rdbu | Red-Blue | 11 |
brbg | Brown-Teal | 11 |
デフォルトは rdbu です。
scaleType と paletteId の互換性
| scaleType | 使用可能な paletteId |
|---|---|
categorical | Categorical パレット + Sequential パレット |
sequential | Sequential パレットのみ |
diverging | Diverging パレットのみ |
threshold | Sequential パレット + 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)
| Key | Type | Range | Default | Description |
|---|---|---|---|---|
color | string (CSS color) | — | '#4682b4' | Point color used when no column is mapped to the color aesthetic. Any CSS color string. |
size | number | 1–20 | 5 | Point radius in pixels, used when no column is mapped to the size aesthetic. |
alpha | number | 0–1 | 0.7 | Opacity of the layer, from 0 (fully transparent) to 1 (fully opaque). |
Line
| Key | Type | Range | Default | Description |
|---|---|---|---|---|
color | string (CSS color) | — | '#4682b4' | Line color used when no column is mapped to the color aesthetic. Any CSS color string. |
strokeWidth | number | 1–5 | 2 | Line width in pixels. |
lineType | 'solid' | 'dashed' | 'dotted' | — | 'solid' | Dash pattern of the line. |
alpha | number | 0–1 | 0.9 | Opacity of the layer, from 0 (fully transparent) to 1 (fully opaque). |
Bar
| Key | Type | Range | Default | Description |
|---|---|---|---|---|
fill | string (CSS color) | — | '#4682b4' | Bar fill color used when no column is mapped to the fill aesthetic. Any CSS color string. |
width | number | 0.1–1 | 0.8 | Bar width as a fraction of the category band width. |
alpha | number | 0–1 | 0.8 | Opacity of the layer, from 0 (fully transparent) to 1 (fully opaque). |
Area
| Key | Type | Range | Default | Description |
|---|---|---|---|---|
fill | string (CSS color) | — | '#4682b4' | Fill color of the area used when no column is mapped to the fill aesthetic. Any CSS color string. |
alpha | number | 0–1 | 0.5 | Opacity of the layer, from 0 (fully transparent) to 1 (fully opaque). |
Tile (Heatmap)
| Key | Type | Range | Default | Description |
|---|---|---|---|---|
fill | string (CSS color) | — | '#cccccc' | Cell fill color used when no column is mapped to the fill aesthetic. Any CSS color string. |
stroke | string (CSS color) | — | '#ffffff' | Border color of each cell. Any CSS color string. |
strokeWidth | number | 0–5 | 0.5 | Border width of each cell in pixels. 0 draws no border. |
alpha | number | 0–1 | 1 | Opacity of the layer, from 0 (fully transparent) to 1 (fully opaque). |
Step (Kaplan-Meier)
| Key | Type | Range | Default | Description |
|---|---|---|---|---|
color | string (CSS color) | — | '#4682b4' | Line color used when no column is mapped to the color aesthetic. Any CSS color string. |
strokeWidth | number | 1–5 | 2 | Line width in pixels. |
lineType | 'solid' | 'dashed' | 'dotted' | — | 'solid' | Dash pattern of the line. |
alpha | number | 0–1 | 0.9 | Opacity of the layer, from 0 (fully transparent) to 1 (fully opaque). |
Ribbon (Confidence Band)
| Key | Type | Range | Default | Description |
|---|---|---|---|---|
fill | string (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. |
alpha | number | 0–1 | 0.2 | Opacity of the layer, from 0 (fully transparent) to 1 (fully opaque). |
Error Bar
| Key | Type | Range | Default | Description |
|---|---|---|---|---|
color | string (CSS color) | — | '#333333' | Color of the bars and caps used when no column is mapped to the color aesthetic. Any CSS color string. |
strokeWidth | number | 0.5–5 | 1.5 | Width of the bars and caps in pixels. |
capWidth | number | 0–20 | 8 | Width of the caps at ymin and ymax in pixels. 0 draws no caps. |
alpha | number | 0–1 | 0.8 | Opacity of the layer, from 0 (fully transparent) to 1 (fully opaque). |
Crossbar
| Key | Type | Range | Default | Description |
|---|---|---|---|---|
fill | string (CSS color) | — | '#4682b4' | Fill color of the rectangle used when no column is mapped to the fill aesthetic. Any CSS color string. |
stroke | string (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. |
width | number | 0.1–1 | 0.6 | Rectangle width as a fraction of the category band width. |
strokeWidth | number | 0.5–5 | 1.5 | Width of the outline and the center line in pixels. |
alpha | number | 0–1 | 0.8 | Opacity of the layer, from 0 (fully transparent) to 1 (fully opaque). |
Box Plot
| Key | Type | Range | Default | Description |
|---|---|---|---|---|
fill | string (CSS color) | — | '#4682b4' | Box fill color used when no column is mapped to the fill aesthetic. Any CSS color string. |
stroke | string (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. |
width | number | 0.1–1 | 0.6 | Box width as a fraction of the category band width. |
strokeWidth | number | 0.5–5 | 1.5 | Width of the box outline, the median line, and the whiskers in pixels. |
pointSize | number | 1–10 | 2.5 | Radius in pixels of the points drawn beyond the whiskers. |
alpha | number | 0–1 | 0.8 | Opacity of the layer, from 0 (fully transparent) to 1 (fully opaque). |
Vertical Line (Reference)
| Key | Type | Range | Default | Description |
|---|---|---|---|---|
xintercept | number | — | — | 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. |
color | string (CSS color) | — | '#888888' | Line color used when no column is mapped to the color aesthetic. Any CSS color string. |
strokeWidth | number | 1–5 | 1 | Line width in pixels. |
alpha | number | 0–1 | 0.7 | Opacity of the layer, from 0 (fully transparent) to 1 (fully opaque). |
Horizontal Line (Reference)
| Key | Type | Range | Default | Description |
|---|---|---|---|---|
yintercept | number | — | — | 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. |
color | string (CSS color) | — | '#888888' | Line color used when no column is mapped to the color aesthetic. Any CSS color string. |
strokeWidth | number | 1–5 | 1 | Line width in pixels. |
alpha | number | 0–1 | 0.7 | Opacity of the layer, from 0 (fully transparent) to 1 (fully opaque). |
Contour
| Key | Type | Range | Default | Description |
|---|---|---|---|---|
strokeWidth | number | 1–5 | 1.5 | Line width in pixels. |
lineType | 'solid' | 'dashed' | 'dotted' | — | 'solid' | Dash pattern of the line. |
color | string (CSS color) | — | '#888888' | Line color of the curve. Any CSS color string. |
alpha | number | 0–1 | 0.6 | Opacity of the layer, from 0 (fully transparent) to 1 (fully opaque). |
Density 2D
| Key | Type | Range | Default | Description |
|---|---|---|---|---|
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. |
levels | number | 2–20 | 10 | Number 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. |
alpha | number | 0–1 | 0.8 | Opacity of the layer, from 0 (fully transparent) to 1 (fully opaque). |
Text (Label)
| Key | Type | Range | Default | Description |
|---|---|---|---|---|
color | string (CSS color) | — | '#333333' | Text color used when no column is mapped to the color aesthetic. Any CSS color string. |
fontSize | number | 6–24 | 11 | Font 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. |
dx | number | -50–50 | 0 | Horizontal offset of the text from the point in pixels. |
dy | number | -50–50 | -8 | Vertical offset of the text from the point in pixels. Negative values move the text up. |
alpha | number | 0–1 | 1 | Opacity of the layer, from 0 (fully transparent) to 1 (fully opaque). |
Label (Annotation)
| Key | Type | Range | Default | Description |
|---|---|---|---|---|
color | string (CSS color) | — | '#333333' | Text color used when no column is mapped to the color aesthetic. Any CSS color string. |
fontSize | number | 6–24 | 11 | Font size in pixels. |
fontWeight | 'normal' | 'bold' | — | 'normal' | Weight of the text. |
backgroundColor | string (CSS color) | — | '#ffffff' | Background color of the text box. Any CSS color string. |
backgroundAlpha | number | 0–1 | 0.93 | Opacity of the text box background, from 0 (fully transparent) to 1 (fully opaque). |
borderColor | string (CSS color) | — | '#cccccc' | Border color of the text box. Any CSS color string. |
leaderColor | string (CSS color) | — | '#999999' | Color of the leader line from the point to the text box. Any CSS color string. |
padding | number | 0–16 | 4 | Space between the text and the edge of the text box in pixels. |
offsetDistance | number | 10–80 | 30 | Distance from the point to the text box in pixels. |
alpha | number | 0–1 | 1 | Opacity 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 出力変数を参照します。
| 変数 | 説明 |
|---|---|
$y | stat 変換後の Y 値(count、mean 等)。position が fill のレイヤーでは各 X 位置の値の絶対値合計に対する割合になり、tooltip で format を省略するとパーセント形式で表示されます |
$x | X 値(ビン中心、カテゴリ名) |
$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 オブジェクトのプロパティ:
| プロパティ | 型 | 説明 |
|---|---|---|
field | string | $ プレフィックス付き変数(上表参照)、またはカラム名かカラム ID。カラム名は大文字小文字を区別せずに解決されます |
format | string | d3-format 書式指定(省略時はデータ型から自動推定)。代表的な書式: .1f(小数1桁)、.0%(パーセント、小数なし)、,.0f(桁区切り) |
prefix | string | フォーマット値の前に付加するテキスト |
suffix | string | フォーマット値の後に付加するテキスト |
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
- 高度なグラフ作成 - Custom Graph の使い方とチュートリアル
- Graph Builder タブ - Graph Builder の基本操作
このページの Markdown 版もあります。