Skip to content

Axis label position: Allow customizing vertical position of axis label for Y axis #1101

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

Open
nobarany opened this issue Oct 25, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@nobarany
Copy link

The distance between the axis label and the chart is customizable in one direction. It'd be great to be able to expose a setting for the other direction (or for styling it in general) to allow more flexibility.

.attr("dy", labelAnchor === "center"
               ? axis === "right"
                   ? "-0.32em"
                   : "0.75em"
               : labelAnchor === "bottom"
                   ? "1.4em"
                   : "-1em")

The last condition ("-1em") seems too tight for my chart:
Screen Shot 2022-10-25 at 10 53 19 AM

@Fil
Copy link
Contributor

Fil commented Oct 27, 2022

Can you share your chart?

@nobarany
Copy link
Author

nobarany commented Oct 27, 2022

Sure:

Plot.plot({
    width,
    y: {
      grid: true,
      zero: true,
      label: 'Daily spending',
      tickFormat: (d: number) => `${formatCurrencySimple(d)}`,
      nice: true,
    },
    x: { tickRotate: -45, type: 'utc' },
    marks: [
      Plot.lineY(
        budget,
        Plot.map(
          { y: 'cumsum' },
          {
            x: xProp,
            y: yProp,
            sort: xProp,
            curve: 'step',
            stroke: 'gray',
          }
        )
      ),
    ],
    marginTop: 40,
    marginBottom: 60,
    marginLeft: 80,
  });

@llimllib
Copy link

llimllib commented Oct 28, 2022

I'd also like this; here's a chart I generated where the X axis label is unpleasantely close to the right margin:

plot(5)

(Probably axis titles should respect the graph margin? But I could also fix it manually if I could tweak its horizontal offset. Also the axis label doesn't have any useful class or property that would let me select it cleanly so I could push it over as a post-processing step)

@mbostock
Copy link
Member

mbostock commented Dec 1, 2022

Related #375.

@mbostock mbostock added the enhancement New feature or request label Dec 2, 2022
@Fil Fil mentioned this issue Sep 14, 2023
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants