X-axis labels for chart [message #720003] |
Mon, 29 August 2011 16:38 |
|
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.
-
Attachment: x-axis.bmp
(Size: 50.33KB, Downloaded 2622 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 |
|
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 |
|
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 |
|
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 #1117516 is a reply to message #1116652] |
Thu, 26 September 2013 14:26 |
|
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
Developer Evangelist, Silanis
|
|
|
Powered by
FUDForum. Page generated in 0.03504 seconds