Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Customize x-axis labels
zerba78
<p>Hi all</p><p>I use Birt designer 2.6.2 and I think it's a great tool.</p><p>I need to customize the x-axis but I don't know how to achieve the following result.</p><p>I have a bar chart that is displaying a measure for a 24 months time range, one value per month, starting from the current month and back to 2 years before. For example, if I execute the document today (July 2013) I get results for August 2011, Sept 2011, ..... June 2013, July 2013.</p><p>If I will execute the document tomorrow (August 2013) I will get values for</p><p>Sept 2011, October 2011..... July 2013, August 2013.</p><p>I want the x-axis to display only labels for first and last months and all January-s (i.e. when a new year starts) in the time range, labels to be horizontally aligned and with a tick.</p><p>I'm trying with scripting tecnique: the main problem I have is that, since the chart isn't too big, there is no enough space for all labes, therefore Birt is hiding some of them (unfortunately also the ones I need). And I don't know how to add ticks with scripts.</p><p>This is my script:</p><p> </p><p> </p><div>function beforeDrawAxisLabel( axis, label, icsc )</div><div>{</div><div> if(axis.isCategoryAxis()){</div><div> var labelParsed = label.getCaption().getValue().split("-");</div><div> </div><div> var year = labelParsed[0]; // this is the year</div><div> var month = labelParsed[1]; // this is the month</div><div> var rownum = labelParsed[2]; // I use this in order to understand if it is the first or last value in the range</div><div> </div><div> if (month == '1'){</div><div> label.getCaption().setValue(year); // I put just the year, I hide January</div><div> } else if ((rownum == 0 )||(rownum == 23 )) {</div><div> label.getCaption().setValue(year+"-"+month);</div><div> } else { </div><div> label.getCaption().setValue("");</div><div> }</div><div> }</div><div>}</div><p> </p><p>Can someone give me some advices?</p><p>Thanks in advance and best regards</p><p> </p><p> </p>
Find more posts tagged with
Comments
kclark
<p>Can you post the rptdesign please?</p>
zerba78
<p>Here you are.</p><p>I simplified the orginal template by editing a SQL query that gets 24 static values. It works properly on MySQL.</p><p>Thanks and best regards.</p><p> </p><p>PS: I will have a 2 weeks vacation. Have a nice vacation too to everyone!!</p><p> </p>
zerba78
<p>Hi</p><p>I used markers (dynamically created with scripts) as a work-around.</p><p>Best regards</p>