Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ticks callback have unexpected behavior #1800

Closed
olyckne opened this issue Dec 18, 2015 · 4 comments
Closed

Ticks callback have unexpected behavior #1800

olyckne opened this issue Dec 18, 2015 · 4 comments

Comments

@olyckne
Copy link
Contributor

olyckne commented Dec 18, 2015

As I mentioned here #1021 (comment).

I think the ticks callback have som unexpected behavior.

Let's say I want to show every X label, with something like:

function (label, index) {
    return index % 10 === 0 ? label : '';
}

On some screen sizes it does what expected and in some not.
I guess the algorithm that automatically skips some labels interfere with the callback.
If I'm not mistaken that algorithm counts against the whole ticks array and not the actual showed one?

I have a graph with over 300 data points and want to show 3-5 labels and it really isn't possible with the callback.

Example.
I can live with this many labels
skarmavbild 2015-12-18 kl 09 55 36

but on a small screen it only showing one:
skarmavbild 2015-12-18 kl 09 55 31

Even more clear when it shows only one here:
skarmavbild 2015-12-18 kl 09 59 12

but a little smaller screen and it shows four:
skarmavbild 2015-12-18 kl 09 59 20

Not a big problem for me since I already have my own custom scale and can implement the afterBuildTicks hook and simply filter the ticks array, but it probably should be fixed.

JsFiddle for the example:

https://jsfiddle.net/olyckne/7ycm5bjg/10/

@etimberg
Copy link
Member

There is an auto skipper. Shouldn't be too difficult to disable in this case.

@olyckne
Copy link
Contributor Author

olyckne commented Dec 18, 2015

Yeah. If you have implemented a callback you probably don't want the auto skipper so it could probably be disabled in that case. Another option is an autoSkipper true/false.

@olyckne
Copy link
Contributor Author

olyckne commented Dec 18, 2015

Oh, just noticed the afterBuildTicks "workaround" doesn't work at all.

Maybe it isn't supposed to be used as I did it though.

I simply filtered this.ticks to only contain 4 items, but that means the labels is showing on completely wrong places, and the first four tooltips gets their title from those four items.

afterBuildTicks: function() {
    var everyX = (Math.ceil((this.ticks.length/2)/10)*10);
    this.ticks = _.filter(this.ticks, function (tick, index) {
        if (index === 1 || index === this.ticks.length - 1 ) {
            return true;
        }
        return index % everyX === 0;
    }.bind(this));
}

skarmavbild 2015-12-18 kl 15 17 57
skarmavbild 2015-12-18 kl 15 18 14

@etimberg
Copy link
Member

Closing since #1810 was merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants