Skip to content

Added an optional css class to the x/y axes #976

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

dgwyer
Copy link

@dgwyer dgwyer commented Jul 7, 2022

This is my first PR! 🙂

Related. #6

This PR introduces optional CSS classes for the x and y axes.

Plot.plot({
    x: {
      axisClass: true
    },
    y: {
      axisClass: true
});

If axisClass is not defined or is false, then no CSS classes get added to the plot. I kind of like the current clean tree of attributes that Plot creates by default. So I considered maintaining this and only adding CSS classes for axes if specifically opted in.

If axisClass has been defined then it inserts the following classes. Note: Only the classes for the y-axis are shown below, but it's exactly the same for the x-axis if CSS classes are enabled.

<g class="y-axis" aria-label="y-axis" aria-description="↑ Close" transform="translate(40,0)" fill="none" text-anchor="end" font-variant="tabular-nums">
  <g class="tick" opacity="1" transform="translate(0,358.4133255882662)"><line stroke="currentColor" x2="-6"></line><line stroke="currentColor" x2="580" stroke-opacity="0.1"></line><text fill="currentColor" x="-9" dy="0.32em">60</text></g>

  ...

  <text class="y-axis-label" fill="currentColor" font-variant="normal" transform="translate(-40,20)" dy="-1em" text-anchor="start">↑ Close</text>
</g>

FYI - I've not added any docs for this PR yet. If it looks like it will be accepted then I'll update it of course.

@Fil Fil mentioned this pull request Jul 18, 2022
@Fil
Copy link
Contributor

Fil commented Jul 18, 2022

Thanks for the contribution. I'm closing because we're probably going to revisit axes to change them to marks (see #1000), and we're also thinking about a generic className option that one could use on any mark (see #253, which would have to be rewritten as a "common option"). These two large generic changes would end up solving this.

@Fil Fil closed this Jul 18, 2022
@mbostock mbostock mentioned this pull request Dec 23, 2022
36 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants