MCPcopy
hub / github.com/nhn/tui.chart / getRoughScale

Function getRoughScale

apps/chart/src/scale/coordinateScaleCalculator.ts:131–150  ·  view source on GitHub ↗
(scale: Required<Scale>, offsetSize: number, minStepSize = 1)

Source from the content-addressed store, hash-verified

129}
130
131function 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
152export function makeScaleOption(dataRange: ValueEdge, scaleOptions?: Scale): Required<Scale> {
153 return {

Callers 1

calculateCoordinateScaleFunction · 0.70

Calls 2

isNumberFunction · 0.90
hasStepSizeFunction · 0.85

Tested by

no test coverage detected