Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » X-axis labels for chart(flexibility with the x-axis label format)
X-axis labels for chart [message #720003] Mon, 29 August 2011 16:38 Go to next message
Olly   is currently offline Olly
Messages: 61
Registered: June 2010
Location: Florida
Member
Is there any way programmatically or via the Eclipse plugin to make the x-axis in a line or area chart have a two tiered label for a timestamp. What I mean is I want the x-axis, which is a timestamp from a database, to look like the attached image.
index.php/fa/3806/0/
Is this possible. At the moment I have the label at a 45 degree angle but I'm looking for other options.
  • Attachment: x-axis.bmp
    (Size: 50.33KB, Downloaded 669 times)

[Updated on: Mon, 29 August 2011 16:38]

Report message to a moderator

Re: X-axis labels for chart [message #720080 is a reply to message #720003] Mon, 29 August 2011 20:06 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

Olly,

Is the x-axis using a date time field? If so why not format the x-axis
labels to only show the hour and use the x-axis title to show the date.
Use some script something like:

xaxistitle = "";
function afterDataSetFilled( series, dataSet, icsc )
{

importPackage( Packages.org.eclipse.birt.chart.util);

//only want the category values
if( series.getSeriesIdentifier() != "Series 1" ){

//org.eclipse.birt.chart.util.CDateTime My test report only had one row
//of data
var mycdatetime = dataSet.getValues()[0];
xaxistitle = mycdatetime.getYear() + "-" + mycdatetime.getMonth() + "-"
+ mycdatetime.getDay();
}
}


function beforeDrawAxisTitle( axis, label, icsc )
{
if( axis.isCategoryAxis() ){
label.getCaption().setValue(xaxistitle);
}
}


Jason

On 8/29/2011 12:38 PM, Olly wrote:
> Is there any way programmatically or via the Eclipse plugin to make the x-axis in a line or area chart have a two tiered label for a timestamp. What I mean is I want the x-axis, which is a timestamp from a database, to look like the attached image.
>
> Is this possible. At the moment I have the label at a 45 degree angle but I'm looking for other options.
Re: X-axis labels for chart [message #720501 is a reply to message #720080] Tue, 30 August 2011 18:02 Go to previous messageGo to next message
Olly   is currently offline Olly
Messages: 61
Registered: June 2010
Location: Florida
Member
Jason,
Thanks for the quick response. The only problem I can see with this is that the charting may encompass multiple days, so this would have to be reflected in the chart, i.e. 2011-05-05 2011-05-06 2011-05-07 all on the same chart. Thanks for your help.
Re: X-axis labels for chart [message #720570 is a reply to message #720501] Tue, 30 August 2011 20:14 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

You can always put new lines in the axis labels. Look at the attached
example.


Jason


On 8/30/2011 2:02 PM, Olly wrote:
> Jason,
> Thanks for the quick response. The only problem I can see with this is
> that the charting may encompass multiple days, so this would have to be
> reflected in the chart, i.e. 2011-05-05 2011-05-06 2011-05-07 all on the
> same chart. Thanks for your help.
Re: X-axis labels for chart [message #1116652 is a reply to message #720003] Wed, 25 September 2013 18:04 Go to previous messageGo to next message
rachel s is currently offline rachel s
Messages: 1
Registered: September 2013
Junior Member
Can some one explain code in zip file? i could not understand function
function beforeDrawAxisLabel( axis, label, icsc )
{
importPackage(
Packages.org.eclipse.birt.chart.model.attribute.impl );
importPackage(
Packages.org.eclipse.birt.chart.model.attribute );
if( axis.getType() == AxisType.TEXT_LITERAL ){
var cp =label.getCaption().getValue();
if( cp.substr(0,2) == last ){
label.getCaption().setValue(cp.substr( (cp.length()-2)));
}else{
label.getCaption().setValue(cp.substr( (cp.length()-2))+"\n\r "+cp.substr(0,2));
}
last = cp.substr(0,2);
}
what does label and icsc refer to?

Could not make my code working by resuing above code.
Re: X-axis labels for chart [message #1117516 is a reply to message #1116652] Thu, 26 September 2013 14:26 Go to previous message
Michael Williams is currently offline Michael Williams
Messages: 1595
Registered: July 2009
Senior Member

Here's the description of the function that you get when you select it from the drop down in the chart script area:

/**
 * Called before rendering each label on a given Axis.
 * 
 * @param axis
 *            Axis
 * @param label
 *            Label
 * @param icsc
 *            IChartScriptContext
 */


It's a standard function that allows you to modify the chart. If you select your chart and go to the script area, you'll see a drop down of functions at the top. If you select one, it will add it to the script area. As far as what the rest of the code does, it is checking the first several characters of the text axis (the x-axis) and changing the label value based on a comparison to the previous label value. Hope this helps.


Michael

Add interactivity, scheduling, sharing, live Excel export, and JS integration to your BIRT app with the new, free BIRT server, BIRT iHub F-Type.
Previous Topic:BIRT4.3 cross-tab report, export excel2007, data is displayed in a cell?
Next Topic:SEVERE: Cannot get ODA driver parameter metadata when exporting to excel
Goto Forum:
  


Current Time: Sat Sep 20 11:59:10 GMT 2014

Powered by FUDForum. Page generated in 0.01890 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software