AreaChart once again - chart and data not showing

UI Components for JSF
Post Reply
User avatar
doughnut
Posts: 27
Joined: 30 Sep 2014, 16:18

20 Oct 2014, 15:46

Hello together

in my application, I am about to use an AreaChart (that is basically a LineChart with setFill and setStacked set to true.
(as shown in the show case: http://www.primefaces.org/showcase/ui/chart/area.xhtml)

Unfortunately, when I indeed have setStacked set to true, the chart is just not showing altogether.
I already had this with "dummy" data and then changed x axis to CategoryAxis (from DateAxis), then the chart was showing.
Now I already have a CategoryAxis, and chart still does not show when stacked=true.

I wonder what may still be wrong?
With non-dummy data, there are 43 series added to the chart. Can this be too much for stacked=true?
Otherwise the data are fine, since as a line chart, everything works perfectly.

Bean excerpt (chart model setup):

Code: Select all

import org.primefaces.model.chart.Axis;
import org.primefaces.model.chart.AxisType;
import org.primefaces.model.chart.CategoryAxis;
import org.primefaces.model.chart.LineChartModel;
import org.primefaces.model.chart.LineChartSeries;

import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.inject.Inject;
import java.io.Serializable;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

@ViewScoped
@ManagedBean
public class Bean implements Serializable {

        // ...
	// getters-setters
        // business logic
	
    public LineChartModel buildLineChartModel(final List<List<NodeObject>> nodeObjectList) {
        final LineChartModel areaModel = new LineChartModel();
        for (final List<PartnerDomainNamesByDate> currentList : nodeObjectList) {
            // ....           
	     // add data series extracted from argument list			
        }
        areaModel.setLegendPosition("ne");
        areaModel.setStacked(true);
        areaModel.setZoom(true);

        final CategoryAxis xAxis = new CategoryAxis("Datum");
        xAxis.setTickAngle(-50);
        areaModel.getAxes().put(AxisType.X, xAxis);
        final Axis yAxis = areaModel.getAxis(AxisType.Y);
        yAxis.setMin(0);
        yAxis.setLabel("Anzahl");       
        return areaModel;
    }
}

... and the .xhtml:

Code: Select all

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                template="/templates/template.xhtml">
    <ui:define name="metadata">
    </ui:define>
    <ui:define name="content">
        <h:form id="mainForm">
            <p:tabView id="mainTabView">
                <p:tab id="tab1" title="#{msg['tabview.title.tagesansicht']}">
                    <div align="center">
                        <h:outputText
                                value="#{msg['report.areachart.title']}"/>
                    </div>
                    <div align="center" style="margin-top:30px">
                        <p:chart type="line" model="#{bean.areaByDateModel}"
                                 style="height:400px; width:800px; margin-top:20px; margin-bottom:5px; border-style: #{bean.chartBorderStyle}; border-width: 2px;"
                                 widgetVar="areaChart">
                            <h:outputText value="#{bean.messageForNoChartData}"/>
                        </p:chart>                      
                    </div>
                </p:tab>
                <p:tab id="tab2" title="#{msg['tabview.title.monatsansicht']}">
                    <div align="center">
                        <h:outputText
                                value="#{msg['report.areachart.title']}"/>
                    </div>
                    <div align="center" style="margin-top:30px">
                        <p:chart type="line" model="#{bean.areaByMonthModel}"
                                 style="height:400px; width:800px; margin-top:20px; margin-bottom:5px; border-style: #{bean.chartBorderStyle}; border-width: 2px;"
                                 widgetVar="areaChartMonthBased">
                            <h:outputText value="#{bean.messageForNoChartData}"/>
                        </p:chart>                       
                    </div>
                </p:tab>
            </p:tabView>
        </h:form>     
    </ui:define>
</ui:composition>
PrimeFaces v. 5.0
JSF: MyFaces impl. v. 2.2.2
Server WildFly v. 8.1.0
IntelliJ IDEA 13.1.3

User avatar
doughnut
Posts: 27
Joined: 30 Sep 2014, 16:18

22 Oct 2014, 09:32

I wonder what may still be wrong?
It can be naroowed down to a data series-related problem.

If I restrict the data series ranges thus that every data series has the same number of points, then the chart and content show as expected.
This also works if abscissa values are different from series to series.

Once the number of points is not the same in all of the added data series, the chart display fails altogether (blank area only).
PrimeFaces v. 5.0
JSF: MyFaces impl. v. 2.2.2
Server WildFly v. 8.1.0
IntelliJ IDEA 13.1.3

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

22 Oct 2014, 09:58

Can you check if this is a problem with plain jqplot as well.?

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 24 guests