|
| 1 | +/** |
| 2 | +* Copyright 2012-2018, Plotly, Inc. |
| 3 | +* All rights reserved. |
| 4 | +* |
| 5 | +* This source code is licensed under the MIT license found in the |
| 6 | +* LICENSE file in the root directory of this source tree. |
| 7 | +*/ |
| 8 | + |
| 9 | +'use strict'; |
| 10 | + |
| 11 | +module.exports = function makeBinAttrs(axLetter, match) { |
| 12 | + return { |
| 13 | + start: { |
| 14 | + valType: 'any', // for date axes |
| 15 | + role: 'style', |
| 16 | + editType: 'calc', |
| 17 | + description: [ |
| 18 | + 'Sets the starting value for the', axLetter, |
| 19 | + 'axis bins. Defaults to the minimum data value,', |
| 20 | + 'shifted down if necessary to make nice round values', |
| 21 | + 'and to remove ambiguous bin edges. For example, if most of the', |
| 22 | + 'data is integers we shift the bin edges 0.5 down, so a `size`', |
| 23 | + 'of 5 would have a default `start` of -0.5, so it is clear', |
| 24 | + 'that 0-4 are in the first bin, 5-9 in the second, but', |
| 25 | + 'continuous data gets a start of 0 and bins [0,5), [5,10) etc.', |
| 26 | + 'Dates behave similarly, and `start` should be a date string.', |
| 27 | + 'For category data, `start` is based on the category serial', |
| 28 | + 'numbers, and defaults to -0.5.', |
| 29 | + (match ? ( |
| 30 | + 'If multiple non-overlaying histograms share a subplot, ' + |
| 31 | + 'the first explicit `start` is used exactly and all others ' + |
| 32 | + 'are shifted down (if necessary) to differ from that one ' + |
| 33 | + 'by an integer number of bins.' |
| 34 | + ) : '') |
| 35 | + ].join(' ') |
| 36 | + }, |
| 37 | + end: { |
| 38 | + valType: 'any', // for date axes |
| 39 | + role: 'style', |
| 40 | + editType: 'calc', |
| 41 | + description: [ |
| 42 | + 'Sets the end value for the', axLetter, |
| 43 | + 'axis bins. The last bin may not end exactly at this value,', |
| 44 | + 'we increment the bin edge by `size` from `start` until we', |
| 45 | + 'reach or exceed `end`. Defaults to the maximum data value.', |
| 46 | + 'Like `start`, for dates use a date string, and for category', |
| 47 | + 'data `end` is based on the category serial numbers.' |
| 48 | + ].join(' ') |
| 49 | + }, |
| 50 | + size: { |
| 51 | + valType: 'any', // for date axes |
| 52 | + role: 'style', |
| 53 | + editType: 'calc', |
| 54 | + description: [ |
| 55 | + 'Sets the size of each', axLetter, 'axis bin.', |
| 56 | + 'Default behavior: If `nbins' + axLetter + '` is 0 or omitted,', |
| 57 | + 'we choose a nice round bin size such that the number of bins', |
| 58 | + 'is about the same as the typical number of samples in each bin.', |
| 59 | + 'If `nbins' + axLetter + '` is provided, we choose a nice round', |
| 60 | + 'bin size giving no more than that many bins.', |
| 61 | + 'For date data, use milliseconds or *M<n>* for months, as in', |
| 62 | + '`axis.dtick`. For category data, the number of categories to', |
| 63 | + 'bin together (always defaults to 1).', |
| 64 | + (match ? ( |
| 65 | + 'If multiple non-overlaying histograms share a subplot, ' + |
| 66 | + 'the first explicit `size` is used and all others discarded. ' + |
| 67 | + 'If no `size` is provided,the sample data from all traces ' + |
| 68 | + 'is combined to determine `size` as described above.' |
| 69 | + ) : '') |
| 70 | + ].join(' ') |
| 71 | + }, |
| 72 | + editType: 'calc' |
| 73 | + }; |
| 74 | +}; |
0 commit comments