Skip to content

Separate out more of the bokehjs example stages #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions ci/typescript/create_vanilla_rspack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ import * as Bokeh from "@bokeh/bokehjs";

console.info("BokehJS version:", Bokeh.version);

function create_bokehjs_plot(target_id: string) {
function create_bokehjs_plot(): Bokeh.Column {
const source = new Bokeh.ColumnDataSource({data: { x: [0.1, 0.9], y: [0.1, 0.9], size: [40, 10] }});

const plot = Bokeh.Plotting.figure({
Expand All @@ -129,11 +129,10 @@ function create_bokehjs_plot(target_id: string) {
}
button.on_click(button_callback);

const column = new Bokeh.Column({children: [plot, button], sizing_mode: "stretch_width"});
Bokeh.Plotting.show(column, target_id);
return new Bokeh.Column({children: [plot, button], sizing_mode: "stretch_width"});
}

create_bokehjs_plot("#target");
Bokeh.Plotting.show(create_bokehjs_plot(), "#target");
EOF

# 11. Rebuild and serve
Expand Down
7 changes: 3 additions & 4 deletions ci/typescript/create_vanilla_vite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import * as Bokeh from "@bokeh/bokehjs";

console.info("BokehJS version:", Bokeh.version);

function create_bokehjs_plot(target_id: string) {
function create_bokehjs_plot(): Bokeh.Column {
const source = new Bokeh.ColumnDataSource({data: { x: [0.1, 0.9], y: [0.1, 0.9], size: [40, 10] }});

const plot = Bokeh.Plotting.figure({
Expand All @@ -63,13 +63,12 @@ function create_bokehjs_plot(target_id: string) {
}
button.on_click(button_callback);

const column = new Bokeh.Column({children: [plot, button], sizing_mode: "stretch_width"});
Bokeh.Plotting.show(column, target_id);
return new Bokeh.Column({children: [plot, button], sizing_mode: "stretch_width"});
}

document.querySelector<HTMLDivElement>('#app')!.innerHTML = \`<div id='target'>Hello</div>\`;

create_bokehjs_plot("#target");
Bokeh.Plotting.show(create_bokehjs_plot(), "#target");
EOF

# 8. Rebuild and serve
Expand Down
7 changes: 3 additions & 4 deletions ci/typescript/create_vanilla_webpack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ import * as Bokeh from "@bokeh/bokehjs";

console.info("BokehJS version:", Bokeh.version);

function create_bokehjs_plot(target_id: string) {
function create_bokehjs_plot(): Bokeh.Column {
const source = new Bokeh.ColumnDataSource({data: { x: [0.1, 0.9], y: [0.1, 0.9], size: [40, 10] }});

const plot = Bokeh.Plotting.figure({
Expand All @@ -130,11 +130,10 @@ function create_bokehjs_plot(target_id: string) {
}
button.on_click(button_callback);

const column = new Bokeh.Column({children: [plot, button], sizing_mode: "stretch_width"});
Bokeh.Plotting.show(column, target_id);
return new Bokeh.Column({children: [plot, button], sizing_mode: "stretch_width"});
}

create_bokehjs_plot("#target");
Bokeh.Plotting.show(create_bokehjs_plot(), "#target");
EOF

# 11. Rebuild and serve
Expand Down
10 changes: 4 additions & 6 deletions recipes/src/recipes/typescript/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ export const baseTSConfig =

export const baseTypeScriptExample = {
import: 'import * as Bokeh from "@bokeh/bokehjs";\n',
version: 'console.info("BokehJS version:", Bokeh.version);\n',
function:
`console.info("BokehJS version:", Bokeh.version);

function create_bokehjs_plot(target_id: string) {
`function create_bokehjs_plot(): Bokeh.Column {
const source = new Bokeh.ColumnDataSource({data: { x: [0.1, 0.9], y: [0.1, 0.9], size: [40, 10] }});

const plot = Bokeh.Plotting.figure({
Expand All @@ -36,9 +35,8 @@ function create_bokehjs_plot(target_id: string) {
}
button.on_click(button_callback);

const column = new Bokeh.Column({children: [plot, button], sizing_mode: "stretch_width"});
Bokeh.Plotting.show(column, target_id);
return new Bokeh.Column({children: [plot, button], sizing_mode: "stretch_width"});
}
`,
create: 'create_bokehjs_plot("#target");'
show: 'Bokeh.Plotting.show(create_bokehjs_plot(), "#target");\n'
};
3 changes: 2 additions & 1 deletion recipes/src/recipes/typescript/vanilla_rspack_recipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,9 @@ export default config;`)
'Replace contents of `src/index.ts` with code to create BokehJS plot',
'src/index.ts',
baseTypeScriptExample.import + "\n" +
baseTypeScriptExample.version + "\n" +
baseTypeScriptExample.function + "\n" +
baseTypeScriptExample.create
baseTypeScriptExample.show
));

this.add(new CommandStep(
Expand Down
3 changes: 2 additions & 1 deletion recipes/src/recipes/typescript/vanilla_vite_recipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ export class VanillaViteRecipe extends Recipe {
'Replace `src/main.ts` with a simple hello example',
'src/main.ts',
baseTypeScriptExample.import + "\n" +
baseTypeScriptExample.version + "\n" +
baseTypeScriptExample.function + "\n" +
"document.querySelector<HTMLDivElement>('#app')!.innerHTML = \\`<div id='target'>Hello</div>\\`;\n\n" +
'create_bokehjs_plot("#target");'
baseTypeScriptExample.show
));

this.add(new CommandStep(
Expand Down
3 changes: 2 additions & 1 deletion recipes/src/recipes/typescript/vanilla_webpack_recipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,9 @@ export default config;`)
'Replace contents of `src/index.ts` with code to create BokehJS plot',
'src/index.ts',
baseTypeScriptExample.import + "\n" +
baseTypeScriptExample.version + "\n" +
baseTypeScriptExample.function + "\n" +
baseTypeScriptExample.create
baseTypeScriptExample.show
));

this.add(new CommandStep(
Expand Down
8 changes: 4 additions & 4 deletions typescript/vanilla_rspack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ This is almost identical to the vanilla webpack example, as `rspack` is designed

console.info("BokehJS version:", Bokeh.version);

function create_bokehjs_plot(target_id: string) {
function create_bokehjs_plot(): Bokeh.Column {
const source = new Bokeh.ColumnDataSource({data: { x: [0.1, 0.9], y: [0.1, 0.9], size: [40, 10] }});

const plot = Bokeh.Plotting.figure({
Expand All @@ -131,11 +131,11 @@ This is almost identical to the vanilla webpack example, as `rspack` is designed
}
button.on_click(button_callback);

const column = new Bokeh.Column({children: [plot, button], sizing_mode: "stretch_width"});
Bokeh.Plotting.show(column, target_id);
return new Bokeh.Column({children: [plot, button], sizing_mode: "stretch_width"});
}

create_bokehjs_plot("#target");
Bokeh.Plotting.show(create_bokehjs_plot(), "#target");

```

11. Rebuild and serve
Expand Down
8 changes: 4 additions & 4 deletions typescript/vanilla_vite/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Create an initial basic project using `create-vite`.

console.info("BokehJS version:", Bokeh.version);

function create_bokehjs_plot(target_id: string) {
function create_bokehjs_plot(): Bokeh.Column {
const source = new Bokeh.ColumnDataSource({data: { x: [0.1, 0.9], y: [0.1, 0.9], size: [40, 10] }});

const plot = Bokeh.Plotting.figure({
Expand All @@ -70,13 +70,13 @@ Create an initial basic project using `create-vite`.
}
button.on_click(button_callback);

const column = new Bokeh.Column({children: [plot, button], sizing_mode: "stretch_width"});
Bokeh.Plotting.show(column, target_id);
return new Bokeh.Column({children: [plot, button], sizing_mode: "stretch_width"});
}

document.querySelector<HTMLDivElement>('#app')!.innerHTML = `<div id='target'>Hello</div>`;

create_bokehjs_plot("#target");
Bokeh.Plotting.show(create_bokehjs_plot(), "#target");

```

8. Rebuild and serve
Expand Down
8 changes: 4 additions & 4 deletions typescript/vanilla_webpack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@

console.info("BokehJS version:", Bokeh.version);

function create_bokehjs_plot(target_id: string) {
function create_bokehjs_plot(): Bokeh.Column {
const source = new Bokeh.ColumnDataSource({data: { x: [0.1, 0.9], y: [0.1, 0.9], size: [40, 10] }});

const plot = Bokeh.Plotting.figure({
Expand All @@ -130,11 +130,11 @@
}
button.on_click(button_callback);

const column = new Bokeh.Column({children: [plot, button], sizing_mode: "stretch_width"});
Bokeh.Plotting.show(column, target_id);
return new Bokeh.Column({children: [plot, button], sizing_mode: "stretch_width"});
}

create_bokehjs_plot("#target");
Bokeh.Plotting.show(create_bokehjs_plot(), "#target");

```

11. Rebuild and serve
Expand Down