Variable bar width in bar graph [message #1015668] |
Fri, 01 March 2013 10:40  |
Eclipse User |
|
|
|
Hello,
I have a requirement to have varaible column width in a bar chart. Basically, there are always going to be two columns, one in the positive direction and one in the negative direction. In addition, there will sometimes a third column that can go in either the positive or the negative direction, and will never be longer than the first or second column. The third column should occlude one of the first two columns, depending on whether it is positive or negative.
I am currently doing this by using stacked bars and computed columns to fake occlusion. But, I have just recieved a requirement that the third bar be 2/3 the thickness of the other bars. Is there a non-hacky way of doing this, and if not what is the least hacky way?
John
[Updated on: Fri, 01 March 2013 10:44] by Moderator
|
|
|
Re: Variable bar width in bar graph [message #1015738 is a reply to message #1015668] |
Fri, 01 March 2013 20:26   |
Eclipse User |
|
|
|
The third bar can easily be moved, without using stacked bars. If you had bars for A, B, and C with A being positive, B negative and C the moving bar, you could move the 3rd to the appropriate location with something like:
function beforeDrawSeries( series, isr, icsc )
{
if( series.getSeriesIdentifier() == "Series 1" ){
var dpharray = isr.getSeriesRenderingHints().getDataPoints();
for( j=0;j<dpharray.length;j++){
if(dpharray[j].getBaseDisplayValue() == "A"){
newNegX = dpharray[j].getLocation().getX();
}
else if(dpharray[j].getBaseDisplayValue() == "B"){
newPosX = dpharray[j].getLocation().getX();
}
if(dpharray[j].getBaseDisplayValue() == "C"){
if(dpharray[j].getOrthogonalValue() < 0){
dpharray[j].getLocation().setX(newNegX);
}
else{
dpharray[j].getLocation().setX(newPosX);
}
}
}
}
}
The thickness of the 3rd bar is the tough one. The width is set with the unit spacing which is set for the entire chart. Setting an image as the background to make it appear like a thinner bar might be an option. If I think of another way, I'll let you know.
[Updated on: Fri, 01 March 2013 20:28] by Moderator
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04910 seconds