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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T17:48:27+00:00 2026-06-03T17:48:27+00:00

I am a d3 newbie and I’ve been trying to customize the Streamgraph example

  • 0

I am a d3 newbie and I’ve been trying to customize the Streamgraph example (http://mbostock.github.com/d3/ex/stream.html):

enter image description here

I have run into some issues:

I want to assign a custom data property (for examples sake, lets just say its a label called “type”) to each layer in the stream so that when you hover over that layer, a popup box appears with the “type” listed for that layer.

When I input my data source into the graph I use this code:

      vis.selectAll("path")
        .data(data0)
      .enter().append("path")

The graph only seems to take data of the format:

            [
                 [
                    {
                        "x": 0,
                        "y": 91,
                        "y0": 1.11
                    },
                    {
                        "x": 1,
                        "y": 290,
                        "y0": 1.11
                    }
                ],  
                [
                    {
                        "x": 0,
                        "y": 9,
                        "y0": 1.11
                    },
                    {
                        "x": 1,
                        "y": 49,
                        "y0": 1.11
                    }
                 ]
             ]

Where each sub-array above corresponds to a layer in the streamgraph.

How can I pass data to the graph that allows me to add an extra “type” property for each layer?

Basically so that when I refer to the datum of a layer, I can just type something like d.type and extract that property?

I originally came up with a really hackish way to do it:

                [
                    {
                        "x": 0,
                        "y": 9,
                        "y0": 1.11,
                        "type": "listings"
                    },
                    {
                        "x": 1,
                        "y": 49,
                        "y0": 1.11,
                    }
                 ]

and then I refer to it in the layer datum by saying d[0].type, but this doesn’t seem like the proper way to do it.

  • 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-03T17:48:28+00:00Added an answer on June 3, 2026 at 5:48 pm

    Use stack.values, and then wrap each layer’s data points with some additional data for the layer. Your data will look something like this:

    [
      {
        "type": "apples",
        "values": [
          { "x": 0, "y":  91},
          { "x": 1, "y": 290}
        ]
      },
      {  
        "type": "oranges",
        "values": [
          { "x": 0, "y":  9},
          { "x": 1, "y": 49}
        ]
      }
    ]
    

    And the stack layout like this:

    var stack = d3.layout.stack()
        .offset("wiggle")
        .values(function(d) { return d.values; });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Newbie question... The objective: I intend to have an HTML text input field as
Newbie still learning, been trying to search and hack code together for hours now,
Newbie question. I’m writing an ASP.Net MVC app in VB.Net and have been using
Newbie question, you've been warned! I'm trying to implement a sample Rails app with
Newbie Warning I have a simple but vexing problem trying to disable an NSButton.
Newbie question: There are three types of Asp.Net controls : HTML server controls, Web
Newbie question. I have Django models that look like this: class Video(models.Model): uploaded_by =
Newbie question since I'm not up to speed using maven at all. I'm trying
Newbie here, I have a struct for a word, which contains a char array
Newbie question. I am trying to use ActiveRecord::Base.connection.execute(..) in a ruby 3.1 app and

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.