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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:04:50+00:00 2026-06-15T17:04:50+00:00

I have a Google Chart’s ColumnChart in a Rails project. This is generated and

  • 0

I have a Google Chart’s ColumnChart in a Rails project. This is generated and populated in JavaScript, by calling a Rails controller action which renders JSON.

The chart displays a month’s worth of information for a customer.

Above the chart I have next and previous arrows which allow a customer to change the month displayed on the chart. These don’t have any functionality as it stands.

My question is, what is the best way to save the state of the chart, in terms of it’s current month for a customer viewing the chart.

Here is how the I was thinking of doing the workflow:

  1. One of the arrows is selected.
  2. This event is captured in JavaScript.
  3. Another request to the Rails action rendering JSON is performed with an additional GET parameter
    passed, based on an data attribute of the arrow button (Either + or – ).
  4. The chart is re-rendered using the new JSON response.

Would the logic around incrementing or decrementing the graphs current date be performed on the server side? With the chart’s date being stored in a session array defaulting to the current date on first load?

On the other hand would it make sense to save the chart state on the client side within the JavaScript code or in cookie, then manipulate the date before it’s sent to the Rails controller?

I’ve been developing with Rails for about 6 months and feel comfortable with it, but have only just recently started developing with JavaScript, using AJAX. My experience tying JS code together with Rails is some what limited at this point, so looking for some advice/best practices about how to approach this.

Any advice is much appreciated.

  • 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-06-15T17:04:51+00:00Added an answer on June 15, 2026 at 5:04 pm

    I’m going to go through a couple of options, some good, some bad.

    First, what you definitely don’t want to do is maintain any notion of what month you are in in cookies or any other form of persistent server-side storage. Certainly sometimes server state is necessary, but it shouldn’t be used when their are easy alternatives. Part of REST (which Rails is largely built around) is trying to represent data in pure attributes rather than letting it’s state be spread around like that.

    From here, most solutions are probably acceptable, and opinion plays a greater role. One thing you could do is calculate a month from the +/- sign using the current month and send that to the server, which will return the information for the month requested.

    I’m not a huge fan of this though, as you have to write javascript that’s capable of creating valid date ranges, and most of this functionality will probably be on the server already. Just passing a +/- and the current month to the server will work as well, you’ll just have to do a bit of additional routing and logic to resolve the sign on the server to a different month.

    While either of these would work, my preferred solution would instead have the initial request for the month generate valid representations of the neighbouring months, and returning this to the client. Then, when you update the graph with the requested data, you also replace the forward/backward links on the graph with the ones provided by the server. This provides a nice fusion of the benefits of the prior two solutions – no additional routing on the server, and no substantive addition to the client-side code. Also, you have the added benefit of being able to grey out transitions to months where no data was collected from the client (i.e. before they were a customer and the future). Without this, you’d have to create separate logic to handle client requests for information that doesn’t exist, which is extra work for you and more confusion for the customer.

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

Sidebar

Related Questions

Hello I have a Google Visualisation Line chart like this... <script type=text/javascript src=https://www.google.com/jsapi></script> <script
I have two issues in this google chart. I want to either get rid
For example we have this line chart at Google Code API there is a
I have a chart generated from Google Charts that can be found here: Chart
I am working on a project which have some charts (graphs), tick chart, candlestick
I have this Google Bar Chart: function drawChart() { var data = new google.visualization.DataTable();
I using the Google Chart for in my HTML5 Project. which takes the JSON
I have setup a simple Google Chart by following the example on this page:
I am trying to center align my google chart but have been unsuccessful in
In the old static image Google charts I have been producing a combined chart

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.