Reputation: 190
Developing a Java8 application with jsf and primefaces, I encountered a small issue with the bar of my barChart which are overlapping. So my question is: How can I configure the width of the chart without impacting the interval of the axis?
My first idea was to modify the axis with xAxis.setTickInterval();
but the problem is that my axis is a DateAxis in month/year and it showed multiple times the same month in the axis (not multiple time the bar (cf the screenshot) reducing the overlapping).
And the code:
private void createChart() {
globalGradeEvolution = new BarChartModel();
globalGradeEvolution.setTitle("Evaluation globale");
globalGradeEvolution.setLegendPosition("e");
//Define two axis
Axis yAxis = globalGradeEvolution.getAxis(AxisType.Y);
DateAxis xAxis = new DateAxis("Dates");
//cacteristics of x axis
xAxis.setTickAngle(-30);
xAxis.setMax(LocalDate.now().getYear()+"-"+LocalDate.now().getMonthValue()+"-"+"15"); // middle of the month
xAxis.setTickFormat("%m/%Y"); // example: 08/2018
//cacteristics of y axis
yAxis.setLabel("Notes");
yAxis.setMin(min);
yAxis.setMax(10);
yAxis.setTickFormat("%.1f");
globalGradeEvolution.getAxes().put(AxisType.X, xAxis);
}
<h:form>
<p:chart type="bar" model="#{statChartView.globalGradeEvolution}" style="height:400px" responsive="true"/>
</h:form>
Upvotes: 1
Views: 587
Reputation: 12019
This is a bug in PrimeFaces + JqPlot combination.
The bug has been reported to PrimeFaces here: https://github.com/primefaces/primefaces/issues/3684
Upvotes: 1