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)
Rename in Bar Chart
SNX2012
Hi at all,
Once again I?ve got a little question. I?ve designed a bar Chart and I want to replace the name of one of the Values from the X-Axis (see at the screen). With the Filter option of a chart or a Query I just can delete a Value by condition but I don?t need to delete, I just need to rename. Any idea?s how I can do this? Thanks for help!
Snx2012
Find more posts tagged with
Comments
kclark
Hi SNX,<br />
You can do this from the beforeDrawAxisLabel() like this<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>function beforeDrawAxisLabel( axis, label, icsc )
{
if(label.getCaption().getValue() == "NY") {
label.getCaption().setValue("New York");
}
}
</pre>
SNX2012
<blockquote class='ipsBlockquote' data-author="'kclark'" data-cid="113330" data-time="1358374620" data-date="16 January 2013 - 03:17 PM"><p>
Hi SNX,<br />
You can do this from the beforeDrawAxisLabel() like this<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>function beforeDrawAxisLabel( axis, label, icsc )
{
if(label.getCaption().getValue() == "NY") {
label.getCaption().setValue("New York");
}
}
</pre></p></blockquote>
<br />
Hey lots of thanks to you! Is there any kind of documentation, where you get all der functions from?<br />
<br />
greets SNX
SNX2012
One more Question, is it possible to do the same with a pie chart? function beforeDrawAxisLabel( axis, label, icsc ) doesn?t work in this case because in a pie chart he concarts the value and the name and the string doesn?t match then
kclark
You can do the same thing for pie charts but it'd be in beforeDrawDataPointLabel()<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>function beforeDrawDataPointLabel( dph, label, icsc )
{
if(label.getCaption().getValue() == "USA") {
label.getCaption().setValue("United States");
}
}
</pre>
SNX2012
Thanks for your help. I?ll tyed it but it doesn?t work. Maybe I explaned my problem with pie charts in a wrong way so I try to do better. I try to rename on render the Value Series Label. The Label consists of the "Value Data" and the "Category Data". I?ll tryed your solution as you can see in the screenshots.
I?ll tryed a little bit to fix my Problem and found another function.
function beforeDrawDataPointLabel( dph, label, icsc )
{
label.getCaption().setValue(label.getCaption().getValue().replaceFirst("Planes","PL"));
}
If you use this construction it will work fine in complex series Labels and you dont lose the "Value Data".
THX for Help
SNX
kclark
By the time you are getting the label BIRT see's it as one string. I solved this by using BirtStr.search() to find the starting position of the value you are looking for since that will remain static and you wont know the first value. From there I used BirtStr.left() to extract the rest of the string from the beginning to the value that was returned by search().<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>function beforeDrawDataPointLabel( dph, label, icsc )
{
var entireLabel = label.getCaption().getValue();
var firstValue;
var secondValue = " United States";
if(BirtStr.search("USA", entireLabel) > 0) {
var endPosition = BirtStr.search("USA", entireLabel) - 1;
firstValue = BirtStr.left(entireLabel, endPosition);
label.getCaption().setValue(firstValue + secondValue);
}
}
</pre>
<br />
Then I was able to change the label like normal except I used the variables I created. If you look at the above code secondValue isn't really needed you could also do something like this<br />
<br />
label.getCaption().setValue(firstValue + "United States");<br />
<br />
The if/then checks if the search value is greater than 0 because if it doesn't find anything then it returns -1.