Coverage for src/lcdoc/mkdocs/lp/plugs/chart/__init__.py: 100.00%

Shortcuts 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

11 statements  

1""" 

2### `lightbox` 

3 

4""" 

5 

6 

7from lcdoc.tools import app lp|features/lp/plugs/chart/index.md

8 

9page_assets = {'header': '//cdn.jsdelivr.net/npm/chart.js'} lp|features/lp/plugs/chart/index.md

10 

11 

12C = '''<div> 

13<canvas id="%(id)s"></canvas> 

14</div>''' 

15 

16S = ''' 

17<script> 

18%(body)s 

19var myChart = new Chart( 

20 document.getElementById('%(id)s'), 

21 config 

22 ); 

23</script> 

24''' 

25 

26 

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