gantt chart - bar doesn't show up

Hi
Im trying to connect my gantt chart with entity and have made some progress but the bar representing activity is not visible in the chart, please see the attached image.

Here is my screen xml, thanks for any help to know why the bars are missing!


<layout>
        <split height="100%"
               orientation="vertical"
               pos="26"
               width="100%">
            <groupTable id="planTable"
                        editable="true"
                        height="100px"
                        presentations="true"
                        width="100%">
                <columns>
                    <column id="productionPlan.resource"/>
                    <column id="article"/>
                    <column id="startDate"/>
                    <column id="duration"/>
                    <column id="endDate"/>
                    <column id="quantity"/>
                </columns>
                <rows datasource="productionPlanResourcesDs"/>
            </groupTable>
            <chart:ganttChart id="gantt"
                              balloonDateFormat="JJ:NN"
                              brightnessStep="10"
                              categoryField="resource"
                              columnWidth="0.5"
                              datasource="productionPlanDs"
                              durationField="duration"
                              endField="endDate"
                              height="100%"
                              marginRight="70"
                              period="DD"
                              rotate="true"
                              segmentsField="productionPlanResource"
                              startDate="2016-09-01"
                              startField="startDate"
                              theme="LIGHT"
                              width="100%">
                <chart:graph balloonText="[[task]]: [[open]] [[value]]"
                             fillAlphas="1"/>
                <chart:valueAxis maximum="31"
                                 minimum="7"
                                 type="DATE"/>
                <chart:chartScrollbar/>
                <chart:chartCursor cursorAlpha="0.1"
                                   fullWidth="true"
                                   valueBalloonsEnabled="false"
                                   valueLineBalloonEnabled="true"
                                   valueLineEnabled="true"/>
                <chart:export/>
            </chart:ganttChart>
        </split>
    </layout>

Snip20160913_2

Hi,
could you attach the code of your screen controller ?

Also, take a look at this demo: [url=https://demo.cuba-platform.com/sampler/open?screen=gantt-chart]https://demo.cuba-platform.com/sampler/open?screen=gantt-chart[/url] , where two entities are used to show tasks and segments on Gantt chart.

Hi
I have checked that example and not sure what is missing. There is nothing in the screen controller file as below:


package com.company.gui.productionplanchart;

import com.haulmont.cuba.gui.components.AbstractWindow;
import com.haulmont.cuba.gui.components.AbstractEditor;

public class Productionplanchart extends AbstractEditor {
}

Please compare your entities and data source definition with our demo.
If you don’t see any differences, then attach here your data source definition, view definition, and entity classes.
I suppose you haven’t specified collection property of task segments in your view for the data source.

Hi
I have checked but didn’t find anything that can help. Here is the codes for your info as suggested:

I have updated few missing definitions in xml file while comparing with the sample (though didn’t help)


<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<window xmlns="http://schemas.haulmont.com/cuba/window.xsd"
        caption="msg://caption"
        class="com.company.gui.productionplanchart.Productionplanchart"
        messagesPack="com.company.gui.productionplanchart"
        xmlns:chart="http://schemas.haulmont.com/charts/charts.xsd">
    <dsContext>
        <collectionDatasource id="productionPlanDs"
                              class="com.company.entity.ProductionPlan"
                              view="productionPlan-view">
            <query>
                <![CDATA[select e from mydb$ProductionPlan e]]>
            </query>
            <collectionDatasource id="productionPlanResourceDs"
                                  property="productionPlanResource"/>
        </collectionDatasource>
        <collectionDatasource id="productionPlanResourcesDs"
                              class="com.company.entity.ProductionPlanResource"
                              view="productionPlanResourceWinPlan-view">
            <query>
                <![CDATA[select e from mydb$ProductionPlanResource e]]>
            </query>
        </collectionDatasource>
        <collectionDatasource id="articlesDs"
                              class="com.company.entity.Article">
            <query>
                <![CDATA[select e from mydb$Article e]]>
            </query>
        </collectionDatasource>
    </dsContext>
    <layout>
        <split height="100%"
               orientation="vertical"
               pos="26"
               width="100%">
            <groupTable id="planTable"
                        editable="true"
                        height="100%"
                        presentations="true"
                        width="100%">
                <columns>
                    <column id="productionPlan.resource"/>
                    <column id="article"/>
                    <column id="startDate"/>
                    <column id="duration"/>
                    <column id="endDate"/>
                    <column id="quantity"/>
                </columns>
                <rows datasource="productionPlanResourcesDs"/>
            </groupTable>
            <chart:ganttChart id="gantt"
                              additionalSegmentFields="article"
                              balloonDateFormat="JJ:NN"
                              brightnessStep="10"
                              categoryField="resource"
                              colorField=""
                              columnWidth="0.5"
                              datasource="productionPlanDs"
                              durationField="duration"
                              endField="endDate"
                              height="100%"
                              marginRight="70"
                              period="DD"
                              rotate="true"
                              segmentsField="productionPlanResource"
                              startDate="2016-09-01"
                              startField="startDate"
                              theme="LIGHT"
                              width="100%">
                <chart:graph balloonText="[[article]]: [[open]] [[value]]"
                             fillAlphas="1"/>
                <chart:valueAxis maximum="31"
                                 minimum="7"
                                 type="DATE"/>
                <chart:chartScrollbar/>
                <chart:chartCursor cursorAlpha="0.1"
                                   fullWidth="true"
                                   valueBalloonsEnabled="false"
                                   valueLineBalloonEnabled="true"
                                   valueLineEnabled="true"/>
                <chart:export/>
            </chart:ganttChart>
        </split>
    </layout>
</window>

database table entity


@NamePattern("%s |planNo")
@Listeners("mydb_ProductionPlanListener")
@Table(name = "MYDB_PRODUCTION_PLAN")
@Entity(name = "mydb$ProductionPlan")
public class ProductionPlan extends StandardEntity {
    private static final long serialVersionUID = -4336136738212610911L;

    @Column(name = "PLAN_NO")
    protected Long planNo;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "FACTORY_ID")
    protected Factory factory;

    @Column(name = "PLAN_STATUS")
    protected String planStatus;


    @Composition
    @OnDelete(DeletePolicy.CASCADE)
    @OneToMany(mappedBy = "productionPlan")
    protected List<ProductionPlanResource> productionPlanResource;


    @Column(name = "TOTAL_PLAN_QUANTITY")
    protected BigDecimal totalPlanQuantity;

    @Transient
    @MetaProperty
    protected BigDecimal orderQuantity;





    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "RESOURCE_ID")
    protected Resource resource;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "FACTORY_PRODUCTION_STAGE_ID")
    protected FactoryProductionStage factoryProductionStage;

    public void setResource(Resource resource) {
        this.resource = resource;
    }

    public Resource getResource() {
        return resource;
    }

    public void setFactoryProductionStage(FactoryProductionStage factoryProductionStage) {
        this.factoryProductionStage = factoryProductionStage;
    }

    public FactoryProductionStage getFactoryProductionStage() {
        return factoryProductionStage;
    }


    public BigDecimal getOrderQuantity() {
        return orderQuantity;
    }


    public void setTotalPlanQuantity(BigDecimal totalPlanQuantity) {
        this.totalPlanQuantity = totalPlanQuantity;
    }

    public BigDecimal getTotalPlanQuantity() {
        return totalPlanQuantity;
    }


    public Long getPlanNo() {
        return planNo;
    }

    public void setPlanNo(Long planNo) {
        this.planNo = planNo;
    }


    public void setProductionPlanResource(List<ProductionPlanResource> productionPlanResource) {
        this.productionPlanResource = productionPlanResource;
    }

    public List<ProductionPlanResource> getProductionPlanResource() {
        return productionPlanResource;
    }


    public ProductionPlanStatus getPlanStatus() {
        return planStatus == null ? null : ProductionPlanStatus.fromId(planStatus);
    }

    public void setPlanStatus(ProductionPlanStatus planStatus) {
        this.planStatus = planStatus == null ? null : planStatus.getId();
    }


    public void setFactory(Factory factory) {
        this.factory = factory;
    }

    public Factory getFactory() {
        return factory;
    }
}

@Table(name = "MYDB_PRODUCTION_PLAN_RESOURCE")
@Entity(name = "mydb$ProductionPlanResource")
public class ProductionPlanResource extends StandardEntity {
    private static final long serialVersionUID = 4247328654429131368L;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "SALES_ORDER_ID")
    protected SalesOrder salesOrder;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "ARTICLE_ID")
    protected Article article;

    @Temporal(TemporalType.DATE)
    @Column(name = "START_DATE", nullable = false)
    protected Date startDate;

    @Column(name = "DURATION", nullable = false)
    protected Long duration;

    @Temporal(TemporalType.DATE)
    @Column(name = "END_DATE")
    protected Date endDate;

    @Column(name = "QUANTITY")
    protected BigDecimal quantity;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "PRODUCTION_PLAN_ID")
    protected ProductionPlan productionPlan;

    public void setSalesOrder(SalesOrder salesOrder) {
        this.salesOrder = salesOrder;
    }

    public SalesOrder getSalesOrder() {
        return salesOrder;
    }

    public void setArticle(Article article) {
        this.article = article;
    }

    public Article getArticle() {
        return article;
    }


    public Long getDuration() {
        return duration;
    }

    public void setDuration(Long duration) {
        this.duration = duration;
    }


    public void setQuantity(BigDecimal quantity) {
        this.quantity = quantity;
    }

    public BigDecimal getQuantity() {
        return quantity;
    }

    public void setProductionPlan(ProductionPlan productionPlan) {
        this.productionPlan = productionPlan;
    }

    public ProductionPlan getProductionPlan() {
        return productionPlan;
    }


    public void setStartDate(Date startDate) {
        this.startDate = startDate;
    }

    public Date getStartDate() {
        return startDate;
    }

    public void setEndDate(Date endDate) {
        this.endDate = endDate;
    }

    public Date getEndDate() {
        return endDate;
    }
}

any help?

I think we will be able to help you if you reproduce this problem in sample project and describe what you want to achieve in details. With all these files it is not clear what is wrong.

Hi Yuriy
Please find attached a sample project. There are some tables needs to be populated upfront though, thanks for your help.

gantt-demo copy.zip (28.6M)

And what about reproduction steps? I cannot understand all these screens.

What is the expected behaviour and what do you want to achieve?

Hi Yuriy
To simplify, I have uploaded a new version of demo gantt where you can generate initial data and you don’t need to go to many screens.

  1. After running for first time, generate initial data, generate from the screen button following the menu - InitialData, from Application menu
  2. Go to menu: productionplanganttchart from Application menu
    You will see the chart frame with no data. if you go to Production Plan menu, you will see data is there.

Thanks for any help getting the full chart generated with colour.

regards
Mortoza

ganttdemo2.zip (647.9K)

Hi,
I’ve checked your sample; it seems that you use startField and endField for Gantt chart configuration. According to AmCharts class reference (AmGanttChart | JavaScript Charts v. 3 | amCharts) if you want to use fields with type date for segments you have to use startDateField and endDateField.

Thank you so much. It worked nicely. I am advancing to usage of charts… I have another question regarding Listener that I am posting separately.

Mortoza