Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6994005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:50:12+00:00 2026-05-27T19:50:12+00:00

Rails 2.35 / Ruby 1.87 I’ve been trying jqplot . With Fusion Charts, I

  • 0

Rails 2.35 / Ruby 1.87

I’ve been trying jqplot.

With Fusion Charts, I was always using the builder files which rendered XML for the view . With jqPlot, if I can simply build a data string and insert it into the JavaScript that generates the graph, is there any reason to render JSON files (etc)?

Also, I couldn’t find any jqPlot Rails examples and just made something up. I was curious how what I did could have been written better (or if I did ok here).

Thanks!

  CONTROLLER
  ---------------------
 def provisioned_accounts
    sql = %Q{
          SELECT day_of, provisioned_accounts from daily_provisioned_accounts_rollup
          }
    graph_data = DailyProvisionedAccountsRollup.find_by_sql(sql)

    @graph_data = ''
    x = 0
    graph_data.each do |g|
      x += 1
      if x == 1
        @graph_data += "['" + g.day_of.to_s + "', "  + g.provisioned_accounts.to_s + "]"
      else
        @graph_data += ", ['" + g.day_of.to_s + "', "  + g.provisioned_accounts.to_s + "]"
      end
    end
  end

  VIEW
  ---------
  <div id="chart1" style="height:300px; width:800px;"></div>

  <script type="text/javascript">
    $(document).ready(function(){
      var line1=[<%= @graph_data %>];
      var plot1 = $.jqplot('chart1', [line1], {
          title:'Provisioned Accounts',
          axes:{
            xaxis:{
              renderer:$.jqplot.DateAxisRenderer,
              tickOptions:{
                formatString:'%b&nbsp;%#d'
              }
            },
            yaxis:{
              tickOptions:{
                formatString:'%.0f'
                }
            }
          }
      });
    });
</script>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T19:50:12+00:00Added an answer on May 27, 2026 at 7:50 pm

    There are a few things I’d do differently here.

    Move your find_by_sql into a method on DailyProvisionedAccountsRollup called something like this:

    class DailyProvisionedAccountsRollup < ActiveRecord::Base
      ...
    
      def self.summary
        all.map do |record|
          [ record.day_of, record.provisioned_accounts ]
        end
      end
    end
    

    Then, in your controller you can just do this:

    def provisioned_accounts
      @graph_data = DailyProvisionedAccountsRollup.summary
    end
    

    Finally, in your view you just use @graph_data.to_json

    <div id="chart1" style="height:300px; width:800px;"></div>
    
    <script type="text/javascript">
      $(document).ready(function(){
        var line1=<%= @graph_data.to_json %>
        var plot1 = $.jqplot('chart1', [line1], {
            title:'Provisioned Accounts',
            ...
    

    That’s all untested code, but it should get you started cleaning up your controllers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to build a free web application using ruby/rails It should be
Rails: 3.0.3 Ruby: 1.9.2 Trying to deserialize a very simple object using YAML.load or
I've been using ruby on rails for the last 4 months or so and
New to rails/ruby (using rails 3 and ruby 1.9.2), and am trying to get
I'm moving to ruby/rails from php, and one of the things I've always been
This ruby/rails construct always puzzles me: User.where(:name => Thiago).limit(3).using(:slave_one) This must execute from left-to-right,
What is the best way to generate a random DateTime in Ruby/Rails? Trying to
running: ruby 1.9.3p0 with Rails 3.2.1 Trying to use rspec but when I try
I have been creating a website with Ruby on Rails, and will be hosting
Still a rails and ruby newbie, and I'm trying to figure out why adding

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.