Skip to content

Commit

Permalink
Sample only if specified option value is smaller than number of ticks (
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann authored and etimberg committed Oct 18, 2019
1 parent ae2f8d7 commit 47b93fe
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/core/core.scale.js
Expand Up @@ -280,7 +280,7 @@ var Scale = Element.extend({
var me = this;
var tickOpts = me.options.ticks;
var sampleSize = tickOpts.sampleSize;
var i, ilen, labels, ticks;
var i, ilen, labels, ticks, samplingEnabled;

// Update Lifecycle - Probably don't want to ever extend or overwrite this function ;)
me.beforeUpdate();
Expand Down Expand Up @@ -345,7 +345,8 @@ var Scale = Element.extend({

// Compute tick rotation and fit using a sampled subset of labels
// We generally don't need to compute the size of every single label for determining scale size
labels = me._convertTicksToLabels(sampleSize ? sample(ticks, sampleSize) : ticks);
samplingEnabled = sampleSize > ticks.length;
labels = me._convertTicksToLabels(samplingEnabled ? sample(ticks, sampleSize) : ticks);

// _configure is called twice, once here, once from core.controller.updateLayout.
// Here we haven't been positioned yet, but dimensions are correct.
Expand All @@ -365,7 +366,7 @@ var Scale = Element.extend({
// Auto-skip
me._ticksToDraw = tickOpts.display && tickOpts.autoSkip ? me._autoSkip(ticks) : ticks;

if (sampleSize) {
if (samplingEnabled) {
// Generate labels using all non-skipped ticks
labels = me._convertTicksToLabels(me._ticksToDraw);
}
Expand Down

0 comments on commit 47b93fe

Please sign in to comment.