Class: Mdoc::Processor::Jqplot
- Inherits:
-
Mdoc::Processor
- Object
- Mdoc::Processor
- Mdoc::Processor::Jqplot
- Defined in:
- lib/mdoc/processor/jqplot.rb
Instance Method Summary collapse
Methods inherited from Mdoc::Processor
#post_processors, #pre_processors, #repeatable?
Instance Method Details
#process!(doc) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/mdoc/processor/jqplot.rb', line 4 def process!(doc) doc..header_js_libs << './js/jquery.min.js' doc..header_js_libs << './js/jquery.jqplot.min.js' doc..header_js_libs << './js/plugins/jqplot.categoryAxisRenderer.min.js' doc..header_js_libs << './js/plugins/jqplot.barRenderer.min.js' # doc.meta.footer_js_srcs << '$(".diagram").sequenceDiagram({theme: "hand"});' new_body = '' doc.body.split("\n").each do |line| if /^\s*#jqplot_bar#(?<id_>\w+)#(?<title_>.+?)#\s*(?<line_>.+)$/ =~ line new_body += <<-ENDC <div id="#{id_}" style="height:400px;width:700px; "></div> <script type="text/javascript"> $(document).ready(function(){ var line_#{id_} = [#{line_}]; $('##{id_}').jqplot([line_#{id_}], { title:'#{title_}', seriesDefaults:{ renderer:$.jqplot.BarRenderer, rendererOptions: { // Set the varyBarColor option to true to use different colors for each bar. // The default series colors are used. varyBarColor: true } }, axes:{ xaxis:{ renderer: $.jqplot.CategoryAxisRenderer } } }); }); </script> ENDC else new_body << line + "\n" end end doc.body = new_body end |