@rtemis/draw 0.1.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -0
- package/dist/charts/bar/config.d.ts +64 -0
- package/dist/charts/bar/config.d.ts.map +1 -0
- package/dist/charts/bar/config.js +172 -0
- package/dist/charts/bar/config.js.map +1 -0
- package/dist/charts/bar/index.d.ts +3 -0
- package/dist/charts/bar/index.d.ts.map +1 -0
- package/dist/charts/bar/index.js +2 -0
- package/dist/charts/bar/index.js.map +1 -0
- package/dist/charts/line/config.d.ts +104 -0
- package/dist/charts/line/config.d.ts.map +1 -0
- package/dist/charts/line/config.js +372 -0
- package/dist/charts/line/config.js.map +1 -0
- package/dist/charts/line/index.d.ts +3 -0
- package/dist/charts/line/index.d.ts.map +1 -0
- package/dist/charts/line/index.js +2 -0
- package/dist/charts/line/index.js.map +1 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -1
- package/dist/rtemis-draw-builders.cjs +832 -2
- package/dist/shared/format.d.ts +14 -0
- package/dist/shared/format.d.ts.map +1 -0
- package/dist/shared/format.js +27 -0
- package/dist/shared/format.js.map +1 -0
- package/dist/shared/labels.d.ts +21 -0
- package/dist/shared/labels.d.ts.map +1 -0
- package/dist/shared/labels.js +31 -0
- package/dist/shared/labels.js.map +1 -0
- package/dist/shared/layout.d.ts +29 -0
- package/dist/shared/layout.d.ts.map +1 -0
- package/dist/shared/layout.js +59 -0
- package/dist/shared/layout.js.map +1 -0
- package/dist/shared/legend.d.ts +14 -0
- package/dist/shared/legend.d.ts.map +1 -0
- package/dist/shared/legend.js +2 -0
- package/dist/shared/legend.js.map +1 -0
- package/dist/shared/limits.d.ts +32 -0
- package/dist/shared/limits.d.ts.map +1 -0
- package/dist/shared/limits.js +62 -0
- package/dist/shared/limits.js.map +1 -0
- package/dist/shared/source.d.ts +57 -0
- package/dist/shared/source.d.ts.map +1 -0
- package/dist/shared/source.js +71 -0
- package/dist/shared/source.js.map +1 -0
- package/dist/theme/tokens.d.ts +76 -0
- package/dist/theme/tokens.d.ts.map +1 -0
- package/dist/theme/tokens.js +207 -0
- package/dist/theme/tokens.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -27,11 +27,23 @@ const option = builders.a3(a3Document, config)
|
|
|
27
27
|
| Type | Builder | Data | Config schema |
|
|
28
28
|
|---|---|---|---|
|
|
29
29
|
| `a3` | `buildA3Option(document, config, appearance)` | an A3 document (`@rtemis/a3` `A3Data`) | `https://schema.rtemis.org/chart/a3/v1/schema.json` |
|
|
30
|
+
| `bar` | `buildBarOption(data, config, appearance)` | tabular data, `{columns, levels, types}` | `https://schema.rtemis.org/chart/bar/v1/schema.json` |
|
|
31
|
+
| `line` | `buildLineOption(data, config, appearance)` | tabular data, `{columns, levels, types}` | `https://schema.rtemis.org/chart/line/v1/schema.json` |
|
|
32
|
+
|
|
33
|
+
Tabular data holds the columns the config binds, each an array or typed array, optionally the level order of categorical columns, and optionally the type of a column whose values are not read as stored: `"time"` declares a date or date-time column, held as epoch milliseconds of its wall-clock reading in UTC or as ISO 8601 text, whose offset is ignored. A bar chart labels a time category by its date, or its date and time. `frequency` names a column holding the number of rows each row stands for, when the host has combined rows. A bar chart draws one bar per row; with `group`, one bar per distinct category and group, in level order. When `group` or `aggregate` is set, the data must hold one row per category and group: the host combines rows as `aggregate` says (rtemislive in DuckDB, rtemis.draw in R) before building. With `y` unset, each bar is the number of rows of its category and group: the sum of the `frequency` column, or one per row. `barValueLabel(config, name)` gives the value axis name a host derives when the author sets none: "Count" with `y` unset; for one `y` column its name, as "Mean X", "Median X", or "Sum of X" under an aggregate.
|
|
30
34
|
|
|
31
35
|
`appearance` holds what every chart type shares and the config does not: the light or dark theme, the font family, the title inset, the legend gap, and animation. Every member of `config` and `appearance` is optional.
|
|
32
36
|
|
|
37
|
+
A line chart draws one line per `y` column, or per `y` column and group, through the rows in data order: a numeric `x` gets a value axis, a time `x` a time axis in UTC, and any other `x` a category axis. Unset axis limits extend the data range by `pad` on each side, as rtemis.draw's `resolve()` derives them; a stacked chart's y range is that of the sums.
|
|
38
|
+
|
|
39
|
+
`lineAspect(option, config)` returns the ratio and pixel margins of the plotting box a host fits for a line chart with `square` or `equal_axes`; `aspectHints` maps each chart type that has such a box to its function.
|
|
40
|
+
|
|
33
41
|
`a3SurfaceHints(document, config, appearance)` returns the height that keeps the layout's row spacing, the plot body height, and the glyph sizes, for a renderer that sizes its surface before drawing.
|
|
34
42
|
|
|
43
|
+
## Themes
|
|
44
|
+
|
|
45
|
+
`themeOption(tokens)` projects a theme's tokens (fonts, text sizes, surface colors, the palette, sign colors, axis colors, and gridline colors) to the ECharts theme object a host registers with `echarts.registerTheme()` or `chart.setTheme()`. `lightThemeTokens()` and `darkThemeTokens()` give rtemis.draw's light and dark themes, whose projections equal the objects `theme_light()` and `theme_dark()` register. Builders write no path the theme owns.
|
|
46
|
+
|
|
35
47
|
## In rtemis.draw
|
|
36
48
|
|
|
37
49
|
rtemis.draw ships the builders as one script, `r/inst/htmlwidgets/lib/draw/rtemis-draw-builders.js`, which defines the global `RtemisDraw` in a browser and is a CommonJS module in Node.js. The `rtemis-draw` widget declares it as a dependency and builds the option of a `BuildRequest` with it; `save_drawing()` builds the same request in Node.js. From the repository root:
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { type MarginMembers } from "../../shared/layout.ts";
|
|
2
|
+
import type { LegendMembers } from "../../shared/legend.ts";
|
|
3
|
+
import { type ColumnNames, type TabularData } from "../../shared/source.ts";
|
|
4
|
+
/**
|
|
5
|
+
* An instance of the `chart/bar/v1` schema, written by rtemis.draw's
|
|
6
|
+
* `BarConfig` class. Every member is optional. spec: draw/shared-builders#bar
|
|
7
|
+
*/
|
|
8
|
+
export interface BarChartConfig extends MarginMembers, LegendMembers {
|
|
9
|
+
readonly type?: "bar";
|
|
10
|
+
/** Column holding the categories. */
|
|
11
|
+
readonly x?: string | null;
|
|
12
|
+
/**
|
|
13
|
+
* Columns holding the values, one series each. Unset, each bar is the
|
|
14
|
+
* number of rows of its category and group.
|
|
15
|
+
*/
|
|
16
|
+
readonly y?: ColumnNames | null;
|
|
17
|
+
/** Column whose values split each value column into one series per group. */
|
|
18
|
+
readonly group?: string | null;
|
|
19
|
+
/**
|
|
20
|
+
* How the `y` values of rows sharing a category and group combine into one
|
|
21
|
+
* bar. The host applies it to the data before building (rtemislive in
|
|
22
|
+
* DuckDB, rtemis.draw in R); the builder requires one row per category and
|
|
23
|
+
* group when it is set, and a `y`. Default `"none"`: one bar per row.
|
|
24
|
+
*/
|
|
25
|
+
readonly aggregate?: "none" | "sum" | "mean" | "median";
|
|
26
|
+
/** Category order by total value across series. Default `"input"`. */
|
|
27
|
+
readonly order?: "input" | "increasing" | "decreasing";
|
|
28
|
+
/** Stack the series instead of grouping them. Default `false`. */
|
|
29
|
+
readonly stack?: boolean;
|
|
30
|
+
/** Draw the bars horizontally. Default `false`. */
|
|
31
|
+
readonly horizontal?: boolean;
|
|
32
|
+
/** A slider, Shift+wheel zoom, and drag panning on the category axis. Default `false`. */
|
|
33
|
+
readonly zoom?: boolean;
|
|
34
|
+
/** Bar thickness in pixels; unset uses automatic category spacing. */
|
|
35
|
+
readonly bar_width?: number | null;
|
|
36
|
+
/** Series colors, or bar colors for one series; unset uses the theme palette. */
|
|
37
|
+
readonly palette?: ColumnNames | null;
|
|
38
|
+
/** Value axis limits, `[min, max]`; unset fits the data. */
|
|
39
|
+
readonly ylim?: readonly [number, number] | null;
|
|
40
|
+
/** Bottom axis name; unset draws none. */
|
|
41
|
+
readonly xlab?: string | null;
|
|
42
|
+
/** Left axis name; unset draws none. */
|
|
43
|
+
readonly ylab?: string | null;
|
|
44
|
+
/** Chart title. */
|
|
45
|
+
readonly title?: string | null;
|
|
46
|
+
}
|
|
47
|
+
/** What is not chart config: animation. */
|
|
48
|
+
export interface BarAppearance {
|
|
49
|
+
/** Animate the first render and updates; unset leaves the ECharts default. */
|
|
50
|
+
readonly animation?: boolean;
|
|
51
|
+
}
|
|
52
|
+
/** Every member of {@link BarChartConfig}, checked against `chart/bar/v1`. */
|
|
53
|
+
export declare const BAR_CHART_CONFIG_MEMBERS: readonly ["type", "x", "y", "group", "aggregate", "order", "stack", "horizontal", "zoom", "bar_width", "palette", "ylim", "xlab", "ylab", "title", "margin_top", "margin_right", "margin_bottom", "margin_left", "legend_position", "legend_placement", "legend_title"];
|
|
54
|
+
/**
|
|
55
|
+
* Build the ECharts option of a bar chart from tabular data and its
|
|
56
|
+
* `chart/bar/v1` config. One bar per row and series, each category once;
|
|
57
|
+
* with `group`, the categories are the distinct `x` values and each group adds a series per
|
|
58
|
+
* value column, empty where a category lacks the group. With `y` unset, each
|
|
59
|
+
* bar is the number of rows of its category and group: the sum of the data's
|
|
60
|
+
* `frequency` column, or one per row. Distinct categories and groups follow
|
|
61
|
+
* their column's levels, then order of appearance.
|
|
62
|
+
*/
|
|
63
|
+
export declare function buildBarOption(data: TabularData, config: BarChartConfig, appearance?: BarAppearance): Record<string, unknown>;
|
|
64
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/charts/bar/config.ts"],"names":[],"mappings":"AACA,OAAO,EAA2B,KAAK,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACrF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAEL,KAAK,WAAW,EAIhB,KAAK,WAAW,EAEjB,MAAM,wBAAwB,CAAC;AAEhC;;;GAGG;AACH,MAAM,WAAW,cAAe,SAAQ,aAAa,EAAE,aAAa;IAClE,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC;IACtB,qCAAqC;IACrC,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B;;;OAGG;IACH,QAAQ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AAE,WAAW,EACjB,MAAM,EAAE,cAAc,EACtB,UAAU,GAAE,aAAkB,GAC7B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAkHzB"}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { formatNumber } from "../../shared/format.js";
|
|
2
|
+
import { axisZoom, cartesianGrid } from "../../shared/layout.js";
|
|
3
|
+
import { asArray, column, distinct, numberOrNull, textColumn, } from "../../shared/source.js";
|
|
4
|
+
/** Every member of {@link BarChartConfig}, checked against `chart/bar/v1`. */
|
|
5
|
+
export const BAR_CHART_CONFIG_MEMBERS = Object.freeze([
|
|
6
|
+
"type",
|
|
7
|
+
"x",
|
|
8
|
+
"y",
|
|
9
|
+
"group",
|
|
10
|
+
"aggregate",
|
|
11
|
+
"order",
|
|
12
|
+
"stack",
|
|
13
|
+
"horizontal",
|
|
14
|
+
"zoom",
|
|
15
|
+
"bar_width",
|
|
16
|
+
"palette",
|
|
17
|
+
"ylim",
|
|
18
|
+
"xlab",
|
|
19
|
+
"ylab",
|
|
20
|
+
"title",
|
|
21
|
+
"margin_top",
|
|
22
|
+
"margin_right",
|
|
23
|
+
"margin_bottom",
|
|
24
|
+
"margin_left",
|
|
25
|
+
"legend_position",
|
|
26
|
+
"legend_placement",
|
|
27
|
+
"legend_title",
|
|
28
|
+
]);
|
|
29
|
+
const _everyMember = true;
|
|
30
|
+
void _everyMember;
|
|
31
|
+
/**
|
|
32
|
+
* Build the ECharts option of a bar chart from tabular data and its
|
|
33
|
+
* `chart/bar/v1` config. One bar per row and series, each category once;
|
|
34
|
+
* with `group`, the categories are the distinct `x` values and each group adds a series per
|
|
35
|
+
* value column, empty where a category lacks the group. With `y` unset, each
|
|
36
|
+
* bar is the number of rows of its category and group: the sum of the data's
|
|
37
|
+
* `frequency` column, or one per row. Distinct categories and groups follow
|
|
38
|
+
* their column's levels, then order of appearance.
|
|
39
|
+
*/
|
|
40
|
+
export function buildBarOption(data, config, appearance = {}) {
|
|
41
|
+
const source = data.columns;
|
|
42
|
+
const yColumns = asArray(config.y);
|
|
43
|
+
if (!config.x) {
|
|
44
|
+
throw new Error("A bar chart needs `x` set to draw.");
|
|
45
|
+
}
|
|
46
|
+
const xs = textColumn(data, config.x, "x");
|
|
47
|
+
const aggregate = config.aggregate ?? "none";
|
|
48
|
+
const counting = yColumns.length === 0;
|
|
49
|
+
if (counting && aggregate !== "none") {
|
|
50
|
+
throw new Error("`aggregate` combines the values of `y`, and `y` is unset: each bar counts the rows of its category.");
|
|
51
|
+
}
|
|
52
|
+
const frequency = data.frequency ? column(source, data.frequency, "frequency") : null;
|
|
53
|
+
const valuesOf = (y) => y === null
|
|
54
|
+
? xs.map((_, row) => (frequency ? numberOrNull(frequency[row]) : 1))
|
|
55
|
+
: column(source, y, "y").map(numberOrNull);
|
|
56
|
+
const measures = counting ? [null] : [...yColumns];
|
|
57
|
+
const groupValues = config.group ? textColumn(data, config.group, "group") : null;
|
|
58
|
+
// A bar is one category and group: two rows for one bar would draw two
|
|
59
|
+
// bars under one label, or keep one of them.
|
|
60
|
+
if (!counting)
|
|
61
|
+
requireOneRowPer(xs, groupValues ?? undefined);
|
|
62
|
+
let categories;
|
|
63
|
+
let series;
|
|
64
|
+
if (groupValues || counting) {
|
|
65
|
+
categories = distinct(xs, data.levels?.[config.x]);
|
|
66
|
+
const groups = groupValues
|
|
67
|
+
? distinct(groupValues, data.levels?.[config.group])
|
|
68
|
+
: [null];
|
|
69
|
+
const at = new Map(categories.map((c, i) => [c, i]));
|
|
70
|
+
series = groups.flatMap((g) => measures.map((y) => {
|
|
71
|
+
const values = valuesOf(y);
|
|
72
|
+
const cells = categories.map(() => null);
|
|
73
|
+
xs.forEach((x, row) => {
|
|
74
|
+
const i = at.get(x);
|
|
75
|
+
if (i === undefined || (groupValues && groupValues[row] !== g))
|
|
76
|
+
return;
|
|
77
|
+
const value = values[row] ?? null;
|
|
78
|
+
cells[i] = counting ? (cells[i] ?? 0) + (value ?? 0) : value;
|
|
79
|
+
});
|
|
80
|
+
const name = g !== null && groups.length > 1
|
|
81
|
+
? measures.length > 1
|
|
82
|
+
? `${y} / ${g}`
|
|
83
|
+
: g
|
|
84
|
+
: (y ?? "Count");
|
|
85
|
+
return { name, data: cells };
|
|
86
|
+
}));
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
categories = xs;
|
|
90
|
+
series = measures.map((y) => ({ name: y, data: valuesOf(y) }));
|
|
91
|
+
}
|
|
92
|
+
const permutation = order(categories, series, config.order ?? "input");
|
|
93
|
+
categories = permutation.map((i) => categories[i]);
|
|
94
|
+
series = series.map((s) => ({ ...s, data: permutation.map((i) => s.data[i] ?? null) }));
|
|
95
|
+
const palette = asArray(config.palette);
|
|
96
|
+
const stack = config.stack ? "total" : undefined;
|
|
97
|
+
const barWidth = typeof config.bar_width === "number" ? config.bar_width : undefined;
|
|
98
|
+
const builtSeries = series.map((s, i) => {
|
|
99
|
+
const single = series.length === 1;
|
|
100
|
+
const perBar = single && palette.length > 1;
|
|
101
|
+
const color = perBar ? undefined : palette.length > 0 ? palette[i % palette.length] : undefined;
|
|
102
|
+
return {
|
|
103
|
+
type: "bar",
|
|
104
|
+
...(single ? {} : { name: s.name }),
|
|
105
|
+
data: perBar
|
|
106
|
+
? s.data.map((value, j) => ({
|
|
107
|
+
value,
|
|
108
|
+
itemStyle: { color: palette[(permutation[j] ?? j) % palette.length] },
|
|
109
|
+
}))
|
|
110
|
+
: s.data,
|
|
111
|
+
...(stack ? { stack } : {}),
|
|
112
|
+
...(barWidth === undefined ? {} : { barWidth }),
|
|
113
|
+
...(color === undefined ? {} : { itemStyle: { color } }),
|
|
114
|
+
};
|
|
115
|
+
});
|
|
116
|
+
const horizontal = config.horizontal ?? false;
|
|
117
|
+
// A horizontal chart lists its categories top to bottom, in reading order.
|
|
118
|
+
const category = {
|
|
119
|
+
type: "category",
|
|
120
|
+
data: categories,
|
|
121
|
+
axisPointer: { type: "none" },
|
|
122
|
+
...(horizontal ? { inverse: true } : {}),
|
|
123
|
+
};
|
|
124
|
+
const value = {
|
|
125
|
+
type: "value",
|
|
126
|
+
...(config.ylim ? { min: config.ylim[0], max: config.ylim[1] } : {}),
|
|
127
|
+
};
|
|
128
|
+
const xAxis = horizontal ? value : category;
|
|
129
|
+
const yAxis = horizontal ? category : value;
|
|
130
|
+
if (config.xlab)
|
|
131
|
+
Object.assign(xAxis, { name: config.xlab, nameLocation: "middle" });
|
|
132
|
+
if (config.ylab)
|
|
133
|
+
Object.assign(yAxis, { name: config.ylab, nameLocation: "middle" });
|
|
134
|
+
const grid = cartesianGrid(config, Boolean(config.xlab || config.ylab));
|
|
135
|
+
const dataZoom = config.zoom ? axisZoom(horizontal ? "y" : "x", grid) : undefined;
|
|
136
|
+
return {
|
|
137
|
+
...(config.title ? { title: { text: config.title } } : {}),
|
|
138
|
+
tooltip: { trigger: "axis", valueFormatter: formatNumber },
|
|
139
|
+
...(series.length > 1 ? { legend: { data: series.map((s) => s.name) } } : {}),
|
|
140
|
+
xAxis,
|
|
141
|
+
yAxis,
|
|
142
|
+
grid,
|
|
143
|
+
...(dataZoom ? { dataZoom } : {}),
|
|
144
|
+
series: builtSeries,
|
|
145
|
+
...(appearance.animation === undefined ? {} : { animation: appearance.animation }),
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
/** The category permutation for an order: input order, or stable by total across series. */
|
|
149
|
+
function order(categories, series, how) {
|
|
150
|
+
const index = categories.map((_, i) => i);
|
|
151
|
+
if (how === "input")
|
|
152
|
+
return index;
|
|
153
|
+
const total = (i) => series.reduce((sum, s) => sum + (s.data[i] ?? 0), 0);
|
|
154
|
+
const sign = how === "increasing" ? 1 : -1;
|
|
155
|
+
return index.sort((a, b) => sign * (total(a) - total(b)) || a - b);
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Stop when two rows share a category (and group): with `group` or
|
|
159
|
+
* `aggregate` set, a bar is one category and group, combined by the host.
|
|
160
|
+
*/
|
|
161
|
+
function requireOneRowPer(xs, groups) {
|
|
162
|
+
const seen = new Set();
|
|
163
|
+
xs.forEach((x, row) => {
|
|
164
|
+
const key = groups ? `${x}\u0000${groups[row]}` : x;
|
|
165
|
+
if (seen.has(key)) {
|
|
166
|
+
const where = groups ? `category '${x}' in group '${groups[row]}'` : `category '${x}'`;
|
|
167
|
+
throw new Error(`Several rows hold ${where}. Combine them before building, as the \`aggregate\` member says (sum, mean, or median).`);
|
|
168
|
+
}
|
|
169
|
+
seen.add(key);
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/charts/bar/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAsB,MAAM,wBAAwB,CAAC;AAErF,OAAO,EACL,OAAO,EAEP,MAAM,EACN,QAAQ,EACR,YAAY,EAEZ,UAAU,GACX,MAAM,wBAAwB,CAAC;AAoDhC,8EAA8E;AAC9E,MAAM,CAAC,MAAM,wBAAwB,GAAG,MAAM,CAAC,MAAM,CAAC;IACpD,MAAM;IACN,GAAG;IACH,GAAG;IACH,OAAO;IACP,WAAW;IACX,OAAO;IACP,OAAO;IACP,YAAY;IACZ,MAAM;IACN,WAAW;IACX,SAAS;IACT,MAAM;IACN,MAAM;IACN,MAAM;IACN,OAAO;IACP,YAAY;IACZ,cAAc;IACd,eAAe;IACf,aAAa;IACb,iBAAiB;IACjB,kBAAkB;IAClB,cAAc;CACsC,CAAC,CAAC;AAGxD,MAAM,YAAY,GAA+C,IAAI,CAAC;AACtE,KAAK,YAAY,CAAC;AAOlB;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc,CAC5B,IAAiB,EACjB,MAAsB,EACtB,aAA4B,EAAE;IAE9B,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC;IAC5B,MAAM,QA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,CAAC,GAAG,CAAC,CAAC,CAAC,aAAa,CAAC,GAAG,CAAC;YACvF,MAAM,IAAI,KAAK,CACb,qBAAqB,KAAK,0FAA0F,CACrH,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAChB,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/charts/bar/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,wBAAwB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/charts/bar/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { type MarginMembers } from "../../shared/layout.ts";
|
|
2
|
+
import type { LegendMembers } from "../../shared/legend.ts";
|
|
3
|
+
import { type ColumnNames, type TabularData } from "../../shared/source.ts";
|
|
4
|
+
/** A dash pattern of a line. */
|
|
5
|
+
export type LineDash = "solid" | "dashed" | "dotted";
|
|
6
|
+
/**
|
|
7
|
+
* An instance of the `chart/line/v1` schema, written by rtemis.draw's
|
|
8
|
+
* `LineConfig` class. Every member is optional. spec: draw/shared-builders#line
|
|
9
|
+
*/
|
|
10
|
+
export interface LineChartConfig extends MarginMembers, LegendMembers {
|
|
11
|
+
readonly type?: "line";
|
|
12
|
+
/**
|
|
13
|
+
* Column along the horizontal axis. A numeric column gets a value axis, a
|
|
14
|
+
* time column a time axis, and any other a category axis.
|
|
15
|
+
*/
|
|
16
|
+
readonly x?: string | null;
|
|
17
|
+
/** Columns to plot, one line each. */
|
|
18
|
+
readonly y?: ColumnNames | null;
|
|
19
|
+
/** Column whose values split each `y` column into one line per group. */
|
|
20
|
+
readonly group?: string | null;
|
|
21
|
+
/**
|
|
22
|
+
* How the `y` values of rows sharing an x and group combine into one point.
|
|
23
|
+
* The host applies it to the data before building (rtemislive in DuckDB,
|
|
24
|
+
* rtemis.draw in R); the builder requires one row per x in each line.
|
|
25
|
+
* Default `"none"`.
|
|
26
|
+
*/
|
|
27
|
+
readonly aggregate?: "none" | "sum" | "mean" | "median";
|
|
28
|
+
/** Column whose contiguous runs shade vertical background bands. */
|
|
29
|
+
readonly blocks?: string | null;
|
|
30
|
+
/** Draw smoothed lines. Default `false`. */
|
|
31
|
+
readonly smooth?: boolean;
|
|
32
|
+
/** Fill the area under each line; unset y limits then hold zero. Default `false`. */
|
|
33
|
+
readonly area?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Show a marker at each value. Default `false`: a point with no neighbor to
|
|
36
|
+
* join keeps its marker, so no value goes undrawn.
|
|
37
|
+
*/
|
|
38
|
+
readonly points?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Stack the lines, each on the sum of those before it. Requires `area`,
|
|
41
|
+
* since the bands are what show each line's share. Default `false`.
|
|
42
|
+
*/
|
|
43
|
+
readonly stack?: boolean;
|
|
44
|
+
/** A slider, Shift+wheel zoom, and drag panning on the x axis. Default `false`. */
|
|
45
|
+
readonly zoom?: boolean;
|
|
46
|
+
/** Line colors, one per line, recycled; unset uses the theme palette. */
|
|
47
|
+
readonly palette?: ColumnNames | null;
|
|
48
|
+
/** Dash pattern of each line, recycled; unset draws solid lines. */
|
|
49
|
+
readonly line_style?: LineDash | readonly LineDash[] | null;
|
|
50
|
+
/** Band colors, one per level of `blocks`; `null` or `"transparent"` draws no band. */
|
|
51
|
+
readonly block_color?: string | readonly (string | null)[] | null;
|
|
52
|
+
/** Band opacity, `[0, 1]`. Default `0.2`. */
|
|
53
|
+
readonly block_opacity?: number;
|
|
54
|
+
/** Draw the plotting box square. The host sizes the box from {@link lineAspect}. */
|
|
55
|
+
readonly square?: boolean;
|
|
56
|
+
/** Give one data unit the same length on both axes. Requires a numeric x. */
|
|
57
|
+
readonly equal_axes?: boolean;
|
|
58
|
+
/** Fraction of the data range each axis extends by when its limits are unset. Default `0.04`. */
|
|
59
|
+
readonly pad?: number;
|
|
60
|
+
/** X axis limits, `[min, max]`; on a time axis, epoch milliseconds. Unset pads the data range. */
|
|
61
|
+
readonly xlim?: readonly [number, number] | null;
|
|
62
|
+
/** Y axis limits, `[min, max]`. Unset pads the data range. */
|
|
63
|
+
readonly ylim?: readonly [number, number] | null;
|
|
64
|
+
/** X axis name; unset draws none. */
|
|
65
|
+
readonly xlab?: string | null;
|
|
66
|
+
/** Y axis name; unset draws none. */
|
|
67
|
+
readonly ylab?: string | null;
|
|
68
|
+
/** Chart title. */
|
|
69
|
+
readonly title?: string | null;
|
|
70
|
+
}
|
|
71
|
+
/** What is not chart config: animation. */
|
|
72
|
+
export interface LineAppearance {
|
|
73
|
+
/** Animate the first render and updates; unset leaves the ECharts default. */
|
|
74
|
+
readonly animation?: boolean;
|
|
75
|
+
}
|
|
76
|
+
/** Every member of {@link LineChartConfig}, checked against `chart/line/v1`. */
|
|
77
|
+
export declare const LINE_CHART_CONFIG_MEMBERS: readonly ["type", "x", "y", "group", "aggregate", "blocks", "smooth", "area", "points", "stack", "zoom", "palette", "line_style", "block_color", "block_opacity", "square", "equal_axes", "pad", "xlim", "ylim", "xlab", "ylab", "title", "margin_top", "margin_right", "margin_bottom", "margin_left", "legend_position", "legend_placement", "legend_title"];
|
|
78
|
+
/**
|
|
79
|
+
* Build the ECharts option of a line chart from tabular data and its
|
|
80
|
+
* `chart/line/v1` config. One line per `y` column, or per `y` column and
|
|
81
|
+
* group, through the rows in data order, each line holding one row per x.
|
|
82
|
+
* A stacked line has no point where a line below it has none, since the sum
|
|
83
|
+
* there is unknown. Unset axis limits extend the data
|
|
84
|
+
* range by `pad` on each side; a stacked chart's y range is that of the sums,
|
|
85
|
+
* and a filled area's y range holds zero, unpadded on that side.
|
|
86
|
+
*/
|
|
87
|
+
export declare function buildLineOption(data: TabularData, config: LineChartConfig, appearance?: LineAppearance): Record<string, unknown>;
|
|
88
|
+
/** A fixed-aspect plotting box's ratio and the pixel margins around it. */
|
|
89
|
+
export interface AspectHint {
|
|
90
|
+
/** Height over width of the plotting box. */
|
|
91
|
+
readonly ratio: number;
|
|
92
|
+
readonly leftPx: number;
|
|
93
|
+
readonly rightPx: number;
|
|
94
|
+
readonly topPx: number;
|
|
95
|
+
readonly botPx: number;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* The plotting box a host fits for a line chart with `square` or `equal_axes`,
|
|
99
|
+
* read from its built option, or `null` without either. `square` asks for a
|
|
100
|
+
* ratio of 1; `equal_axes` for the y span over the x span, so one data unit
|
|
101
|
+
* has the same length on both axes. The host solves the box from its width.
|
|
102
|
+
*/
|
|
103
|
+
export declare function lineAspect(option: Record<string, unknown>, config: Pick<LineChartConfig, "square" | "equal_axes">): AspectHint | null;
|
|
104
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/charts/line/config.ts"],"names":[],"mappings":"AACA,OAAO,EAA2B,KAAK,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACrF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAQ5D,OAAO,EAEL,KAAK,WAAW,EAKhB,KAAK,WAAW,EAGjB,MAAM,wBAAwB,CAAC;AAEhC,gCAAgC;AAChC,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAErD;;;GAGG;AACH,MAAM,WAAW,eAAgB,SAAQ,aAAa,EAAE,aAAa;IACnE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3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