In this recipe, we will see how to feed data to the OFC chart using a SharedResource
. The advantage of this technique, over using a component-callback, is that all charts on the page can get their data asynchronously because access to SharedResources is not synchronized to a single thread per page. This will reduce the total time to load the page and make the application feel more responsive. This will make a big difference when we have multiple charts on the page as follows:
Let's get started by implementing the chart by using a component callback to retrieve the data.
Implement
StockService
that will feed us chart data; see the first recipe for code listing.Implement the
Chart
component. Refer toChart.template
andChart.data.template
in the code bundle for the data setup of the chart.Chart.java
public class Chart extends WebComponent implements IHeaderContributor, IResourceListener { public Chart(String id, IModel<String...