Skip to content

Commit c807b88

Browse files
authored
echarts (#811)
* echarts * pin [email protected] * index: true
1 parent b8945bd commit c807b88

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

docs/lib/echarts.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
index: true
3+
---
4+
5+
# Apache ECharts
6+
7+
Apache ECharts is available by default as `echarts` in Markdown. You can also import it explicitly like so:
8+
9+
```js run=false
10+
import * as echarts from "npm:echarts/dist/echarts.esm.js";
11+
```
12+
13+
To use ECharts, declare a container element with the desired dimensions, [display it](../javascript/display), and then call `echarts.init`.
14+
15+
```js echo
16+
const myChart = echarts.init(display(html`<div style="width: 600px; height:400px;"></div>`));
17+
18+
myChart.setOption({
19+
title: {
20+
text: "ECharts getting started example"
21+
},
22+
tooltip: {},
23+
xAxis: {
24+
data: ["shirt", "cardigan", "chiffon", "pants", "heels", "socks"]
25+
},
26+
yAxis: {},
27+
series: [
28+
{
29+
name: "sales",
30+
type: "bar",
31+
data: [5, 20, 36, 10, 10, 20]
32+
}
33+
]
34+
});
35+
```

src/client/stdlib/recommendedLibraries.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export const d3 = () => import("npm:d3");
55
export const dot = () => import("observablehq:stdlib/dot").then((dot) => dot.default);
66
export const duckdb = () => import("npm:@duckdb/duckdb-wasm");
77
export const DuckDBClient = () => import("observablehq:stdlib/duckdb").then((duckdb) => duckdb.DuckDBClient);
8+
export const echarts = () => import("npm:echarts/dist/echarts.esm.js");
89
export const htl = () => import("npm:htl");
910
export const html = () => import("npm:htl").then((htl) => htl.html);
1011
export const svg = () => import("npm:htl").then((htl) => htl.svg);

src/javascript/imports.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ export async function resolveNpmImport(specifier: string): Promise<string> {
346346
if (name === "@duckdb/duckdb-wasm" && !range) range = "1.28.0"; // https://github.com/duckdb/duckdb-wasm/issues/1561
347347
if (name === "apache-arrow" && !range) range = "13.0.0"; // https://github.com/observablehq/framework/issues/750
348348
if (name === "parquet-wasm" && !range) range = "0.5.0"; // https://github.com/observablehq/framework/issues/733
349+
if (name === "echarts" && !range) range = "5.4.3"; // https://github.com/observablehq/framework/pull/811
349350
try {
350351
return `https://cdn.jsdelivr.net/npm/${name}@${await resolveNpmVersion({name, range})}/${path}`;
351352
} catch {

0 commit comments

Comments
 (0)