formatNumber; filter log tickFormat function#2078
Conversation
507264a to
d9a98e9
Compare
| // to infer whether the ordinal scale is UTC or local time. | ||
| export function inferTickFormat(scale, data, ticks, tickFormat, anchor) { | ||
| return typeof tickFormat === "function" | ||
| return typeof tickFormat === "function" && !(scale.type === "log" && scale.tickFormat) |
There was a problem hiding this comment.
| return typeof tickFormat === "function" && !(scale.type === "log" && scale.tickFormat) | |
| return typeof tickFormat === "function" && scale.type !== "log" |
Nit: I'm not sure about the case for the second part of the test. When scale.type is "log", the scale is an instance of d3.scaleLog() and it has a tickFormat method, which the user can't nullify.
There was a problem hiding this comment.
I didn’t do this because I didn’t want to assume that log scales necessarily implement scale.tickFormat. That is currently true, but if this assumption doesn’t hold in the future, this would break.
There was a problem hiding this comment.
Error may be mine, but this "invalid" message comes from the format in many European languages returning 2 000 which is not accepted in SVG.
There was a problem hiding this comment.
The problem comes from running beautify.html on the generated SVG, meaning that the SVG is assumed to be in HTML. We’ll have to find a way to disable that for tests.
Edit: Actually it’s from JSDOM’s outerHTML serialization.
Fixes #2077. Also exposes Plot.formatNumber(locale).