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)
BIRT Chart - X axis not sorted correctly
niranjan087
<div>I'm getting data back from database and displaying it in BIRT Chart. I am plotting hour in X axis and reading (for that corresponding hour) in Y axis. I want the hour in X axis to be in ascending order like 0,1,2,3,4....23. So , I set the Grouping and Sorting in X Series to Ascending(screenshot attached). But, in the resulting chart ascending order has been applied to hour's first digit and then second digit i.e. it is displaying like 0,1,10,11,12,13....19,2,20,21,22,23,3,4,5...9(Attached the graph screenshot) Please refer to the attached screenshot and suggest me how to arrange the goruping and sorting.. Any help would be greatly appreciated..</div>
Find more posts tagged with
Comments
PaulCooper
<p>This occurs because you are sorting on a string rather than a number. If your X-axis field contains hours and is a string you need to convert the value to a number (a computed column or binding with the expression of parseInt(row["<em>field_name</em>"], 10) should do the job).</p>
<p> </p>
<p>If it is a DateTime field then you need to set the grouping interval's Type should be "DateTime" and the Units should be "Hours".</p>
<p> </p>
<p>Paul</p>
niranjan087
<p>Thanks for your reply Paul. I understood the issue. The parsing code you have given <span style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;">parseInt(row["</span><em>field_name</em><span style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;">"], 10), i tried putting it in 2 places One in 'Category X Series' and 'Sort on' option in Grouping and sorting. Also I changed the grouping to Numeric . Please refer to the changes made in attached screenshot. But the graph looks weird now showing 'NaN' values in x axis. Please refer to screenshot attached. </span>Where should I do casting or parsing you suggested? </p>
PaulCooper
<p>The second argument to the parseInt function should be 10 not 2. This is the base. 2 would mean binary. You don't techincally need the base number but adding it stops parseInt function thinking number with leading zeros are octal (base 8) so adding this is good practice.</p>
<p> </p>
<p>Because you put 2 numbers 2 to 9 and 12 to 23 would be converted to NaN.</p>