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 += " <div id=\"\#{id_}\" style=\"height:400px;width:700px; \"></div>\n <script type=\"text/javascript\">\n$(document).ready(function(){\n var line_\#{id_} = [\#{line_}];\n\n $('#\#{id_}').jqplot([line_\#{id_}], {\n title:'\#{title_}',\n seriesDefaults:{\n renderer:$.jqplot.BarRenderer,\n rendererOptions: {\n // Set the varyBarColor option to true to use different colors for each bar.\n // The default series colors are used.\n varyBarColor: true\n }\n },\n axes:{\n xaxis:{\n renderer: $.jqplot.CategoryAxisRenderer\n }\n }\n });\n});\n </script>\n ENDC\n else\n new_body << line + \"\\n\"\n end\n end\n\n doc.body = new_body\nend\n" |