Holoviz Panel: Now The Best Static Site Generator

Just discovered I can update ECharts without a live kernel: https://dapper-kitten-77a3f8.netlify.app/

import inspect
import panel as pn
pn.extension('echarts')

def create_panel():

    import pscript
    import js2py
    Math = js2py.eval_js('Math')

    def sin_array(arr, q):
        return [3 * Math.sin(q*i) for i in arr]

    xs = [i for i in range(0,100)]

    ys = sin_array(xs, 1)

    echart = {
        'title': {
            'text': 'ECharts entry example'
        },
        'tooltip': {},
        'legend': {
            'data':['Sales']
        },
        'xAxis': {
            'data': xs
        },
        'yAxis': {},
        'series': [{
            'name': 'Sales',
            'type': 'line',
            'data': ys
        }],
    };

    slider = pn.widgets.FloatSlider(name='Line Width', start=0.001, step = 0.001, end=10, format='1[.]000')

    sin_array_js = pscript.py2js(sin_array)

    echart_pane = pn.pane.ECharts(echart, height=480, width=640)

    slider.jscallback(args={'ech': echart_pane}, value= sin_array_js + """
    //console.log(ech.data.xAxis.data);
    ech.data.series[0].data= sin_array(ech.data.xAxis.data, cb_obj.value)
    ech.properties.data.change.emit()
    """)
    return pn.Column(slider, echart_pane)

pn.Column(
pn.pane.Markdown('''
# Holoviz Panel Static Site Generator

I love Panel, but sometimes I don't have a live kernel (and Pyodide is overkill).

___
'''),
create_panel,
pn.pane.Markdown(f'''
``python\n
{inspect.getsource(create_panel)}\n
``
'', width = 800
)
).save('index.html')

(change double ticks to triple ticks in the code to make it work)

3 Likes

Thanks for sharing @riziles . I also think that the ability to create static, but interactive reports is a super power of Panel. I see many users of alternative frameworks asking for this feature, but not getting it. They don’t know you can do this with Panel.

It would be nice to have some examples in our Gallery one day of some nicely styled examples that looks like company reports etc.

I took it for a spin

script2.py (1.7 KB)

static-site-online

1 Like

@riziles @Marc,

I totally agree, before I found panel and all, this is what I generally used bokeh to do, send small interactive data snippets that end user required nothing else than their browser to explore. As my data sets got larger I edged away but this is great to see and come back to attention.

1 Like

Agreed, for big datasets, I love a Python kernel to pull and manipulate data and run complex calculations. But deploying static sites is so fast and easy nowadays. Literally deployed from GitHub to live Vercel app in under 2 seconds.

… whoops. I mean Netlify, not Vercel. No offense to either service…