GithubHelp home page GithubHelp logo

Option to hide domain path (line) about d3-axis HOT 5 CLOSED

d3 avatar d3 commented on April 26, 2024 1
Option to hide domain path (line)

from d3-axis.

Comments (5)

mbostock avatar mbostock commented on April 26, 2024 44

I typically achieve this using the “post-selection” technique (modifying the DOM after creation by the axis). For example:

g
  .attr("transform", `translate(${margin.left},0)`)
  .call(d3.axisLeft(y).ticks(8, "$.0f"))
  .call(g => g.select(".domain").remove())

https://beta.observablehq.com/@mbostock/d3-line-chart

Since post-selection enables a wide array of customizations, without needing to support them explicitly in d3-axis, that is my preferred approach.

from d3-axis.

matthewverde avatar matthewverde commented on April 26, 2024 9

Yes the provided solution above works, but that just feels way to hacky to be considered THE solution. Having an actual API to toggle this would be much appreciated.

from d3-axis.

airportpeople avatar airportpeople commented on April 26, 2024 9

I've also used this

yAxis_group.select('.domain')
                    .attr('stroke-width', 0);

After defining and calling the yAxis_group (i.e., svg.append('g') ... .call(yAxis)).

from d3-axis.

curran avatar curran commented on April 26, 2024 6

I agree with @matthewverde . I think of the post-selection approach as introducing extra computational overhead by rendering the domain path, then removing it. It's unnecessary DOM manipulation that could be avoided. That said, it's not critical either in the grand scheme of things, but a "nice to have" sort of thing.

from d3-axis.

kiranb555 avatar kiranb555 commented on April 26, 2024 2

.call(g => g.select(".domain").remove())

works well

from d3-axis.

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.