PivotTable.js – použitie

HTML:

<div id="output" style="margin: 30px;"></div>

JS:

<script type="text/javascript">

	$(function()
	{
        $("#output").pivotUI($("#tab_akvi"),
        {
            rows: ["Produktová skupina"],
            cols: ["Dátum"],
            vals: ["Predaj"],
    		aggregatorName: "Integer Sum",
            hiddenFromDragDrop: [],
            hideTotals: true,
        });
     });
</script>

Formátovanie čísiel:

<script type="text/javascript">
    // This example loads data from the HTML table below.

	$(function()
	{
		var sum = $.pivotUtilities.aggregatorTemplates.sum;
        var numberFormat = $.pivotUtilities.numberFormat;
        var intFormat = numberFormat({digitsAfterDecimal: 0, thousandsSep:" "});
		var heatmap =  $.pivotUtilities.renderers["Heatmap"];

        $("#output2").pivot($("#tab_akvi"),
        {
            rows: ["Produkt popis"],
            cols: ["Mesiac", "Week"],
			aggregator: sum(intFormat)(["Forecast ks"]),
			renderer: heatmap

        });
     });
</script>

PivotTable.js – inštalácia

https://github.com/nicolaskruchten/pivottable

https://cdnjs.com/libraries/pivottable

<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script> 
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/pivottable/2.23.0/pivot.min.css" integrity="sha512-BDStKWno6Ga+5cOFT9BUnl9erQFzfj+Qmr5MDnuGqTQ/QYDO1LPdonnF6V6lBO6JI13wg29/XmPsufxmCJ8TvQ==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/pivottable/2.23.0/pivot.min.js" integrity="sha512-XgJh9jgd6gAHu9PcRBBAp0Hda8Tg87zi09Q2639t0tQpFFQhGpeCgaiEFji36Ozijjx9agZxB0w53edOFGCQ0g==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>