Hi,
I am using the below mentioned query on chart to know growth % on a chart. But it doesnt seem to work.
SELECT 'dbr.chart', 'Column', 'Growth Percentage';
select 'dbr.chart.options', 'bargap', 0.5;
select 'dbr.chart.options', 'chartdirector', '
$declineColor = 0x33CC33;
$growthColor = 0xFF1D1D;
$arrowColor = 0x000000;
for ($ds=0; $ds < $layer->getDataSetCount()-1; $ds++) {
$fromVal = $layer->getDataSet($ds)->getValue($ds);
$toVal = $layer->getDataSet($ds+1)->getValue($ds+1);
$sameValue = $fromVal==$toVal;
$percent = sprintf("%+d%%", round(($toVal - $fromVal)/$fromVal*100,0));
$x = $c->getXCoor($ds)+($c->getXCoor($ds+1)-$c->getXCoor($ds))/2;
if (!$sameValue) {
$c->addLine( $x, $c->getYCoor($fromVal), $x, $c->getYCoor($toVal), $arrowColor,3 );
} else {
$c->addLine( $x-10, $c->getYCoor($fromVal), $x+10, $c->getYCoor($fromVal), $arrowColor,3 );
}
if ($fromVal<=$toVal) {
if (!$sameValue) {
$c->addLine( $x+4, $c->getYCoor($toVal)+4, $x, $c->getYCoor($toVal), $arrowColor,3 );
$c->addLine( $x, $c->getYCoor($toVal), $x-4, $c->getYCoor($toVal)+4, $arrowColor,3 );
}
$c->addText($x, $c->getYCoor($toVal)-14, $percent, "", 8, $sameValue ? 0x000000 : $declineColor, TopCenter);
} else {
$c->addLine( $x-4, $c->getYCoor($toVal)-4, $x, $c->getYCoor($toVal), $arrowColor,3 );
$c->addLine( $x, $c->getYCoor($toVal), $x+4, $c->getYCoor($toVal)-4, $arrowColor,3 );
$c->addText($x, $c->getYCoor($toVal)+14, $percent, "", 8, $growthColor, BottomCenter);
}
}
', 'after';