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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T22:05:27+00:00 2026-06-18T22:05:27+00:00

After using data().enter().append() in D3.js, individual columns/values in a dataset can be retrieved by

  • 0

After using data().enter().append() in D3.js, individual columns/values in a dataset can be retrieved by simply using d.valuename. But I want to find the maximum value in a CSV column for a linear scale. Since the scale is not preceeded by any data calls, I’m really uncertain on how to specify the right column from which to find the maximum value.

This is my failed attempt. What do I substitute d.column1 with?

d3.csv("file.csv", function (data) {

var x = d3.scale.linear()
    .domain([0, d3.max(d.column1)])
    .range([0, 960]);

EDIT:

Ok, I got a bit further by looking at a similar example. I don’t understand why my code is not working now.

 d3.csv("file.csv", function (data) {

 data.forEach(function(d) {
    d.column1 = +d.column1;
 });

 var max = d3.max(data, function(d) { return d.column1; });

 var x = d3.scale.linear()
     .domain([0, max])
     .range([0, 960]);

EDIT #2:

In case the problem derives from the data itself, here’s a snippet. I have tried removing all quotes, and also keeping the quotes for everything but the top row, but nothing works.

"product", "price"
"bread",20
"meat",100
"meat, sausage",200

EDIT #3:

Ok, I promise, last edit. But just to be absolutely clear; I’m using the x-scale to determine the width of the bars in a bar chart: .attr("width", x) and the scale returns NaN.

  • 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-18T22:05:28+00:00Added an answer on June 18, 2026 at 10:05 pm

    I just realized what the problem was. No wonder we couldn’t figure this one out together. All the code above is fine. It’s just that when I called the x-scale to determine the width of my bars, I didn’t specify which column in the data would be input to the scale. I had

    .attr("width", x)
    

    But now I changed that row to:

    .attr("width", function(d) { return x(d.column1); })
    

    Thanks for your help and patience.

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

Sidebar

Related Questions

I want to display information after I enter data into the database using ajax
We're using RavenDB saga storage, but the saga data isn't being persisted after the
I want my test data goes to another window after Enter key press, like
I'm having trouble to display data after form submition using JS and AJAX here
Is it possible to update the same view with new data? Using UPDATE after
I'm using curl to fetch some data from a website. After I process it
I am trying to implement a Data Flow Anomaly Detection using ptrace. After a
After creating the table with pm.createTable() and adding data to it using pm.addDataToTable() ,
I am using a barcode scanner to enter in data and then send the
here i,m trying to enter data into table playlist using information extracted from other

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.