Skip to content

[BUG] Null ticks are graphed when autoSkip=false #4794

@elibyrd

Description

@elibyrd

Expected Behavior

When a custom tick format callback returns null, that tick should be removed from graph.

Current Behavior

If autoSkip is set to false, null ticks are graphed alongside non-null ticks.
screenshot-jsfiddle net 2017-09-25 16-14-35-384

Possible Solution

It looks like null ticks are getting filtered out in _autoSkip (line 7492):

if (shouldSkip && i !== tickCount - 1 || helpers.isNullOrUndef(tick.label)) {
	// leave tick in place but make sure it's not displayed (#4635)
	delete tick.label;
}

If the null check were applied outside of the autoskip filter, it might fix the issue.

Steps to Reproduce (for bugs)

JSFiddle: https://jsfiddle.net/elibyrd/mxcervrt/

  1. Create a custom tick format that returns null on at least one tick
  2. Set autoSkip=false on same axis

Context

We have a dynamic chart that graphs one variable over the course of several hours, in minute increments. We want to manually set the x axis to tick every hour, which autoSkip interferes with.

Environment

  • Chart.js version: 2.7.0
    Note: this wasn't an issue in version 2.6.0 - we encountered it when trying to upgrade to 2.7.0 to take advantage of some new features in 2.7.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions