Skip to content

Multi-line format helper? #1766

@mbostock

Description

@mbostock

Should we expose a multi-line format helper? You can do it yourself but it’s a bit verbose:

tickFormat(x, i, X) {
  const format1 = (x) => x.toLocaleString("it", { day: "numeric" });
  const format2 = (x) => x.toLocaleString("it", { month: "short" });
  const f1 = format1(x);
  const f2 = format2(x);
  return i > 0 && f2 === format2(X[i - 1]) ? f1 : [f1, f2].join("\n");
}

Maybe:

tickFormat: Plot.formatConditional({ day: "numeric" }, { month: "short" })

But, you’d also need a way to pass in the locale, perhaps the template.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions