Home
Analytics
Gantt chart
Ronak
Hi sir,
I am preparing a gantt chart. In that I wants to dispaly the bar with different colour i.e if on vertical bar there is "SR" then it should display in Red color, id "BREAK" then White etc.
How to do it?
I think script to be used is "beforeDrawDataPoint(dph, fill, icsc)".
but I am not getting answer.
thanks
Find more posts tagged with
Comments
JasonW
Look at this example:
http://www.birt-exchange.org/org/devshare/designing-birt-reports/1357-gantt-chart-scripts/
You can uncomment the file io to see what dph value to check for your example.
Jason
Ronak
<blockquote class='ipsBlockquote' data-author="'JasonW'" data-cid="76106" data-time="1303317368" data-date="20 April 2011 - 09:36 AM"><p>
Look at this example:<br />
<a class='bbc_url' href='
http://www.birt-exchange.org/org/devshare/designing-birt-reports/1357-gantt-chart-scripts/'>http://www.birt-exchange.org/org/devshare/designing-birt-reports/1357-gantt-chart-scripts/</a><br
/>
<br />
You can uncomment the file io to see what dph value to check for your example.<br />
<br />
Jason<br /></p></blockquote>
Ronak
Thanks for the reply.
function beforeDrawDataPoint( dph, fill, icsc )
{
if( dph.getBaseDisplayValue() = "141"){
fill.set(255,0,0);
}
}
The above code didnt works?
can you correct it?
JasonW
Uncomment these lines:
//importPackage( Packages.java.io );
//out = new PrintWriter( new FileWriter( "c:/test/ganttchartevents.txt", true ) );
//out.println( "dph base"+dph.getBaseDisplayValue());
//out.println( "dph display"+dph.getOrthogonalDisplayValue());
//out.println( "dph series"+dph.getSeriesDisplayValue());
//out.close();
Change the directory in the second line and run the report. Verify its the base or orthogonal value you are checking.
Jason
Ronak
In gantt chart i added row["worktype"]+row[work] on vertical axis. now I wants to change colour based on that values. How to do that?
Ronak
I am having a scenario like, In the gantt chart the value displays on vertical axis i.e SR1011 in repeated three times for three different timings.
I want it to be displayed only once. And it should contian three different bars for different timings.
How to do that?
Thanks
JasonW
Can you post a report that I can run that shows the issue?
Jason
Ronak
I got the solution of the above discussed problem.
Now I got a new problem.
In my Gantt Chart I want the Timevalue on horizontal axis as per the user Requirements i.e When the user enter the time 5:00 or else then the Gant chart should be start from that duration to next like 5:00,5:30,6:00,6:30 etc.
I think I should use report Parameter here, but not getting solution.
How to do that ???
Thanks
JasonW
You could use the scale.setMin and Max methods. To get access to a report parameter do:
var cdt = icsc.getExternalContext().getScriptable().getParameterValue("myDtParm");
var dt = DateTimeDataElementImpl.create( new CDateTime(cdt) )
Jason
Ronak
<blockquote class='ipsBlockquote' data-author="'JasonW'" data-cid="76209" data-time="1303764716" data-date="25 April 2011 - 01:51 PM"><p>
You could use the scale.setMin and Max methods. To get access to a report parameter do:<br />
var cdt = icsc.getExternalContext().getScriptable().getParameterValue("myDtParm");<br />
var dt = DateTimeDataElementImpl.create( new CDateTime(cdt) )<br />
<br />
Jason<br /></p></blockquote>
<br />
<br />
Sorry I didn't get you. How to solve that problem. Can you explain it in brief.<br />
I don't know where to write the code you gave me.<br />
Thanks
Ronak
<blockquote class='ipsBlockquote' data-author="'Ronak'" data-cid="76215" data-time="1303797720" data-date="25 April 2011 - 11:02 PM"><p>
Sorry I didn't get you. How to solve that problem. Can you explain it in brief.<br />
I don't know where to write the code you gave me.<br />
Thanks<br /></p></blockquote>
<br />
<br />
<br />
<br />
<br />
1. Also I got new problem. In my Gantt Chart in the legend I am getting all the values as on y-axis. I dont want that. If the y-axis contains for SR with green color then in legend It should show only as SR with green icon instead of SR1,SR2,SR3,SR4 etc...<br />
2. Also how to remove the legend items if required to do that.
JasonW
You can turn off the legend in the third tab of the chart wizard. Just select the legend tree icon and uncheck the visibile box. To set the start scale hour of the chart look at the beforeGeneration script on the attached example.
function beforeGeneration(chart, icsc)
{
importPackage( Packages.org.eclipse.birt.chart.model.data.impl );
importPackage( Packages.org.eclipse.birt.chart.util );
rpctx = icsc.getExternalContext().getScriptable();
xAxis = chart.getBaseAxes()[0];
yAxis = chart.getOrthogonalAxes( xAxis, true)[0];
scale = yAxis.getScale();
var starthr = icsc.getExternalContext().getScriptable().getParameterValue("StartHour");
scale.setMin( DateTimeDataElementImpl.create( new CDateTime(2005,1,13,starthr,0) ) );
scale.setMax( DateTimeDataElementImpl.create( new CDateTime(2005,1,13,23,0) ) );
}
In this case I am getting an integer parameter StartHour and creating a cdate with the starthr variable.
Jason
Ronak
I didn't find the solution of that legend problem.
Still I wants only the SR to be displayed onnce.
I am sending you a pdf .
plz chek it out
thanks
JasonW
Can you post the design?
Jason
Ronak
here is design file
JasonW
I am still not certain what you need. You could always modify to hide lengend entries with a legend script like:
function beforeDrawLegendItem( lerh, bounds, icsc )
{
if( lerh.getValueLabel().getCaption().getValue() == "SR"){
bounds.setHeight(0);
bounds.setWidth(0);
lerh.getLabel().setVisible(false);
lerh.getValueLabel().setVisible(false);
lerh.getValueLabel().getCaption().setValue("");
}else{
lerh.getLabel().setVisible(true)
lerh.getValueLabel().setVisible(true);
}
}
This should hide all the SR values. Attached is an example report that does a lot of legend manipulation.
Jason
stuarts
I want it to be displayed only once. And it should contian three different bars for different timings.
JasonW
If you can create an example report that I can run that shows the issue I can modify it to do what you want.
Jason
Ronak
I got the solution of the above problem.
Now I want one help.
Can you provide me a simple report using excel file . Plz be careful it shouldn't be a csv file.
The excel file should be in .XLS or .XLSX format, So that I can change it's data in terms of font,size etc.
Ronak
Also I wants to know that how to print anything in birt report.
EG: like in java we use System.out.println().
Also,
How to work with excel file in birt with .XLS format.
JasonW
You can print to the cmd window but that would require running Eclipse from the command line. For debugging I generally just put in a command like:
importPackage( Packages.java.io );
out = new PrintWriter( new FileWriter( "c:/temp/events.txt", true ) );
out.println( "Initialize Event");
out.close();
I do not have an xls example.
Jason
Ronak
Can you tell me that if I have an .xls file then how I can create report with it.
i.e steps to do with it??
Ronak
Even, You can tell me if any link is there where I can find the report with .xls file,if possible
JasonW
I would look at writting a BIRT scripted datasource and use either POI or jXLS
http://jxls.sourceforge.net/index.html
to read the xls files.
Jason
Ronak
<blockquote class='ipsBlockquote' data-author="'JasonW'" data-cid="76610" data-time="1304532010" data-date="04 May 2011 - 11:00 AM"><p>
I would look at writting a BIRT scripted datasource and use either POI or jXLS <a class='bbc_url' href='
http://jxls.sourceforge.net/index.html'>http://jxls.sourceforge.net/index.html</a><br
/>
to read the xls files.<br />
<br />
Jason<br /></p></blockquote>
<br />
<br />
<br />
<br />
Please tell me that is it possible to engage the .XLs file in report or chart within birt???
JasonW
Sure its possible. If you create a scripted datasource that calls something like poi or jxls to read the xls file and use it as a datasource.
Jason
Ronak
Can you please send me a example or code how to do that. I am not able to import excel sheet in birt report
Ronak
<blockquote class='ipsBlockquote' data-author="'Ronak'" data-cid="76600" data-time="1304511327" data-date="04 May 2011 - 05:15 AM"><p>
I got the solution of the above problem.<br />
Now I want one help.<br />
Can you provide me a simple report using excel file . Plz be careful it shouldn't be a csv file. <br />
The excel file should be in .XLS or .XLSX format, So that I can change it's data in terms of font,size etc.<br /></p></blockquote>
<br />
<br />
<br />
I have now new query:<br />
In my gantt chart I told you previously, Now I want that gantt chart with parameters of user_id and date time along with hour it from where the time starts .<br />
for eg if in hour parameter if it enters & the the time starts from hour 7,8,...23.<br />
how to do it????
JasonW
I posted an example of how to do this on page one of this thread. Look at the GanttscriptScaleStartHour.rptdesign example I posted.
Jason
Ronak
Hii,
I am getting problem in generating parameter using datetime. How to do that??