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)
Sorting the X-axis on month name with optional Y-series grouping
mogwai
<p><span style="font-size:14px;">I have 2 columns in my data set: charmonth (Jan, Feb,...) and intmonth (1, 2, ...). I expected that it would sort correctly when using charmonth on the X-axis but sorting the X-axis on intmonth.</span></p>
<p><span style="font-size:14px;">I found some information telling me that the X-axis will always be sorted on whatever is displayed on the X-axis when optional Y-series grouping is used, so the intmonth should go on the X-axis and the label can be changed using the <span style="color:rgb(0,0,0);">beforeDrawAxisLabel function.</span></span></p>
<p><span style="font-size:14px;"><span style="color:rgb(0,0,0);">My problem is that I don't know the correct syntax of </span></span><span style="color:rgb(0,0,0);">beforeDrawAxisLabel to substitute the corresponding value of charmonth. Could anyone provide the correct script that will substitute the intmonth value for the charmonth value on the X-axis?</span></p>
Find more posts tagged with
Comments
pricher
<p>Hi,</p>
<p> </p>
<p>Maybe you don't need scripting here. What you can do is build your chart from a data cube instead of directly from the data set. In the attached example, I have a data set (based on Classic Models) that returns intmonth, charmonth, and status. I have then created a data cube where dimension charmonth is defined this way:</p>
<p> </p>
<p>
mogwai
<p>Thanks Pierre. That works fine. Excellent idea.</p>
mogwai
<p>Life has become more complicated. The chart uses confidence intervals now and that requires more complex grouping and aggregation (such as STDEV). This doesn't work in a crosstab. Is there a way to use scripting anyway to change the int value of the month to a char value. I tried mapping but that doesn't work either.</p>
pricher
<p>Hi,</p>
<p> </p>
<p>The following chart script can be used to change the X-axis labels:</p>
<pre class="_prettyXprint _lang-">
var map = new java.util.HashMap();
map.put("1","Jan");
map.put("2","Feb");
map.put("3","Mar");
map.put("4","Apr");
map.put("5","May");
map.put("6","Jun");
map.put("7","Jul");
map.put("8","Aug");
map.put("9","Sep");
map.put("10","Oct");
map.put("11","Nov");
map.put("12","Dec");
function beforeDrawAxisLabel( axis, label, icsc )
{
if (axis.isCategoryAxis()) {
label.getCaption().setValue(map.get(label.getCaption().getValue()));
}
}
</pre>
<p>I have attached a working sample.</p>
<p> </p>
<p>Hope this helps,</p>
<p> </p>
<p>P.</p>
mogwai
<p>This works like a charm. Thanks Pierre.</p>