(scale: Required<Scale>, offsetSize: number, minStepSize = 1)
| 129 | } |
| 130 | |
| 131 | function getRoughScale(scale: Required<Scale>, offsetSize: number, minStepSize = 1): ScaleData { |
| 132 | const { min, max } = scale; |
| 133 | const limitSize = Math.abs(max - min); |
| 134 | const valuePerPixel = limitSize / offsetSize; |
| 135 | |
| 136 | let stepCount = Math.ceil(offsetSize / DEFAULT_PIXELS_PER_STEP); |
| 137 | |
| 138 | const pixelsPerStep = offsetSize / stepCount; |
| 139 | let stepSize = valuePerPixel * pixelsPerStep; |
| 140 | |
| 141 | if (hasStepSize(scale.stepSize)) { |
| 142 | stepSize = scale.stepSize; |
| 143 | stepCount = limitSize / stepSize; |
| 144 | } else if (isNumber(minStepSize) && stepSize < minStepSize) { |
| 145 | stepSize = minStepSize; |
| 146 | stepCount = limitSize / stepSize; |
| 147 | } |
| 148 | |
| 149 | return { limit: { min, max }, stepSize, stepCount }; |
| 150 | } |
| 151 | |
| 152 | export function makeScaleOption(dataRange: ValueEdge, scaleOptions?: Scale): Required<Scale> { |
| 153 | return { |
no test coverage detected