* Computes an "ideal" category based on the absolute bar thickness or, if undefined or null, * uses the smallest interval (see computeMinSampleSize) that prevents bar overlapping. This * mode currently always generates bars equally sized (until we introduce scriptable options?). * @private
(index, ruler, options, stackCount)
| 59 | * @private |
| 60 | */ |
| 61 | function computeFitCategoryTraits(index, ruler, options, stackCount) { |
| 62 | const thickness = options.barThickness; |
| 63 | let size, ratio; |
| 64 | |
| 65 | if (isNullOrUndef(thickness)) { |
| 66 | size = ruler.min * options.categoryPercentage; |
| 67 | ratio = options.barPercentage; |
| 68 | } else { |
| 69 | // When bar thickness is enforced, category and bar percentages are ignored. |
| 70 | // Note(SB): we could add support for relative bar thickness (e.g. barThickness: '50%') |
| 71 | // and deprecate barPercentage since this value is ignored when thickness is absolute. |
| 72 | size = thickness * stackCount; |
| 73 | ratio = 1; |
| 74 | } |
| 75 | |
| 76 | return { |
| 77 | chunk: size / stackCount, |
| 78 | ratio, |
| 79 | start: ruler.pixels[index] - (size / 2) |
| 80 | }; |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * Computes an "optimal" category that globally arranges bars side by side (no gap when |
no test coverage detected