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 7577927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:18:33+00:00 2026-05-30T17:18:33+00:00

i am trying to figure out how to input data values into highcharts. Firstly

  • 0

i am trying to figure out how to input data values into highcharts. Firstly i have a home object(@home) that has many energies(energy table consists of three columns, namely, consumption, home_id and consumption_date)

This is what i have so far:

<script type="text/javascript">
var chart;
$(function() {
    new Highcharts.Chart({
        chart: {
            renderTo: "consumption_chart",
        },
            title: {
            text: "Consumption - <%= @home.name %>"
        },
        xAxis: {
            type: 'datetime',
        },
        yAxis: {
            title: {
                text: "Power"
            }
        },
        series: [{
            data: <%= @data_set %>
        }]
    });
});
</script>

For the data part i get all the values like this

@data_set = @home.energies.collect{|e| e.consumption_date.utc}.zip(@home.energies.collect{|g| g.consumption})

This returns a nested set of arrays like this:

[[2012-03-02 09:06:00 UTC, 1200], [2012-04-30 00:00:00 UTC, 1145], [2012-04-30 00:00:00 UTC, 1158], [2012-05-31 00:00:00 UTC, 1145]]

Each nested array is just of the form [consumption_date, consumption]. However this does not work(chart does not render any data), please can someone point out my errors and tell me what i am doing incorrectly. thanks

  • 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-30T17:18:34+00:00Added an answer on May 30, 2026 at 5:18 pm

    Could you try to use lazy-high-chart gem? It’s easy and it will save your time when doing this.

    https://github.com/michelson/lazy_high_charts

    e.g.
    In controller,

    @h = LazyHighCharts::HighChart.new('graph') do |f|
    f.options[:chart][:defaultSeriesType] = "area"
    f.series(:name=>'John', :data=>[3, 20, 3, 5, 4, 10, 12 ,3, 5,6,7,7,80,9,9])
    f.series(:name=>'Jane', :data=> [1, 3, 4, 3, 3, 5, 4,-46,7,8,8,9,9,0,0,9] )
    end
    

    In view,

    <%= high_chart("my_id", @h) %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to figure out how to write a jquery formula that will sum all
I have a hypothetical set of data with 3 columns that has monthly profit
I am trying to unit test for data being input into a textbox (txtPrice).
Using XCode 3.2, What I'm trying to do is have the user input data
I'm trying to figure out how to read from the standard input stream of
I'm trying to figure out a way to automate posting data on this site
Trying to figure out an equation to get the current group a page would
Trying to figure out the best way to set up collection lists for users
Trying to figure out which to use.
Trying to figure out how to programmatically access the web pages in the application.

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.