setting gantt chart axis scale

davefromal
edited February 11, 2022 in Analytics #1
hi, i have a gantt chart with a datetime axis along the bottom. When I set the origin to MIN, it always has the origin 1 time unit earlier than the minimum data point. This means I always have a blank day at the start, which i can't have.

I've tinkered with setting axis scales:

function afterDataSetFilled( series, dataSet, icsc )
{

chart=icsc.getChartInstance();
xAxis = chart.getBaseAxes()[0];
yAxis = chart.getOrthogonalAxes( xAxis, true )[0];

xAxis1=chart.getOrthogonalAxes(xAxis,true)[0];
xScale=xAxis1.getScale();


v=DateTimeDataElementImpl.Create("3/3/2000");
xScale.setMin(v);

}

but I get errors about DateTimeDataElementImpl not being defined. This all seems so difficult, please help!

thanks
dave

Comments

  • davefromal
    edited December 31, 1969 #2
    ok to simplify the problem, can any show some code to set the axis origin of a chart datetime axis to the value of a report parameter?

    thanks!
  • mwilliams
    edited December 31, 1969 #3
    Hi Dave,

    To use DateTimeDataElementImpl, you'll need to import the appropriate package:

    importPackage(Packages.org.eclipse.birt.chart.model.data.impl);
    Warning No formatter is installed for the format ipb
  • mwilliams
    edited December 31, 1969 #4
    Dave,

    Try something like this:

    function beforeGeneration( chart, icsc )
    {
    importPackage(Packages.org.eclipse.birt.chart.model.data.impl);
    importPackage( Packages.org.eclipse.birt.chart.util);

    xAxis = chart.getBaseAxes()[0];
    yAxis = chart.getOrthogonalAxes( xAxis, true )[0];

    xScale=xAxis.getScale();

    xScale.setMin(DateTimeDataElementImpl.create(new CDateTime(2000,3,3,0,0)));
    }
    Warning No formatter is installed for the format ipb
  • RaphaelM
    edited December 31, 1969 #5
    Hello,

    I'm replying to this old thread because i have exactly the same problem as the author:
    The y axis of the gantt chart starts one time unit earlier than the min value.

    Is there a way to start exactly with the min value and keep auto scaling?
  • mwilliams
    edited December 31, 1969 #6
    Can you set up a simple example that shows your issue using the Classic Models, sample database and attach it in here for me to look at and test on? Thanks!
    Warning No formatter is installed for the format ipb
  • RaphaelM
    edited December 31, 1969 #7
    <blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="100105" data-time="1336492032" data-date="08 May 2012 - 08:47 AM"><p>
    Can you set up a simple example that shows your issue using the Classic Models, sample database and attach it in here for me to look at and test on? Thanks!<br /></p></blockquote>
    I uploaded an example report here:<br />
    <a class='bbc_url' href='http://www.birt-exchange.org/org/devshare/designing-birt-reports/1509-gantt-chart-auto-axis-scale-example/'>http://www.birt-exchange.org/org/devshare/designing-birt-reports/1509-gantt-chart-auto-axis-scale-example/</a&gt;
  • mwilliams
    edited December 31, 1969 #8
    Try adding this code to your chart script:<br />
    <br />
    <pre class='_prettyXprint _lang-auto _linenums:0'>
    importPackage( Packages.org.eclipse.birt.chart.model.type.impl );
    importPackage( Packages.org.eclipse.birt.chart.util);
    importPackage(Packages.org.eclipse.birt.chart.model.data.impl);

    function afterDataSetFilled(series, dataSet, icsc)
    {

    ps = PluginSettings.instance( );

    dsp = ps.getDataSetProcessor( series.getClass() );
    //find min date
    if (series.getSeriesIdentifier() == "Series 1"){
    mmin = dsp.getMinimum( dataSet );
    mmax = dsp.getMaximum( dataSet );
    }

    }


    function beforeGeneration( chart, icsc )
    {

    var yAxis = chart.getAxes().get(0).getAssociatedAxes().get(0);
    var yScale = yAxis.getScale();
    yScale.setMin(DateTimeDataElementImpl.create(mmin));
    yScale.setMax(DateTimeDataElementImpl.create(mmax));
    yAxis.setScale(yScale);

    }
    </pre>
    Warning No formatter is installed for the format ipb
  • RaphaelM
    edited December 31, 1969 #9
    <blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="100181" data-time="1336600659" data-date="09 May 2012 - 02:57 PM"><p>
    Try adding this code to your chart script:<br />
    <br />
    <pre class='_prettyXprint _lang-auto _linenums:0'>
    importPackage( Packages.org.eclipse.birt.chart.model.type.impl );
    importPackage( Packages.org.eclipse.birt.chart.util);
    importPackage(Packages.org.eclipse.birt.chart.model.data.impl);

    function afterDataSetFilled(series, dataSet, icsc)
    {

    ps = PluginSettings.instance( );

    dsp = ps.getDataSetProcessor( series.getClass() );
    //find min date
    if (series.getSeriesIdentifier() == "Series 1"){
    mmin = dsp.getMinimum( dataSet );
    mmax = dsp.getMaximum( dataSet );
    }

    }


    function beforeGeneration( chart, icsc )
    {

    var yAxis = chart.getAxes().get(0).getAssociatedAxes().get(0);
    var yScale = yAxis.getScale();
    yScale.setMin(DateTimeDataElementImpl.create(mmin));
    yScale.setMax(DateTimeDataElementImpl.create(mmax));
    yAxis.setScale(yScale);

    }
    </pre></p></blockquote>
    That works like a charm.<br />
    Thank you very much!
  • mwilliams
    edited December 31, 1969 #10
    You're welcome! Let us know whenever you have questions! :)
    Warning No formatter is installed for the format ipb
  • gyuksel
    edited October 10, 2012 #11
    Hello,<br />
    <br />
    How is the value "mmin" defined for both functions? The value "mmin" is not known by my beforeGeneration function.<br />
    <br />
    How can I define it as a global value for both functions in the script?<br />
    <br />
    <blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="100181" data-time="1336600659" data-date="09 May 2012 - 02:57 PM"><p>
    Try adding this code to your chart script:<br />
    <br />
    <pre class='_prettyXprint _lang-auto _linenums:0'>
    importPackage( Packages.org.eclipse.birt.chart.model.type.impl );
    importPackage( Packages.org.eclipse.birt.chart.util);
    importPackage(Packages.org.eclipse.birt.chart.model.data.impl);

    function afterDataSetFilled(series, dataSet, icsc)
    {

    ps = PluginSettings.instance( );

    dsp = ps.getDataSetProcessor( series.getClass() );
    //find min date
    if (series.getSeriesIdentifier() == "Series 1"){
    mmin = dsp.getMinimum( dataSet );
    mmax = dsp.getMaximum( dataSet );
    }

    }


    function beforeGeneration( chart, icsc )
    {

    var yAxis = chart.getAxes().get(0).getAssociatedAxes().get(0);
    var yScale = yAxis.getScale();
    yScale.setMin(DateTimeDataElementImpl.create(mmin));
    yScale.setMax(DateTimeDataElementImpl.create(mmax));
    yAxis.setScale(yScale);

    }
    </pre></p></blockquote>
    Warning No formatter is installed for the format ipb
  • mwilliams
    edited December 31, 1969 #12
    It should work, as is, as long as your series is named "Series 1", which is the default. If you've change the series name, mmin will not get set, because the check for it being called "Series 1" will not be satisfied, and you'll get an error.
    Warning No formatter is installed for the format ipb
  • Hello ,
    I am trying to create same time of graph with custom columns on x axis trying to set date min and max and on y axis workitem count.

    markerLine.setValue(DateTimeDataElementImpl.create(new Date(y,m,d)));

    this line of code gives me below error.

    Cannot convert Invalid Date to java.lang.Long at line 34 of chart script: '

    Can you please suggest what is wrong, I tried using CDateTime method too.and imported all packages also.