Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Report # 5 : Charts and Graphs
nuraniuscc
Hi,
This is the one and only report that uses Graph.
Since there is no concept of Detail or Footer, Right after defining the Headers
we can Insert the Chart and define them. Right?
1) How do I define Legends as part of the Graph?
Eg : My X axis will be all "Months"
My Y axis will be all "Percentages" (in steps of 20) like 0, 20, 40 etc
2) How do I show comments for the 'X' and 'Y' axis?
3) I need to show 2 bars for each month.
1 bar will represent 0 - 5 days and the other bar will indicate 6 -10
days.
4) The months are given as Range in Input. Eg : Jan - June means the 'X' axis will say Jan Feb......June. This will vary
depending on the user request.
Please answer these in the simplest way possible.
Thanks
Nurani Sivakumar
Find more posts tagged with
Comments
Davolio
I to am interested in the result of this thread. What I ended up doing to have my Y- axis be in percents was add this code and formatted my data accordingly... also not I use BIRT 2.2.1
in my function beforeDrawAxisLabel(axis, label, icsc) method
function beforeDrawAxisLabel(axis, label, icsc){
else if(axis.getType() == AxisType.LINEAR_LITERAL){
//we want to show percents so lets buff up the formatting
var actualval = Number(label.getCaption().getValue());
actualval = actualval * 100;
actualval = actualval.toFixed(0);
actualval = String(actualval) + "%";
label.getCaption().setValue(actualval);
axis.setLabel(label);
}
Ignore the Date_TIME_LITERAL axis because that was my x-axis
<code>
//full code
importPackage(Packages.java.text);
importPackage(Packages.org.eclipse.birt.chart.model.attribute);
importPackage(Packages.org.eclipse.birt.chart.model.type.impl);
function beforeDrawAxisLabel(axis, label, icsc)
{
if (axis.getType() == AxisType.DATE_TIME_LITERAL){
var actualval = "" + label.getCaption().getValue();
var context = icsc.getExternalContext();
var timeIntervalParam = context.getScriptable().getPersistentGlobalVariable("TimeInterval");
var sdf;
if (timeIntervalParam == "DAYS")
{
sdf = new SimpleDateFormat("dd/MM/yyyy");
}
else if (timeIntervalParam == "WEEKS")
{
sdf = new SimpleDateFormat("dd/MM/yyyy");
}
else if (timeIntervalParam == "MONTHS")
{
sdf = new SimpleDateFormat("MM/yyyy");
}
else if (timeIntervalParam == "YEARS")
{
// sdf = new SimpleDateFormat("dd/MM/yyyy");
}
//go through the date and make sure its correct.
//javascript Date.getYear() is the number of years since 1900...
//the getFullYear() function is inaccessible for some reason.
var dateVal = new Date(actualval);
var curDate = dateVal.getDate();
var curMonth = dateVal.getMonth();
var curYear = dateVal.getYear();
var fourDigYear = curYear + 1900;
if(fourDigYear < 1954)
{
fourDigYear = fourDigYear + 100;
dateVal = new Date(fourDigYear,curMonth,curDate);
}
//for some reason I can't format years correctly...
//without doing this...
if (timeIntervalParam!= "YEARS")
{
label.getCaption().setValue( sdf.format(dateVal) );
axis.setLabel(label);
}
}
else if(axis.getType() == AxisType.LINEAR_LITERAL){
//we want to show percents so lets buff up the formatting
var actualval = Number(label.getCaption().getValue());
actualval = actualval * 100;
actualval = actualval.toFixed(0);
actualval = String(actualval) + "%";
label.getCaption().setValue(actualval);
axis.setLabel(label);
}
}
</code>