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)
To remove x-axis label when no data available in bar chart
jain
Hi I have created the bar chart, in that if the value for any x-axis label is null, then in x-axis its displaying as null in the chart, So how to suppress the null value and tick from the x-axis bar chart. Please find the attached screen shot and rptdesign file,
Find more posts tagged with
Comments
kclark
The easiest way to do this would be to add a filter from the chart UI. From Select data you can click filters > add. From here you can filter out all the null values. Or you can do it from script with something like
function beforeDrawAxisLabel( axis, label, icsc )
{
if(label.getCaption().getValue() == "null") {
label.getCaption().setValue("");
}
}
jain
thanks Kclark for your response, I have implemented the logic which you provided, x-axis label is getting removed if the value is null and its working as expected. In the same way how to remove ticks in x-axis for the null value label?
kclark
You can remove the tick marks from a chart in beforeGeneration() using this<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
function beforeGeneration( chart, icsc )
{
yAxis = chart.primaryBaseAxes[0];
yAxis.getMajorGrid().getTickAttributes().setVisible(false);
}</pre>
<br />
This will remove all of the ticks on that axis. I think the best solution if you want to remove the labels and the ticks in your chart would be to add a filter to the chart.<br />
<br />
Double click the chart > Select Data > Filters<br />
<br />
Then add a filter that shows something like row["THEROW"] Greater Than 0<br />
<br />
This way your chart will only show values greater than 0 and you don't need to worry about the tick marks.<br />
<br />
If the dataset you are using is just for the chart then it might be quicker to do this from your query.<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>select *
from CLASSICMODELS.CUSTOMERS
where CLASSICMODELS.CUSTOMERS.CREDITLIMIT > 0</pre>
jain
Thanks Kclark, let me implement this in the report and check it out.