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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:03:15+00:00 2026-06-09T00:03:15+00:00

I created a multiple-line chart using nvd3 , but was unable to modify it

  • 0

I created a multiple-line chart using nvd3, but was unable to modify it in some important ways. I would like to roll my own using straight d3js, but I’m struggling with thinking in joins.

I need to create a path for each d.key with its own corresponding d.values.

My data is formatted for nvd3 as follows (abridged).

[
    {
        "key":"brw-a",
        "values":[
            ["2012-07-11T00:00:00", 0.0 ],
            ["2012-07-11T23:59:59", 0.0 ],
            ["2012-07-05T06:31:47", 0.0 ],
            ["2012-07-05T23:59:59", 0.0 ]
        ]
    },
    {
        "key":"brw-c",
        "values":[
            ["2012-07-11T00:00:00", 0.0 ],
            ["2012-07-07T00:00:00", 2.0 ],
            ["2012-07-05T23:59:59", 4.0 ]
        ]
    }
]

I seem to need an inner loop to access the array stored in each d.values. I have a working example that demonstrates how d.values comes out in one big glob of uselessness.

var p = d3.select("body").selectAll("p")
        .data(data)
      .enter().append("p")
        .text(function(d) {return d.key +":  " + '[' + d.values + ']'})

I feel like I’m close, and it has something to do with:

.data(data, function(d) { return d.key; })

Update: I was able to manually loop over the data to create the desired effect. Perhaps there is not a way of doing this with joins? Save for using the wonderful nvd3 lib, of course. See the comment below for the link.

var body = d3.select("body")

for (i=0; i < data.length; i++) {
    var key = data[i].key
    var values = data[i].values

    body.append("h3")
        .text(key)

    for (j=0; j < values.length; j++) {
        body.append("p")
            .text(values[j][0] + " -- " + values[j][1])
    }

}
  • 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-09T00:03:16+00:00Added an answer on June 9, 2026 at 12:03 am

    You were right about .data() function. But because you need to loop through elements in values, that’s what you need to pass as data for a nested selection:

    .data(function(d) { return d.values})
    

    You could try this:

    var p = d3.select("body").selectAll("p")
            .data(data)
          .enter().append("p")
            .attr("id", function(d) { return d.key})
            .text(function(d) {return d.key})
                .selectAll("span")
                    .data(function(d) { return d.values})
                    .enter().append("span")
                        .text(function(d) {return d})
    

    Produces:

    <p id="brw-a">brw-a
        <span>2012-07-05T00:00:00,0</span>
        <span>2012-07-06T23:59:59,1</span>
        <span>2012-07-07T06:31:47,0</span>
        <span>2012-07-08T23:59:59,3</span>
    </p>
    
    <p id="brw-c">brw-c
        <span>2012-07-11T00:00:00,0</span>
        <span>2012-07-07T00:00:00,2</span>
        <span>2012-07-05T23:59:59,4</span>
    </p>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm using the WPFToolkit to create a line chart with multiple LineSeries(multiple colors). I
I have multiple buttons that gets created in a table which all look like
I created a function for splitting an image into multiple images, but when I
Using Tinybutstrong and openTBS i created a script in PHP that opens multiple docx
I would like to open a file and read a line from it. There
we have created a SSRS report with a big chart that have multiple entries
I'm trying to divide a line into multiple segments. Because of that i've created
The Rails console doesn't seem to like multiple ruby statements on the same line
For example, a file contains multiple strings, where some look like this: --EX ABCDEFG
I am to process single PDFs that have each been created by 'merging' multiple

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.