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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:30:34+00:00 2026-05-12T14:30:34+00:00

I have a setup where I am using amcharts that is feed data via

  • 0

I have a setup where I am using amcharts that is feed data via appendData from an AJAX call. The call goes to a URL which simply renders the Time.now as the X and 8 lines using the function 2cos(x/2)+2ln (ln is the line number). AJAX request is made every 1 second.

The backend is always correct and always returns a single point, unless it is a duplicate X in which it throws an error. The error causes not to complete and therefore not call appendData.

Anybody have any idea what is going wrong with amcharts? It seems to be an issue only with appendData (which I need to simulate a sliding window).

The Javascript code is below. It assumes that the page creates a line chart with 8 points graphs and passes it to setup_chart_loader. Netcordia.rapid_poller.updateChart is used to update the chart using the Ajax request

Ext.ns("Netcordia.rapid_poller");

Netcordia.rapid_poller.refresh_rate = 1; //seconds
Netcordia.rapid_poller.pause = false; //causes the AJAX to suspend
Netcordia.rapid_poller.chart = null;
Netcordia.rapid_poller.stop = false;

/* This function does everything that is required to get the chart data correct */
Netcordia.rapid_poller.setup_chart_loader = function(chart){
  assert(Netcordia.rapid_poller.displaySizeInMinutes,"No display size");
  assert(Netcordia.rapid_poller.delta_url, "Data URL is empty");
  assert(Netcordia.rapid_poller.delta_params, "No Data params");

  if(typeof(chart) !== 'object'){
    chart = document.getElementById(chart);
  }

  Netcordia.rapid_poller.chart = chart;

  // 5 seconds raw polling
  var maxPoints = Netcordia.rapid_poller.displaySizeInMinutes * 60 / 5;
  var count = 0;
  var lastUpdate = '';

  debug("max number of points: "+maxPoints);

  debug('creating updateChart function');
  Netcordia.rapid_poller.updateChart = function(){
    debug("Sending Data request");
    var params = {last: lastUpdate, max: 1}; //maxPoints};
    //I have to do this otherwise amcharts get a lot of data and only renders
    // one item, then the counts is off
    if(lastUpdate === ''){params['max'] = maxPoints;}
    if (Netcordia.rapid_poller.pause){
      alert("pausing");
      params['historical'] = 1;
      params['max'] = maxPoints;
    }
    Ext.apply(params, Netcordia.rapid_poller.delta_params);

    //this might need to be moved to within the Ajax request
    // incase things start piling up
    if(!Netcordia.rapid_poller.stop){
      setTimeout(Netcordia.rapid_poller.updateChart,1000*Netcordia.rapid_poller.refresh_rate);
    } else {
      debug("skipping next poll");
      return;
    }

    Ext.Ajax.request({
      url: Netcordia.rapid_poller.delta_url,
      baseParams: Netcordia.rapid_poller.delta_params,
      params: params,
      success: function(response){
        //if(Netcordia.rapid_poller.pause){
        //  debug("Data stopped");
        //  return;
        //}

        var json = Ext.util.JSON.decode(response.responseText);
        lastUpdate = json.lastUpdate;

        if( json.count === 0 ){
          debug("no data to append");
          return;
        }

        debug("appending "+json.count);

        var remove = (count + json.count) - maxPoints;
        if(remove <= 0){ remove = 0; }
        count += json.count;
        if(count > maxPoints){ count = maxPoints; }

        debug("removing "+remove);
        debug("count: "+count);

        if(Netcordia.rapid_poller.pause){
          alert("Pausing for historical");
          //append a zero point and delete the existing data
          // amcharts can leak extra points onto the screen so deleting
          // twice the number is 
          chart.appendData("00:00:00;0;0;0;0;0;0;0;0",(count*2).toString());
          count = json.count;
          remove = 1;
          Netcordia.rapid_poller.stop = true;
        }

        chart.appendData(json.lines.toString(),remove.toString());
      }
    });
  };
};

The rails code that returns the data is as follows:

def get_delta
  max = 1
  begin
    current = Time.parse(params[:last])
  rescue
    current = Time.now
  end

  if params[:historical]
    max     = params[:max].to_i || 10
    current = Time.at(current.to_i - (max/2))
  end

  logger.info(current.to_i)
  logger.info(max)

  n = current.to_i
  m = n+max-1

  data = (n..m).collect do |x|
    logger.info "For Point: #{x}"
    point = Math.cos(x/2)
    data = [Time.at(x).strftime("%H:%M:%S")]
    for i in (1..8)
      data.push(2*point+(2*i));
    end
    data.join(";")
  end

  render :json => {count: data.size, lastUpdate: Time.now.strftime('%Y-%m-%d %H:%M:%S'), lines: data.join("\n")}
end

alt text

  • 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-12T14:30:34+00:00Added an answer on May 12, 2026 at 2:30 pm

    Seems to be a bug in Amcharts itself.

    Forum Post has the developer’s answer.

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

Sidebar

Related Questions

I have an OData Service setup using WCF Data Services (v2) that is hosted
I have setup a UITableView using a NSFetchedResultsController that displays a number of prototype
I have the following setup using Core Data: Nib1: A WindowController with two custom
I have setup an NSURLConnection using the guidelines in Using NSURLConnection from the Mac
We have a wcf pub/sub setup using reliable sessions via netTcpBinding and on one
I have setup an android test project that runs junit tests. It's using two
I have created a setup project using Visual Studio 2008. After the application is
I have a datepicker control setup using the JQuery UI, I am also using
I have a small tabbed navigation setup using CSS. When hovering over the tabs
Setup : Using PowerBuilder 6.5. I have a composite report (with a report header)

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.