@riebeckite/plugin-vega-lite 0.0.32 → 0.0.33
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 +15 -1
- package/README_ja.md +19 -5
- package/dist/index.d.ts +0 -2
- package/dist/index.js +2 -4
- package/dist/src/types.d.ts +2 -1
- package/package.json +4 -4
- package/style.css +0 -20
package/README.md
CHANGED
|
@@ -54,6 +54,20 @@ Put a Vega-Lite specification as JSON in the body of the code block. Both
|
|
|
54
54
|
The caption comes from the code-block `title`, or from the specification's
|
|
55
55
|
`title`.
|
|
56
56
|
|
|
57
|
+
## Live example
|
|
58
|
+
|
|
59
|
+
~~~vega-lite
|
|
60
|
+
{
|
|
61
|
+
"title": "Revenue",
|
|
62
|
+
"data": { "values": [{ "category": "A", "value": 28 }, { "category": "B", "value": 55 }] },
|
|
63
|
+
"mark": "bar",
|
|
64
|
+
"encoding": {
|
|
65
|
+
"x": { "field": "category", "type": "nominal" },
|
|
66
|
+
"y": { "field": "value", "type": "quantitative" }
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
~~~
|
|
70
|
+
|
|
57
71
|
## How it renders
|
|
58
72
|
|
|
59
73
|
A ` ```vega-lite ` block becomes a `figure.rb-vega-lite`:
|
|
@@ -110,7 +124,7 @@ JavaScript is disabled and the spec stays readable in the fallback `details`.
|
|
|
110
124
|
|
|
111
125
|
## Main exports
|
|
112
126
|
|
|
113
|
-
- `vegaLite(options?)`: create the plugin (`
|
|
127
|
+
- `vegaLite(options?)`: create the plugin (`vegaLite` is an alias)
|
|
114
128
|
- `initVegaLite`: initialize client-side rendering
|
|
115
129
|
- Types: `VegaLiteOptions`, `VegaLiteSpec`, `VegaLiteTheme`,
|
|
116
130
|
`VegaLiteRenderer`
|
package/README_ja.md
CHANGED
|
@@ -51,7 +51,21 @@ export default defineConfig({
|
|
|
51
51
|
|
|
52
52
|
キャプションにはコードブロックの `title`、なければ仕様の `title` を使います。
|
|
53
53
|
|
|
54
|
-
##
|
|
54
|
+
## 実行例
|
|
55
|
+
|
|
56
|
+
~~~vega-lite
|
|
57
|
+
{
|
|
58
|
+
"title": "Revenue",
|
|
59
|
+
"data": { "values": [{ "category": "A", "value": 28 }, { "category": "B", "value": 55 }] },
|
|
60
|
+
"mark": "bar",
|
|
61
|
+
"encoding": {
|
|
62
|
+
"x": { "field": "category", "type": "nominal" },
|
|
63
|
+
"y": { "field": "value", "type": "quantitative" }
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
~~~
|
|
67
|
+
|
|
68
|
+
## 描画の仕組み
|
|
55
69
|
|
|
56
70
|
` ```vega-lite ` のコードブロックは `figure.rb-vega-lite` に置き換わります。
|
|
57
71
|
|
|
@@ -62,7 +76,7 @@ export default defineConfig({
|
|
|
62
76
|
|
|
63
77
|
`initVegaLite` は `[data-vega-lite]` を探し、`data-vega-lite-spec` を `JSON.parse` してから `vega`、`vega-lite`、`vega-embed` を動的インポートして `vega-embed` で描画します。描画に成功すると `data-vega-lite="rendered"` になります。
|
|
64
78
|
|
|
65
|
-
`vega-embed` の読み込み、仕様の `JSON.parse`、描画のいずれかが失敗した場合は例外を投げず、その figure の `details` を開いて元の仕様を見せます(`data-vega-lite="error"`)。
|
|
79
|
+
`vega-embed` の読み込み、仕様の `JSON.parse`、描画のいずれかが失敗した場合は例外を投げず、その `<figure>` の `details` を開いて元の仕様を見せます(`data-vega-lite="error"`)。
|
|
66
80
|
|
|
67
81
|
JSON を解析できないコードブロックは置き換えず、通常のコードブロックのまま残し、`@riebeckite/plugin-vega-lite` を `source` に持つ診断を出します。
|
|
68
82
|
|
|
@@ -74,13 +88,13 @@ JSON を解析できないコードブロックは置き換えず、通常のコ
|
|
|
74
88
|
| `actions` | `null` | `vega-embed` の操作メニューを表示する(`true` / `false` / `null`) |
|
|
75
89
|
| `theme` | `"light"` | 配色(`"light"`、`"dark"`、`"none"`) |
|
|
76
90
|
| `renderer` | `"canvas"` | Vega のレンダラー(`"canvas"` または `"svg"`) |
|
|
77
|
-
| `className` | `"rb-vega-lite"` | figure に付ける基準クラス |
|
|
91
|
+
| `className` | `"rb-vega-lite"` | `<figure>` に付ける基準クラス |
|
|
78
92
|
|
|
79
93
|
`actions` が `null` のときは `vega-embed` の既定(操作メニューあり)に従います。`theme` が `"light"` または `"none"` のときは Vega 既定の明るい配色を使い、`"dark"` のときだけ `vega-embed` の `dark` テーマを適用します。
|
|
80
94
|
|
|
81
95
|
## クライアント側の描画
|
|
82
96
|
|
|
83
|
-
クライアントの初期化コードは静的なので、プラグインのオプションは受け取りません。`actions`、`theme`、`renderer` は figure の `data-vega-lite-*` 属性に埋め込まれ、`initVegaLite` がそこから読み取ります。
|
|
97
|
+
クライアントの初期化コードは静的なので、プラグインのオプションは受け取りません。`actions`、`theme`、`renderer` は `<figure>` の `data-vega-lite-*` 属性に埋め込まれ、`initVegaLite` がそこから読み取ります。
|
|
84
98
|
|
|
85
99
|
Vega ランタイムは `import()` で動的に読み込むため、JavaScript を無効にしていてもページは表示され、仕様はフォールバックの `details` から読めます。
|
|
86
100
|
|
|
@@ -94,7 +108,7 @@ Vega ランタイムは `import()` で動的に読み込むため、JavaScript
|
|
|
94
108
|
|
|
95
109
|
## 主なエクスポート
|
|
96
110
|
|
|
97
|
-
- `vegaLite(options?)`: プラグインを作成する(`
|
|
111
|
+
- `vegaLite(options?)`: プラグインを作成する(`vegaLite` は別名)
|
|
98
112
|
- `initVegaLite`: クライアント側の描画を初期化する
|
|
99
113
|
- 型: `VegaLiteOptions`、`VegaLiteSpec`、`VegaLiteTheme`、`VegaLiteRenderer`
|
|
100
114
|
|
package/dist/index.d.ts
CHANGED
|
@@ -7,5 +7,3 @@ export type { VegaLiteOptions, VegaLiteRenderer, VegaLiteSpec, VegaLiteTheme, }
|
|
|
7
7
|
* `initVegaLite`, which imports the Vega runtime dynamically.
|
|
8
8
|
*/
|
|
9
9
|
export declare function vegaLite(options?: VegaLiteOptions): import("@riebeckite/core").RiebeckitePlugin<VegaLiteOptions>;
|
|
10
|
-
/** Alias kept for symmetry with the other plugin factories. */
|
|
11
|
-
export declare const vegaLitePlugin: typeof vegaLite;
|
package/dist/index.js
CHANGED
|
@@ -87,7 +87,7 @@ function buildFigure(input) {
|
|
|
87
87
|
);
|
|
88
88
|
}
|
|
89
89
|
children.push(
|
|
90
|
-
element("details", { className: `${base}__fallback` }, [
|
|
90
|
+
element("details", { className: `${base}__fallback rb-source-fallback` }, [
|
|
91
91
|
element("summary", {}, [text("Vega-Lite spec")]),
|
|
92
92
|
element("pre", {}, [element("code", {}, [text(input.source)])])
|
|
93
93
|
])
|
|
@@ -188,7 +188,6 @@ function vegaLite(options = {}) {
|
|
|
188
188
|
]
|
|
189
189
|
});
|
|
190
190
|
}
|
|
191
|
-
var vegaLitePlugin = vegaLite;
|
|
192
191
|
function validateVegaLiteOptions(options) {
|
|
193
192
|
if (!options) return [];
|
|
194
193
|
const issues = [];
|
|
@@ -223,6 +222,5 @@ function isRenderer(value) {
|
|
|
223
222
|
}
|
|
224
223
|
export {
|
|
225
224
|
rehypeVegaLite,
|
|
226
|
-
vegaLite
|
|
227
|
-
vegaLitePlugin
|
|
225
|
+
vegaLite
|
|
228
226
|
};
|
package/dist/src/types.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ export type TextNode = {
|
|
|
32
32
|
type: "text";
|
|
33
33
|
value: string;
|
|
34
34
|
};
|
|
35
|
-
|
|
35
|
+
type RawNode = {
|
|
36
36
|
type: "raw";
|
|
37
37
|
value: string;
|
|
38
38
|
};
|
|
@@ -40,3 +40,4 @@ export type HastNode = ElementNode | TextNode | RawNode | {
|
|
|
40
40
|
type: string;
|
|
41
41
|
[key: string]: unknown;
|
|
42
42
|
};
|
|
43
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riebeckite/plugin-vega-lite",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.33",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
"./style.css": "./style.css"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
+
"@riebeckite/core": "0.0.33",
|
|
25
|
+
"@riebeckite/diagram": "0.0.33",
|
|
24
26
|
"vega": "^6.4.0",
|
|
25
27
|
"vega-embed": "^7.3.0",
|
|
26
|
-
"vega-lite": "^6.4.3"
|
|
27
|
-
"@riebeckite/core": "0.0.32",
|
|
28
|
-
"@riebeckite/diagram": "0.0.32"
|
|
28
|
+
"vega-lite": "^6.4.3"
|
|
29
29
|
},
|
|
30
30
|
"publishConfig": {
|
|
31
31
|
"access": "public"
|
package/style.css
CHANGED
|
@@ -40,26 +40,6 @@
|
|
|
40
40
|
height: auto;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
.rb-vega-lite__fallback {
|
|
44
|
-
border-top: 1px solid var(--rb-vega-lite-rule);
|
|
45
|
-
color: var(--rb-vega-lite-muted);
|
|
46
|
-
font-size: 0.8125rem;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
.rb-vega-lite__fallback summary {
|
|
50
|
-
cursor: pointer;
|
|
51
|
-
padding: 0.5rem 0.75rem;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
.rb-vega-lite__fallback pre {
|
|
55
|
-
overflow: auto;
|
|
56
|
-
margin: 0 1rem;
|
|
57
|
-
padding: 0.75rem;
|
|
58
|
-
border-top: 1px solid var(--rb-vega-lite-rule);
|
|
59
|
-
color: var(--rb-vega-lite-ink);
|
|
60
|
-
background: color-mix(in srgb, var(--rb-vega-lite-ink) 6%, transparent);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
43
|
.rb-vega-lite[data-vega-lite="error"] .rb-vega-lite__canvas::before,
|
|
64
44
|
.rb-vega-lite[data-vega-lite="pending"] .rb-vega-lite__canvas:empty::before {
|
|
65
45
|
content: "Chart could not be rendered.";
|