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)
Expand field chart Gantt
_Petr
When I build chart Gantt the series of diagrams overlap<br />
<a class='bbc_url' href='
http://www.pictureshack.ru/view_7615gannt.png'><img
src='
http://www.pictureshack.ru/thumbs/7615gannt.png'
alt='Posted Image' class='bbc_img' /></a><br />
How expand field chart?
Find more posts tagged with
Comments
mwilliams
Hi _Petr,
Does resizing the chart in your layout not help?
_Petr
No, all data for chart this List<new Gantt()>, so don't fixed hight and width for chart. How do dynamically resize field chart?<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
public List<GanttData> getGanttData() throws GranException {
List<GanttData> ganttDatas = new ArrayList<GanttData>();
if (tasks != null) {
for (SecuredTaskBean stb : tasks) {
String name = stb.getName() + "[#" + stb.getNumber() + "]";
Date updateDate = stb.getUpdatedate() != null ? stb.getUpdatedate().getTime() : null;
Date deadlineDate = stb.getDeadline() != null ? stb.getDeadline().getTime() : null;
Date submitDate = stb.getSubmitdate() != null ? stb.getSubmitdate().getTime() : null;
ganttDatas.add(new GanttData(name, submitDate, updateDate, deadlineDate));
}
}
Collections.sort(ganttDatas);
return ganttDatas;
}
</pre>
mwilliams
_Petr,
If you can check the length of your array to know how much data you're displaying, you should be able to resize your chart in the beforeGeneration script of the chart.
_Petr
mwilliams. Thanks a lot.<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
var ganttChart = this.getReportElement("GanttChart");
gsh = new Packages.com.trackstudio.app.report.birt.gantt.GanttDao();
gantt = gsh.getGanttData();
var height = gantt.size() * 5;
var width = gantt.size();
//ganttChart.setWidth(width+"pixels");
ganttChart.setHeight(height+"mm");
</pre>
mwilliams
Glad to help!
_Petr
I have got another question. How in script change series name? And where I can find JavaString API for Chart?
mwilliams
Do you want to change the actual series name, or just the name in the label in the chart?
_Petr
Just the name in the label.
mwilliams
If you know the names of the series' in the chart, you can do something like this:
function beforeDrawLegendItem( lerh, bounds, icsc )
{
if (lerh.getLabel().getCaption().getValue() == "currentSeriesName"){
lerh.getLabel().getCaption().setValue("newSeriesName");
}
}
Let me know if this works for you.
_Petr
Yes. It is working. Thanks.
_Petr
But I have got new problem. Name series does not fit in field chart.<br />
<a class='bbc_url' href='
http://img541.imageshack.us/i/201010011636571680x1050.png/'><img
src='
http://img541.imageshack.us/img541/5301/201010011636571680x1050.th.png'
alt='Posted Image' class='bbc_img' /></a><br />
[/URL]<br />
How enlarge width field by label name?
mwilliams
See if changing the actual series name helps it adjust on its own.
function beforeGeneration( chart, icsc )
{
importPackage(Packages.java.util);
importPackage(Packages.org.eclipse.birt.chart.model.data.impl);
importPackage(Packages.org.eclipse.birt.chart.model.component.impl);
importPackage(Packages.org.eclipse.birt.chart.model.type.impl);
importPackage(Packages.org.eclipse.birt.chart.model.attribute);
var xAxis = chart.getAxes().get(0);
var yAxis = xAxis.getAssociatedAxes().get(0);
var xSerieDef = xAxis.getSeriesDefinitions().get(0);
var ySerieDef1 = yAxis.getSeriesDefinitions().get(0);
var ySerieDef2 = yAxis.getSeriesDefinitions().get(1);
ySerieDef1.getSeries().get(0).setSeriesIdentifier("My Series 1");
ySerieDef2.getSeries().get(0).setSeriesIdentifier("My Series 2");
}