Skip to content
plowdawg edited this page Jun 15, 2012 · 4 revisions

JQuery_Cheats gem uses XML parsed by a JavaScript that makes it possible to interact with the jqPlot Javascript. To start off, the JQuery_Cheats gem includes a helper method that can be loaded right into the view where you want your graph.

In order to make a pie chart make sure you need the following code in your asset pipeline:

In assets/javascript/application.js

//=require jqplot/plugins/jqplot.pieRenderer.min.js

and in assets/stylesheets/application.css

*=require jquery.jqplot.css

To load the chart into the view the code is:

<%= piechart("name","/path/to/xml") %>

replace the name and the path to where you need it.

In your controller, just make sure that you have a format.xml in your respond_to block in the action where you want your XML to be loaded.

The graph requires you to make a separate XML file for parsing, which should be the name of the action, so show would require show.xml.erb.

Some things to remember

  • All bars must be contained within
  • The entire XML must have a root of
Clone this wiki locally