Opened 14 years ago

Closed 14 years ago

#5419 closed defect (invalid)

Custom labels on chart fails to check for -ve index to array

Reported by: guest Owned by: Eugene Lazutkin
Priority: high Milestone: 1.1
Component: Charting Version: 1.0
Keywords: Cc:
Blocked By: Blocking:

Description (last modified by Adam Peller)

_getLabel in /dojox/charting/axis2d/Default.js fails to check for a negative index when attempting to find a label:

290 	                                --lo;
291 	                                if(lo < l.length && eq(l[lo].value, number)){

fails where lo==0, changing to

291 	                                if(lo>=0 && lo < l.length && eq(l[lo].value, number)){

works. It may not be necessary to test for lo<l.length.

Tested on 1.0.1, but code seems unchanged in trunk.

Paul Barrass.

Change History (3)

comment:1 Changed 14 years ago by Adam Peller

Description: modified (diff)
Owner: changed from Tom Trenka to Eugene Lazutkin

comment:2 Changed 14 years ago by Eugene Lazutkin

Milestone: 1.1
Status: newassigned

comment:3 Changed 14 years ago by Eugene Lazutkin

Resolution: invalid
Status: assignedclosed

The code in question is looking for a match in the classic array, which index goes from 0 to length. If you want to associate a label with a negative number, you should do it the normal way like it is demonstrated in test_labels2d.html:

    {value: -1, text: "Negative 1"}, 
    {value: 0, text: "Zero"}, 
    {value: 1, text: "Positive 1"}

Make sure that the array of labels is sorted by "value" in the ascending order.

Note: See TracTickets for help on using tickets.