setting gantt chart axis scale

davefromaldavefromal Junior Member
edited December 1969 in Designing Analytics Reports
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

  • davefromaldavefromal Junior Member
    edited December 1969
    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!
  • mwilliamsmwilliams BIRT Guru
    edited December 1969
    Hi Dave,

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

    importPackage(Packages.org.eclipse.birt.chart.model.data.impl);

    Regards,

    Michael Williams

    eSignLive Evangelism & Community Manager | eSignLive by VASCO
     
    Find me on:
    Twitter
    Facebook
    Blog

    LinkedIn

    eSignLive Developer Community
     
    Email me:
    Google: [email protected]

  • mwilliamsmwilliams BIRT Guru
    edited December 1969
    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)));
    }

    Regards,

    Michael Williams

    eSignLive Evangelism & Community Manager | eSignLive by VASCO
     
    Find me on:
    Twitter
    Facebook
    Blog

    LinkedIn

    eSignLive Developer Community
     
    Email me:
    Google: [email protected]

  • edited December 1969
    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?
  • mwilliamsmwilliams BIRT Guru
    edited December 1969
    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!

    Regards,

    Michael Williams

    eSignLive Evangelism & Community Manager | eSignLive by VASCO
     
    Find me on:
    Twitter
    Facebook
    Blog

    LinkedIn

    eSignLive Developer Community
     
    Email me:
    Google: [email protected]

  • edited December 1969


    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!


    I uploaded an example report here:

    http://www.birt-exchange.org/org/devshare/designing-birt-reports/1509-gantt-chart-auto-axis-scale-example/
  • mwilliamsmwilliams BIRT Guru
    edited December 1969
    Try adding this code to your chart script:




    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);

    }

    Regards,

    Michael Williams

    eSignLive Evangelism & Community Manager | eSignLive by VASCO
     
    Find me on:
    Twitter
    Facebook
    Blog

    LinkedIn

    eSignLive Developer Community
     
    Email me:
    Google: [email protected]

  • edited December 1969


    Try adding this code to your chart script:




    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);

    }

    That works like a charm.

    Thank you very much!
  • mwilliamsmwilliams BIRT Guru
    edited December 1969
    You're welcome! Let us know whenever you have questions! :)

    Regards,

    Michael Williams

    eSignLive Evangelism & Community Manager | eSignLive by VASCO
     
    Find me on:
    Twitter
    Facebook
    Blog

    LinkedIn

    eSignLive Developer Community
     
    Email me:
    Google: [email protected]

  • edited October 2012
    Hello,



    How is the value "mmin" defined for both functions? The value "mmin" is not known by my beforeGeneration function.



    How can I define it as a global value for both functions in the script?




    Try adding this code to your chart script:




    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);

    }

    Regards

    Gokhan

  • mwilliamsmwilliams BIRT Guru
    edited December 1969
    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.

    Regards,

    Michael Williams

    eSignLive Evangelism & Community Manager | eSignLive by VASCO
     
    Find me on:
    Twitter
    Facebook
    Blog

    LinkedIn

    eSignLive Developer Community
     
    Email me:
    Google: [email protected]

  • 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.

Sign In or Register to comment.