Skip to content
This repository

Off by one bug with maxIndex/neededColors in fillInSeriesOptions() #832

Closed
dnschnur opened this Issue · 4 comments

3 participants

David Schnur resting datadeflator
David Schnur
Owner

Original author: gabriel....@datadeflator.com (September 13, 2012 23:18:33)

Using jquery.flot.js (commit: c202303) from master.

When maxIndex == neededColors at line 441, neededColors isn't correctly adjusted. An indexing error later occurs at colors[s.color], line 485.

Attached test.html: one series with .color = 0; maxIndex = 0 and neededColors = 0. neededColors should be adjusted to 1.

Attached test2.html: two series with .color = numeric index and one series with .color = null; maxIndex = 1 and neededColors = 1. neededColors should be adjusted to 2.

Proposed fix: init maxIndex to -1 (instead of 0) and compare maxIndex >= neededColors (instead of >)

Original issue: http://code.google.com/p/flot/issues/detail?id=753

resting

I'm having this error Uncaught TypeError: Cannot call method 'toString' of undefined jquery.flot.js:485

Using the same replicate of the test examples.
source: https://github.com/resting/Flot-Experiments/blob/master/test/test.html

How do I resolve this?

David Schnur
Owner

This is first of all a question for the forums, and in any case it doesn't have anything to do with this issue. I'd guess that it's due to your 'color: 0', which isn't a valid color definition. Deleting both of these comments in a couple of days.

datadeflator

Committed fix for #906 partially fixes this bug. However,

jquery.flot.js:424: maxIndex should be initialized to -1 instead of 0.

Scenario: if every series had a css color spec setting (so no numeric color indexes were specified), a single color would still be generated unnecessarily. neededColors would've counted down to 0. maxIndex >= neededColors would pass, setting neededColors to 1.

Cheers

David Schnur dnschnur referenced this issue from a commit
David Schnur dnschnur Prevent color generation with all fixed indexes.
As pointed out in a comment to #832, initializing maxIndex to zero
results in the creation of a single color even when all indexes are
fixed.
a6414ca
David Schnur
Owner

Thanks for pointing that out! It's fixed in master now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.