Coder Social home page Coder Social logo

Comments (4)

mbostock avatar mbostock commented on May 1, 2024 1

Ah. Well yes, the bin.x0 and bin.x1 are coerced to numbers. And so are the other parts of the histogram (the domain, the values, the thresholds). However, it occurs to me that this is overly strict, and really the histogram only requires comparable (ordinal) values and not numbers, so we could relax that and leave dates as dates.

from d3-array.

mbostock avatar mbostock commented on May 1, 2024

Yes, that’s valid. Is there a question? Here’s an example:

preview

from d3-array.

cpietsch avatar cpietsch commented on May 1, 2024

Oh sorry. I got confused by the negative x0/x1 values. Was expecting a date object or a positive value.

from d3-array.

lgrkvst avatar lgrkvst commented on May 1, 2024

Observation: if .value() returns Date objects, the first element's x0 and the last element's x1 will stay Date objects. The bin thresholds in-between is coerced into numberobjects.

var A = [1476448344837, 1476448348221, 1476448350581, 1476448352482];
var yay = d3.histogram().value(a => a)(A); // all numbers
var nay = d3.histogram().value(a => new Date(a))(A); // Date objects for `nay[0].x0` and `nay[1].x1`

from d3-array.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.