@@ -97,51 +97,23 @@ rm temp.json
97
97
# 9. Add BokehJS dependency
98
98
npm install ../../../../bokeh-bokehjs-3.7.0-dev.5.tgz
99
99
100
- # 10. tsconfig.json needs workaround for @bokehjs paths
101
- cat > temp.json << EOF
102
- {
103
- "compilerOptions": {
104
- "paths": {
105
- "@bokehjs/*": ["./node_modules/@bokeh/bokehjs/build/js/lib/*"]
106
- }
107
- }
108
- }
109
- EOF
110
- npx json-merger --output tsconfig.json --pretty tsconfig.json temp.json
111
- rm temp.json
112
-
113
- # 11. webpack.config.ts needs workaround to resolve @bokehjs alias
114
- # TODO: use proper ts parser to parse, add new code, write back out
115
- head -13 webpack.config.ts > temp.ts
116
- cat >> temp.ts << EOF
117
- resolve: {
118
- alias: {
119
- "@bokehjs": path.resolve(__dirname, "node_modules/@bokeh/bokehjs/build/js/lib/")
120
- }
121
- },
122
- EOF
123
- tail -9 webpack.config.ts >> temp.ts
124
- mv temp.ts webpack.config.ts
125
-
126
- # 12. Replace src/index.ts with code to create BokehJS plot
100
+ # 10. Replace src/index.ts with code to create BokehJS plot
127
101
cat > src/index.ts << EOF
128
- import { Column, ColumnDataSource, version } from "@bokehjs/bokeh";
129
- import { figure, show } from "@bokehjs/api/plotting";
130
- import { Button } from "@bokehjs/models/widgets";
102
+ import * as Bokeh from "@bokeh/bokehjs";
131
103
132
- console.info("BokehJS version:", version);
104
+ console.info("BokehJS version:", Bokeh. version);
133
105
134
106
function create_bokehjs_plot(target_id: string) {
135
- const source = new ColumnDataSource({data: { x: [0.1, 0.9], y: [0.1, 0.9], size: [40, 10] }});
107
+ const source = new Bokeh. ColumnDataSource({data: { x: [0.1, 0.9], y: [0.1, 0.9], size: [40, 10] }});
136
108
137
- const plot = figure({
109
+ const plot = Bokeh.Plotting. figure({
138
110
title: "Example BokehJS plot", height: 500, width: 500,
139
111
x_range: [0, 1], y_range: [0, 1], sizing_mode: "stretch_width",
140
112
});
141
113
142
114
plot.scatter({ field: "x" }, { field: "y" }, {source, size: { field: "size" }});
143
115
144
- const button = new Button({label: "Click me to add a point", button_type: "primary"});
116
+ const button = new Bokeh.Widgets. Button({label: "Click me to add a point", button_type: "primary"});
145
117
function button_callback() {
146
118
const data = source.data as any;
147
119
data.x.push(Math.random());
@@ -151,14 +123,14 @@ function create_bokehjs_plot(target_id: string) {
151
123
}
152
124
button.on_click(button_callback);
153
125
154
- const column = new Column({children: [plot, button], sizing_mode: "stretch_width"});
155
- show(column, target_id);
126
+ const column = new Bokeh. Column({children: [plot, button], sizing_mode: "stretch_width"});
127
+ Bokeh.Plotting. show(column, target_id);
156
128
}
157
129
158
130
create_bokehjs_plot("#target");
159
131
EOF
160
132
161
- # 13 . Rebuild and serve
133
+ # 11 . Rebuild and serve
162
134
npm install
163
135
npm run build
164
136
# npm run serve
0 commit comments