Skip to content

Commit d7504ab

Browse files
committed
docs(colorbar): document that log/date dtick string forms are not supported on color bars
The colorbar tick axis is mocked with type 'linear' (mockColorBarAxis in src/components/colorbar/draw.js), and clean_ticks.dtick silently falls back to the default step for any non-numeric dtick on a linear axis. So the *L<f>*, *D1*, *D2* (log) and *M<n>* (date) special strings that the shared dtick description advertises have no effect on colorbar.dtick or coloraxis.colorbar.dtick - they even degrade to a 1-unit linear step, producing one garbage label per pixel of bar length (issue #7376). Give the colorbar dtick attribute its own accurate description: only positive numbers are honored. Regenerate test/plot-schema.json and the TS types accordingly.
1 parent 81bb1cd commit d7504ab

4 files changed

Lines changed: 52 additions & 39 deletions

File tree

draftlogs/7991_fix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Correct the `colorbar.dtick` (and `coloraxis.colorbar.dtick`) description: the special *log*/*date* string forms (*L<f>*, *D1*, *D2*, *M<n>*) are not supported on color bars - the internal color-bar axis is always linear, so such strings are silently ignored. The attribute now documents that only positive numbers are honored [[#7376](https://github.com/plotly/plotly.js/issues/7376)]

src/components/colorbar/attributes.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,22 @@ module.exports = overrideAll(
153153
description: 'Sets the color of padded area.'
154154
},
155155
// tick and title properties named and function exactly as in axes
156+
// (except dtick: the colorbar axis is mocked as type *linear*, so the
157+
// special *log*/*date* string forms documented on `dtick` - *L<f>*,
158+
// *D1*, *D2*, *M<n>* - are silently discarded, see #7376)
156159
tickmode: axesAttrs.minor.tickmode,
157160
nticks: axesAttrs.nticks,
158161
tick0: axesAttrs.tick0,
159-
dtick: axesAttrs.dtick,
162+
dtick: extendFlat({}, axesAttrs.dtick, {
163+
description: [
164+
'Sets the step in-between ticks on this color bar. Use with `tick0`.',
165+
'Must be a positive number.',
166+
'Unlike on x/y axes, the special *log* and *date* string forms',
167+
'(*L<f>*, *D1*, *D2*, *M<n>*) are NOT supported here: this axis is',
168+
'always linear, so such strings are silently ignored and the step',
169+
'falls back to its default.'
170+
].join(' ')
171+
}),
160172
tickvals: axesAttrs.tickvals,
161173
ticktext: axesAttrs.ticktext,
162174
ticks: extendFlat({}, axesAttrs.ticks, { dflt: '' }),

src/types/generated/schema.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ export interface ColorBar {
239239
*/
240240
borderwidth?: number;
241241
/**
242-
* Sets the step in-between ticks on this axis. Use with `tick0`. Must be a positive number, or special strings available to *log* and *date* axes. If the axis `type` is *log*, then ticks are set every 10^(n*dtick) where n is the tick number. For example, to set a tick mark at 1, 10, 100, 1000, ... set dtick to 1. To set tick marks at 1, 100, 10000, ... set dtick to 2. To set tick marks at 1, 5, 25, 125, 625, 3125, ... set dtick to log_10(5), or 0.69897000433. *log* has several special values; *L<f>*, where `f` is a positive number, gives ticks linearly spaced in value (but not position). For example `tick0` = 0.1, `dtick` = *L0.5* will put ticks at 0.1, 0.6, 1.1, 1.6 etc. To show powers of 10 plus small digits between, use *D1* (all digits) or *D2* (only 2 and 5). `tick0` is ignored for *D1* and *D2*. If the axis `type` is *date*, then you must convert the time to milliseconds. For example, to set the interval between ticks to one day, set `dtick` to 86400000.0. *date* also has special values *M<n>* gives ticks spaced by a number of months. `n` must be a positive integer. To set ticks on the 15th of every third month, set `tick0` to *2000-01-15* and `dtick` to *M3*. To set ticks every 4 years, set `dtick` to *M48*
242+
* Sets the step in-between ticks on this color bar. Use with `tick0`. Must be a positive number. Unlike on x/y axes, the special *log* and *date* string forms (*L<f>*, *D1*, *D2*, *M<n>*) are NOT supported here: this axis is always linear, so such strings are silently ignored and the step falls back to its default.
243243
* Setting this also sets: tickmode = "linear"
244244
*/
245245
dtick?: any;

0 commit comments

Comments
 (0)