This blog post solves an error I encountered while trying to display some data in a PrimeFaces line chart graph (Version 6.2). Each time I opened the page with the graph, the Browser crashed with an “Out of Memory” message in the console. The error always occurred in Primeface’s chart.js
It took me 1-2 hours to realize what the problem was. So I want to save you some time if you do the same mistake I did….
Here is the code I used to initialize the graph:
LineChartModel lineModel = new LineChartModel();
Axis yAxis = lineModel.getAxis(AxisType.Y);
long tickinterval = maxValue / 10;
maxValue (an integer value) is the maximum value used for the y-Axis. What I was trying to achieve here is, that there are around 10 horizonal lines drawn in the graph. Dividing the maximum value by 10 and setting this as the tick count should do the trick.
I would have expected the library to not allow this in the first place, but the solution simply is to make sure that the tick count never is 0.
long tickinterval = Math.max(maxValue / 10, 1);
So in the end it actually was my mistake, but I hope this at least helps someone else having the same problem.
If you have questions or comments, please leave a message below.