Create data reports using javascript function

Assume you have a sporting event or competition. Most likely the results will be stored in a database and have to be listed on a website. You can use the Fetch Api to fetch the data from the backend. This will not be explained in this document. I assume the data has already been retrieved and is an array of records.

General structure of a report:

Most sections are just html tables or html flex items.

Example of report structure:

Structure of report definition object called reportDefinition:

Examples of headers and footers array elements:

Example of compare function:

Running counter

In case you want to implement a running counter, you have to initialize/reset it in the right place. It can be achieved by putting some code in the relevant header:

If you only want to initialize objWork.runningCounter at the beginning of the report you can achieve that by putting the right code in reportDefinition.headers[0]. I call it property runningCounter, but you can give it any name you want.

You have to increase the running counter somewhere in your code because... otherwise it is not running ;-) for example:

How to create totals for multiple section levels, a running total and even a numbered header?

How to preprocess the source array on the fly (for example in click event)?

How to generate the report?

Source code:

Below source code I created to make this all work. It is kind of wrapper function for all headers and footers. Feel free to copy paste it and use it in your own module.

What is objWork?

objWork is a javascript object that is passed as the second argument to createOutput function. It is passed on as shallow copy to headers functions, footers functions, compare function, init function, source function and display function. All these functions share this object. You can use it for example for configuration information or color theme. objWork is automagically extended with { rawData: thisData }. For example createOutput(reportDefinition, { font: 'Arial', font_color: 'blue' }).


Reports for petanque
Reports for billiard club
Reports for billiard scores
More reports for carom billiards
and many more....
For remarks or extra information you can reach me by sending email to