Giter Site home page Giter Site logo

Comments (3)

susielu avatar susielu commented on June 13, 2024

Would you mind posting some sample code?

from d3-legend.

bohnna avatar bohnna commented on June 13, 2024

Sure thing! I believe I figured out what's happening, the legend will skip if a value is duplicated.

I've extracted the code into a codepen below:

http://codepen.io/anon/pen/vXoXWV?editors=1010#0

If you change the values for the constant dataValues, it will add the remaining labels as long as the matching value does not exist already in the dataset. This is my first project using D3 so excuse the mess!

from d3-legend.

susielu avatar susielu commented on June 13, 2024

So what you want to do is actually pass the dataLabels into the ordinal scale for the legend. This is not really a legend problem but a scale problem. The assumption you make when you're using scales in d3 is that there are unique domain values that map to a range. Here is this fixed code: http://codepen.io/anon/pen/vXoXWV?editors=1010#0

All I did was change line 72 from dataValues to dataLabels. DataValues are values that you would pass to a scale for the scale to interpret but not to setup the scale itself. Does that make sense?

from d3-legend.

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.