Home
Analytics
X axis sorting in a Chart
RBO2
Hello,
I am a new Birt user. I try to create a prototype a client and I get a simple problem with a Birt chart. I get data from a scripted dataset and I want to display the X axis values sorted by Desc (Example: 3000 2000 1000 0).
My dataset is already sorted with the good order.
The problem is if I select the ?Is Cathegory? option for my X axis, the X axis is sorted by Desc but the displayed vales are not acceptable (3005.432, 2564.321, ?)
If I disabled this option, the X axis the displayed values are acceptable (0, 1000, 2000, ?) but sorted by Asc.
I try to manage this order by ?Select data? menu with the sorting of X series but the sorting stay the same.
Is somebody seeing any issue?
Thanks in advance.
Find more posts tagged with
Comments
mwilliams
What is your BIRT version? Can you reproduce this issue with the sample database?
RBO2
Hello Birt Guru!<br />
<br />
I am using the 2.5.2 version.<br />
The problem can be reproducing on the sample DB.<br />
<br />
I am thinking about customized my chart using a script because Birth offer a lot of possibilities with scripting.<br />
I found some code sample to get the X axis:<br />
<br />
xAxis = chart.getBaseAxes()[0];<br />
<br />
But I don?t found the function name to reverse the axis and/or manage the ?Is Cathegory? property. I don?t found It in the Eclipse and Burt library.<br />
<br />
Do you know any property or function corresponding to these needs?<br />
Thanks in advance.
mwilliams
Can you attach the report in which you reproduced the issue?
RBO2
Dear Birt Guru,
Here is the report on the sample DB.
To sum up, I just want to have a correct dynamic X axis scale with a reverse order...
RBO2
In my chart, the X axis is not a cathegory Axis.
Is it possible to reverse the X axis order with a script or a specific option (for example: to start from 17000 and end with 0)?
mwilliams
If it's not a category axis, I don't know if you can switch the way it goes regardless. If I don't have "is category axis" selected in the chart editor, the sorting doesn't change the x-axis order.
RBO2
Dear Williams,<br />
<br />
Ok. Thanks for your support.<br />
Have a nice day.
mwilliams
You're welcome. You can always submit an enhancement request to be able to reverse the x-axis scale when not using a category axis.
http://www.birt-exchange.org/org/resources/bug-reporting/
RBO2
<span style='font-family: Arial'>Hello Williams,<br />
<br />
For me it is not a bug, it is more a king of limitation.<br />
I just found the solution to solve this problem.<br />
Here are the steps to perform:<br />
<p class='bbc_indent' style='margin-left: 40px;'><br />
- Modify the data Set by multiplied all X values by -1<br />
- Modify the chart to start the X axis a the min value<br />
- Suppress the ? when drawing the X axis labels using my script:</span></p>
<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
/**
* Called before rendering each label on a given Axis.
*
*
@param
axis
* Axis
*
@param
label
* Label
*
@param
icsc
* IChartScriptContext
*/
function beforeDrawAxisLabel( axis, label, icsc )
{
//Supress the - characters on the X axis value only
if (label.getCaption().getValue().startsWith('-') && axis.getOrientation() == Orientation.HORIZONTAL_LITERAL )
{
label.getCaption().setValue(label.getCaption().getValue().substring(1, label.getCaption().getValue().length())) ;
}
}
</pre>
RBO2
- Modify the chart to start the <strong class='bbc'>X</strong> axis a the min value<br />
<br />
Sorry, this is the <strong class='bbc'>Y</strong> axis.
mwilliams
Glad you found a solution. The link I gave you is for logging bugs and for making enhancement requests. I suggested logging an enhancement request. If they added a feature to do this, you wouldn't have to do all of that script in future versions. But if using the workaround you are isn't a big deal, then no worries!
Let us know whenever you have questions!
RBO2
Ok. Thanks