# Thread: CCC Bullet Chart: dynamic max range

1. Senior Member
Join Date
Feb 2011
Posts
840

## CCC Bullet Chart: dynamic max range

So, following Duarte's advice, here's a new thread to ask: how do I make the max range of a bullet bar dynamic? So thing like this doesn't happen on me:

2. Senior Member
Join Date
Mar 2012
Posts
645
Hi,

this lousy extension point code did it in my test case:
Code:
```bulletPanel_ranges: function(d) {
var max = Math.max(pv.max(d.markers), pv.max(d.measures));

var ranges = d.ranges;
if(!ranges || !ranges.length) return [max];

max = Math.max(max, pv.max(ranges));

ranges = ranges.slice().sort();
ranges[ranges.length - 1] = max;

return ranges;
}```
Does not fix the "formattedRanges" array, that maybe you don't use, and it also makes the assumption that the markers and measures are there...or NaN may arise...
Last edited by duarte.leao; 09-11-2014 at 05:22 PM. Reason: added sort to ranges array

3. Senior Member
Join Date
Feb 2011
Posts
840
ok, even after the edit, rememeber that sort was messing things up, the problem was the presence of nulls. So i'll just put here the code that worked in the end, so if anyone ever need this...

Code:
```bulletPanel_ranges: function(d) {
var max = Math.max(pv.max(d.markers), pv.max(d.measures));

var ranges = d.ranges.filter(function(v){ return v != null; }) ;
if(!ranges || !ranges.length) return [max];

max = Math.max(max, pv.max(ranges));

ranges = ranges.slice();
ranges[ranges.length - 1] = max;

return ranges;
}```

4. Senior Member
Join Date
Mar 2012
Posts
645
Thanks João,

I didn't edit the example because I couldn't reproduce the problem you described when the sort() is used.
The null filtering, however, is a good guard.

5. Member
Join Date
Feb 2009
Posts
37
Hello Duarte,

Please, and if I want to make the minimal value dynamic (not just zero). Is it possible?

Thank you very much!

6. Senior Member
Join Date
Mar 2012
Posts
645
Hi Leandro,

as explained in this thread, it should be a matter of setting the extension point "bulletPanel_originIsZero" to boolean false.
Note that you need to set this in preExecution, as in the extension points property dialog it will be interpreted as string "false", which, is considered true...
Code:
```function f() {
this.chartDefinition.bulletPanel_originIsZero = false;
}```

Cheers

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•