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

  • Home
  • SEARCH
  • 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 8612875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:44:05+00:00 2026-06-12T04:44:05+00:00

I have a really simple line chart written using NVD3.js. I’ve written a simple

  • 0

I have a really simple line chart written using NVD3.js. I’ve written a simple redraw based on timer, pulled from examples I’ve seen, but I get the error

Uncaught TypeError: Cannot read property ‘y’ of undefined

The JS is

    var data = [{
        "key": "Long",
        "values": getData()
    }];
    var chart;

    nv.addGraph(function () {
          chart = nv.models.cumulativeLineChart()
                      .x(function (d) { return d[0] })
                      .y(function (d) { return d[1] / 100 })
                      .color(d3.scale.category10().range());

        chart.xAxis
            .tickFormat(function (d) {
                return d3.time.format('%x')(new Date(d))
            });

        chart.yAxis
            .tickFormat(d3.format(',.1%'));

        d3.select('#chart svg')
            .datum(data)
            .transition().duration(500)
            .call(chart);

        nv.utils.windowResize(chart.update);

        return chart;
    });


    function redraw() {
        d3.select('#chart svg')
            .datum(data)
          .transition().duration(500)
            .call(chart);
    }

    function getData() {
        var arr = [];
        var theDate = new Date(2012, 01, 01, 0, 0, 0, 0);
        for (var x = 0; x < 30; x++) {
            arr.push([theDate.getTime(), Math.random() * 10]);
            theDate.setDate(theDate.getDate() + 1);
        }
        return arr;
    }

    setInterval(function () {
        var long = data[0].values;
        var next = new Date(long[long.length - 1][0]);
        next.setMonth(next.getMonth() + 1)
        long.shift();
        long.push([next.getTime(), Math.random() * 100]);
        redraw();
    }, 1500);
  • 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-12T04:44:06+00:00Added an answer on June 12, 2026 at 4:44 am

    Second Answer (after comment)

    I looked at source for cumulativeLineChart. You can see the display.y property get created during chart creation. It relies on a private method: “indexify”. If some derivative of that method was made public, then perhaps you could do something like chart.reindexify() before redrawing.

    As a temporary workaround, you could recreate the chart from scratch on every update. If you remove the transition, that seems to work okay. Example jsfiddle: http://jsfiddle.net/kaliatech/PGyKF/.

    First Answer

    I believe there is bug in cumulativeLineChart. It appears that the cumulativeLineChart adds a “display.y” property dynamically to data values in the series. However, it does not regenerate this property when new values are added to the series for a redraw. I don’t know of anyway to make it do this, although I’m new to NVD3.

    Do you really need a CumulativeLineChart, or would a normal line chart be sufficient? If so, I had to make the following changes to your code:

    • Change from cumulativeLineChart to lineChart
    • Change from using 2 dimension arrays of data, to using objects of data (with x,y properties)
      • (I’m not familiar enough with NVD3 to say what data formats is expects. The 2D array obviously works for initial loads, but I think it fails to work for subsequent redraws. This is likely related to the same issue you are having with cumulativeLineChart. I thought changing to objects would fix cumulativeLineChart as well, but it didn’t seem to.)

    I also changed the following, although not as important:

    • Modified your getData function to create a new instance of Date to avoid unexpected consequences of sharing a reference as the date gets incremented.

    • Modified the update interval function to generate new data in increments of days (not months) with y values in the same range as the getData function.

    Here’s a working jsfiddle with those changes:

    • http://jsfiddle.net/kaliatech/4TMMD/
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have really simple XML (HTML) parsing ANTLR grammar: wiki: ggg+; ggg: tag |
I have a really simple XML file that I'm trying to read, but I
I have a really simple Rails app. Basically an article with comments. I want
I have a really simple blog application and I want to add a really
I have a really simple mod-rewrite rule : RewriteRule ^(.*)$ index.php?url=$1 [PT,L] As an
I have a really simple table with two rows and two columns. I want
A really simple shell script question. I have a file with something like this:
I have what is probably a really simple, studid question but I can't find
hey guys having this really simple problem but cant seem to figure out have
Probably something really simple, but I'm having some real trouble with it. I have

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.