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)
Customize X-Axis Labels in Chart
evgeny
Hi and thank you for reading,
I am working with a tables which has the two columns timeframe-category and amount of orders, it looks like this:
0 22
1 23
2 39
3 12
4 98
...
Now I know that the timeframe-category 0 is actually one week, category 1 is 2 weeks, 2 is one month aso.
I have created a table in Birt, which formates the category according to my needs:
if(category==1){
timeframe="2 Weeks";
}
So that I have a nice table, which transforms the categories in meaningful terms for the user.
Now I would like to do the same for a chart, is it possible to customize the chart in this way? I have the category on my X-Axis and would like that instead of 1 it shows 2 Weeks, aso.
Thank you for your help
Evgeny
Find more posts tagged with
Comments
mwilliams
Hi Evgeny,
You can write this same code to change the label value in the chart script. You would just get the label value, check it, and replace it with your new value. Another thing you could do would be to actually create a computed column in your dataSet that creates this value as an actual column, then you could just use that as your x-axis category in your chart.
Hope this helps.
evgeny
Thank you for you help mwilliams,
can you please provide me some details on how to format the X-Axis labes in the chart. Is it in the Interactivity section of the x-axis dialog, and then execute a script? Can you give me a short example of the code to write there?
Thank you
Evgeny
mwilliams
Evgeny,<br />
<br />
If you click on the actual chart in the design and then on the script tab below the design window, you'll have something like the following function:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
function beforeDrawAxisLabel( axis, label, icsc )
{
if (axis.isCategoryAxis()){
if (label.getCaption().getValue() == "1"){
label.getCaption().setValue("2 Weeks");
}
}
}
</pre>
evgeny
Thanks a lot!
Evgeny
mwilliams
No problem, good luck!