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>