Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""
2### `lightbox`
4"""
7from lcdoc.tools import app lp|features/lp/plugs/chart/index.md
9page_assets = {'header': '//cdn.jsdelivr.net/npm/chart.js'} lp|features/lp/plugs/chart/index.md
12C = '''<div>
13<canvas id="%(id)s"></canvas>
14</div>'''
16S = '''
17<script>
18%(body)s
19var myChart = new Chart(
20 document.getElementById('%(id)s'),
21 config
22 );
23</script>
24'''
27def run(cmd, kw): lp|features/lp/plugs/chart/index.md
28 if isinstance(cmd, str): lp|features/lp/plugs/chart/index.mdlp|features/lp/plugs/chart/index.md
29 kw['body'] = cmd lp|features/lp/plugs/chart/index.md
30 else:
31 kw['body'] = 'var config = %s;' % str(cmd) lp|features/lp/plugs/chart/index.md
32 js = S % kw lp|features/lp/plugs/chart/index.mdlp|features/lp/plugs/chart/index.md
33 div = C % kw lp|features/lp/plugs/chart/index.mdlp|features/lp/plugs/chart/index.md
34 return {'res': div, 'formatted': True, 'footer': js} lp|features/lp/plugs/chart/index.mdlp|features/lp/plugs/chart/index.md