Giter Site home page Giter Site logo

Comments (7)

curran avatar curran commented on June 3, 2024

I ran into this too. Here's an example where I ended up jumping through hoops to get the color legend and visualization to be ordered in the same way http://bl.ocks.org/curran/805413fb3b2efaada1ce

I ended up reversing the order of the stacked bars with this nasty line of code, so the order is the same on the color legend and the visualization.

from d3-legend.

ckhung avatar ckhung commented on June 3, 2024

Thank you, curran! Your code and idea are actually very neat. During the weekend I'll try to apply the idea to my situation. Maybe I just have to reverse both the domain and range of my scale...

from d3-legend.

curran avatar curran commented on June 3, 2024

Thanks! It is a bit tricky. I agree that it would be cool to think about
maybe adding an option to the legend to reverse it, without the need to
change around the scale.

On Tue, Oct 27, 2015 at 9:20 PM, Chao-Kuei Hung [email protected]
wrote:

Thank you, curran! Your code and idea are actually very neat. During the
weekend I'll try to apply the idea to my situation. Maybe I just have to
reverse both the domain and range of my scale...


Reply to this email directly or view it on GitHub
#15 (comment).

from d3-legend.

ckhung avatar ckhung commented on June 3, 2024

Yes, reversing both the domain and the range works. (I take the opportunity to multiply the numbers by 100 at the same time, making percent values out of ratios.)

My problem is solved so I wouldn't mind if susielu closes this issue.
(At the same time I feel the same as curran.)

from d3-legend.

susielu avatar susielu commented on June 3, 2024

Apologies on the late reply. There is actually an option called ascending that you can change to true if you want to reverse the order. It was added from a pull request and I forgot to add that feature to the documentation, will add that today.

from d3-legend.

curran avatar curran commented on June 3, 2024

Nice! Thank you.

from d3-legend.

ckhung avatar ckhung commented on June 3, 2024

OK I tried it just now. One can just do this: .ascending(true) to achieve this effect.
You might want to add an example and a brief description in the doc.

But before adding an example, you might consider changing its name.
I would probably call it .descending(true) instead.
Or better, .reverse(true) considering both vertical and horizontal legends.
This change may not hurt if not too many people are using it yet.
Name changes or not, this already makes my code look clearer. Thanks!

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.