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)
Bar Chart - Minimum value on Axis?
Chrisrustydog
<p>I have a bar chart with an X axis showing yearly intervals. In the attached image, you can see how I set the minimum starting value to a specific year. </p>
<p> </p>
<p>Is there a way to make the minimum value the current year? I was thinking that there would be a way to set the minimum starting value to some kind of logical statement such as sql syntax - YEAR(GetDate())</p>
<p> </p>
<p> </p>
Find more posts tagged with
Comments
Clement Wong
<p>I'm assuming that you're using OS BIRT based on your other posts. Also, I'm assuming that your X-Axis "Is Category Axis" setting is <strong>not</strong> checked.</p>
<p> </p>
<p>If so, then, you can use the following in your Chart's<em> onRender > beforeGeneration</em> event:</p>
<pre class="_prettyXprint">
function beforeGeneration( chart, icsc )
{
importPackage( Packages.org.eclipse.birt.chart.model.data.impl );
importPackage( Packages.org.eclipse.birt.chart.util );
xAxis = chart.getBaseAxes()[0];
scale = xAxis.getScale();
scale.setMin( DateTimeDataElementImpl.create( new CDateTime(BirtDateTime.year(BirtDateTime.now()),1,1) ) );
//scale.setMax( DateTimeDataElementImpl.create( new CDateTime(BirtDateTime.year(BirtDateTime.now()),1,1) ) );
}</pre>
Chrisrustydog
<p>Thanks for your response.</p>
<p> </p>
<p>I am not sure what OS BIRT is. I am using the free edition.</p>
<p> </p>
<p>My programming knowledge is limited to some XML and very little javascript, below average at best. I am decent with writing SQL queries though - Curious, does one need to be well versed in Java Script in order to utilize the scripting capabilities in BIRT? Would you say that knowing how to script in BIRT is essential to unlocking the applications primary functionality or is it just "nice to have" ?</p>
<p> </p>
<p>I did some googling to understand how and where to implement the script you gave me and I think I've done it right (see image #1). I am running the report, but the axis is not updating. Er, as I am typing this, I realized that I am using a flipped axis orientation (see image #2), so I misspoke about the X axis. I am really trying to do this to the Y axis, yes?</p>
Clement Wong
<p>OS BIRT = Open Source BIRT = "Free" Edition</p>
<p> </p>
<p>For basic tasks, you shouldn't need to dive into the scripts. However, it's really nice to have since you'll be able to customize BIRT to your specific business requirements.</p>
<p> </p>
<p>You did find the right spot for the script. What I assumed is that you were using a line chart, and not bar.</p>
<p> </p>
<p>Actually, the easiest thing to do, now that I think about your requirements again, <strong>without</strong> scripting is... Add a filter to your chart!</p>
<p> </p>
<p>Select the Chart.</p>
<p>Under Property Editor - Chart (in the lower right pane), select the Filters tab.</p>
<p>Enter a filter condition.</p>
<p> </p>
<p style="margin-left:40px;">Here you can either build a expression like the following:</p>
<p style="margin-left:40px;"> </p>
<p style="margin-left:80px;"><em><em>BirtDateTime.year(</em>row["<em>YourDataSetColumn</em>"]) <strong>Greater than or Equal</strong> BirtDateTime.year(BirtDateTime.today())</em></p>
<p> </p>
<p> </p>
<p>Attached is an example created in OS BIRT 4.5.0.</p>
RakhiR
<p>Hello,</p>
<p> </p>
<p>Can you please help me to set start value of X-axis as min value of date column.</p>
<p> </p>
<p> I have set Origin as Min inside Y-Aixs properties. Now the min date is Oct 2012 , But the graph starts one step previous to this.</p>
<p> </p>
<p>No category Axis.</p>
Clement Wong
<p>Please provide whether you are using commercial, or open source BIRT? What version of BIRT you are using?</p>
<p> </p>
<p>Also, if you have an example design using Classic Models of what you already tried and replicates what you are currently seeing?</p>
<p> </p>
<p>(Please start a new thread in the future.)</p>