| 
| Pie wedge dynamic (script) coloring issues [message #211523] | Mon, 15 January 2007 07:58 |  | 
| Eclipse User  |  |  |  |  | Originally posted by: vgryn.yahoo.com 
 Hi!
 
 I'm using BIRT version 2.2M2.
 
 For Pie chart, I can specify following using script:
 
 function beforeDrawLegendItem( lerh, bo, context ){
 if (lerh.getDataIndex() == otherIndex) {
 lerh.getFill().set(200,200,200);
 }
 }
 
 function beforeDrawDataPoint( dph, fill, context ){
 if (dph.getIndex() == otherDataIndex) {
 fill.set(200,200,200);
 }
 }
 
 This allows set fill color of wedges dynamically dependent on some
 condition.
 Question 1.
 Assume chart is changed in such way that some palette items use unusual fill
 styles, such as gradient, image etc. How in the above script I can check
 whether we have
 normal (solid color) fill or gradient fill or image fill? There is fill type
 (int) property of fill object, but I could not find any description for it
 (i.e. what fill type is what number). Maybe, I should check this by class
 (instanseof)? But how to do this in the script?
 
 Question 2.
 Assume I need to change the fill for pie wedge to the gradient, but it was
 normal (solid) color that comes from palette. Is there any way to change the
 type of the fill? There is no setFill for lerh object, and fill comes as
 parameter for data point. Can it be added? Playing with palette is way too
 troublesome. Also, can it be improved that return value from
 beforeDrawDataPoint function is used as a new fill object?
 
 Question 3.
 It is really hard to detect what wedge is "Other" wedge that contains total
 of all filtered out wedged after Min Slice condition. Can you add 2 methods
 for pie chart run-time object(s) to allow get out legend index of legend
 item that matches to the "Other" wedge (or at least get number of legend
 items) and data index for data point that matched to "Other" wedge? I
 calculated these 2 indexes in script by quite complicated code with use of
 run-time data set values scanning (call to
 BaseRenderer.getFilteredMinSliceEntry). But that is another pass through the
 data set (performance loss).
 
 Question 4.
 Is it possible to limit just number of wedges in Pie chart? So, for example,
 I want to display just top 10 and all the rest go to the "Other" (Min slice)
 wedge? It would be good if it is a separate Pie chart setting so both Min
 Slice and max number of wedges apply. For example, if after Min Slice
 filtering there are more than 10 wedges (include "Other"), then apply max 10
 rule.
 I ask for this because need to assure good pie displaying no matter what
 data come from backend. For this, need to limit number of wedges as well -
 just Min Slice setting is not enough to assure pie chart is not garbaged by
 too much wedges.
 Of course, like in Question 3. I can go through run-time data by self and
 calculate that by self, then set MinSlice to the required value (not
 percent). However, it looks like it would not be possible to change Min
 Slice at that point (or it is possible?). Even if possible, it would not
 help if 15 top rows in data set come with equal value, but I need max 10.
 
 --
 WBR,
 Vlad Grynchyshyn
 |  |  |  | 
Powered by 
FUDForum. Page generated in 1.10152 seconds