92 lines
2.4 KiBLFS
HTML
92 lines
2.4 KiBLFS
HTML
<html>
|
|
<head>
|
|
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-2.4.2.js"></script>
|
|
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.4.2.min.js"></script>
|
|
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.4.2.min.js"></script>
|
|
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@holoviz/panel@0.13.0-rc.10/dist/panel.min.js"></script>
|
|
|
|
<link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" />
|
|
<script defer src="https://pyscript.net/alpha/pyscript.js"></script>
|
|
</head>
|
|
<body> <py-script>
|
|
import sys
|
|
print(sys.version)
|
|
print('Hello, World!')
|
|
for i in range(5):
|
|
print(i)
|
|
</py-script>
|
|
</py-script>
|
|
<py-env>
|
|
- bokeh
|
|
- numpy
|
|
- panel==0.13.1a2
|
|
</py-env>
|
|
<h1>Panel Example</h1>
|
|
<div id="myplot"></div>
|
|
<py-script>
|
|
import asyncio
|
|
import panel as pn
|
|
|
|
slider = pn.widgets.FloatSlider(start=0, end=10, name='Amplitude')
|
|
|
|
def callback(new):
|
|
return f'Amplitude is: {new}'
|
|
|
|
row = pn.Row(slider, pn.bind(callback, slider))
|
|
|
|
await pn.io.pyodide.show(row, 'myplot')
|
|
</py-script>
|
|
</py-script>
|
|
<py-env>
|
|
- altair
|
|
- pandas
|
|
- vega_datasets
|
|
</py-env>
|
|
|
|
<div id="altair" style="width: 100%; height: 100%"></div>
|
|
<py-script output="altair">
|
|
import altair as alt
|
|
from vega_datasets import data
|
|
|
|
source = data.movies.url
|
|
|
|
pts = alt.selection(type="single", encodings=['x'])
|
|
|
|
rect = alt.Chart(data.movies.url).mark_rect().encode(
|
|
alt.X('IMDB_Rating:Q', bin=True),
|
|
alt.Y('Rotten_Tomatoes_Rating:Q', bin=True),
|
|
alt.Color('count()',
|
|
scale=alt.Scale(scheme='greenblue'),
|
|
legend=alt.Legend(title='Total Records')
|
|
)
|
|
)
|
|
|
|
circ = rect.mark_point().encode(
|
|
alt.ColorValue('grey'),
|
|
alt.Size('count()',
|
|
legend=alt.Legend(title='Records in Selection')
|
|
)
|
|
).transform_filter(
|
|
pts
|
|
)
|
|
|
|
bar = alt.Chart(source).mark_bar().encode(
|
|
x='Major_Genre:N',
|
|
y='count()',
|
|
color=alt.condition(pts, alt.ColorValue("steelblue"), alt.ColorValue("grey"))
|
|
).properties(
|
|
width=550,
|
|
height=200
|
|
).add_selection(pts)
|
|
|
|
alt.vconcat(
|
|
rect + circ,
|
|
bar
|
|
).resolve_legend(
|
|
color="independent",
|
|
size="independent"
|
|
)
|
|
</py-script>
|
|
|
|
|
|
</html> |