MCPcopy
hub / github.com/chartjs/Chart.js / handleTickRangeOptions

Method handleTickRangeOptions

src/scales/scale.linearbase.js:181–211  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

179 }
180
181 handleTickRangeOptions() {
182 const {beginAtZero} = this.options;
183 const {minDefined, maxDefined} = this.getUserBounds();
184 let {min, max} = this;
185
186 const setMin = v => (min = minDefined ? min : v);
187 const setMax = v => (max = maxDefined ? max : v);
188
189 if (beginAtZero) {
190 const minSign = sign(min);
191 const maxSign = sign(max);
192
193 if (minSign < 0 && maxSign < 0) {
194 setMax(0);
195 } else if (minSign > 0 && maxSign > 0) {
196 setMin(0);
197 }
198 }
199
200 if (min === max) {
201 let offset = max === 0 ? 1 : Math.abs(max * 0.05);
202
203 setMax(max + offset);
204
205 if (!beginAtZero) {
206 setMin(min - offset);
207 }
208 }
209 this.min = min;
210 this.max = max;
211 }
212
213 getTickLimit() {
214 const tickOpts = this.options.ticks;

Callers 2

determineDataLimitsMethod · 0.45
determineDataLimitsMethod · 0.45

Calls 1

getUserBoundsMethod · 0.65

Tested by

no test coverage detected