Skip to content

Axis nice only appears to affect one end of axis #1077

@knutwannheden

Description

@knutwannheden

I created a plot looking like a demography chart and set nice: true for the X axis. This only appears to affect one end of the axis (the left one in my case). That seems like a bug to me.

Here is the example code (without data):

Plot.plot({
  x: {
    grid: true,
    label: "← Unbezahlt · Bezahlt →",
    labelAnchor: "center",
    tickFormat: Math.abs,
    nice: true
  },
  marks: [
    Plot.barX(source, Plot.stackX2({
      x: d => d.bezahlt == 'ja' ? d.anzahl : -d.anzahl,
      y: "partei",
      sort: {y: "x", reverse: true},
      fill: "bezahlt",
      title: d => `anzahl: ${d.anzahl}`
    })),
    Plot.text(source, {
      x: d => d.bezahlt == 'ja' ? d.anzahl + 10 : -d.anzahl - 10,
      y: "partei", text: "anzahl",
      // textAnchor: 'end',
    }),
    Plot.ruleX([0])
  ],
  color: {
    type: "categorical",
    domain: ['nein', 'ja'],
  },
  marginLeft: 50,
})

And the result:
image

Note: Regarding another question I posted this example in #1073

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions