I have a report with two time parameters, and I want them to define the maximum and minimum X axis scale in a chart. I have found <a class='bbc_url' href='
http://www.birt-exchange.org/org/devshare/designing-birt-reports/830-setting-the-min-and-max-value-of-the-xaxis-with-scripting/'>this</a> that describes how to do it with dates, but I am unable to figure out how to do it with times.<br />
<br />
This is my latest effort:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>importPackage(Packages.org.eclipse.birt.chart.model.data.impl);
function beforeGeneration( chart, icsc )
{
/* This script will change the Min and Max value of the X axis based on the value
for the Start and End date parameters.
NB: In order to work, make sure to turn OFF the "Is Category Axis" attribute
in the X-Axis properties screen
*/
/* Get the start and end dates from the parameters */
start_time_p = icsc.getExternalContext().getScriptable().getParameterValue("start_time");
finish_time_p = icsc.getExternalContext().getScriptable().getParameterValue("finish_time");
start_time = new Date( (start_time_p.getHours() + 1) + ":" + start_time_p.getMinutes() + ":" + start_time_p.getSeconds() );
/* Get the X-Axis object */
xAxisArray = chart.getBaseAxes();
/* Set the Min and Max values */
xAxisArray[0].getScale().setMin(DateTimeDataElementImpl.create(start_time));
}</pre>
<br />
But I understand that the constructor of a date object requires a long integer, which is probably why I get this error:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>Cannot convert Invalid Date to java.lang.Long at line 34 of chart script:'' (Element ID:71)</pre>
<br />
Any help getting this working will be very much appreciated,<br />
<br />
Thanks,<br />
Stephen