From 7d9b71fa5496c8355570d10cfcb605ec65f4a109 Mon Sep 17 00:00:00 2001 From: poka Date: Fri, 2 Oct 2020 21:34:49 +0200 Subject: [PATCH] Beautify graph view; Improve cumulate.jq syntaxe --- lib/cumulate.jq | 19 ++++++-------- tpl/js/graph.js | 68 +++++++++++-------------------------------------- 2 files changed, 23 insertions(+), 64 deletions(-) diff --git a/lib/cumulate.jq b/lib/cumulate.jq index 1cd1980..370035c 100644 --- a/lib/cumulate.jq +++ b/lib/cumulate.jq @@ -1,13 +1,10 @@ def round: . + 0.5 | floor; def roundit: .*100.0|round/100.0; -[foreach .[] as $row ({nbrMembers: 0, nbrWallets: 0, sMembers: 0, rMembers: 0, sWallets: 0, rWallets: 0}; - { - nbrMembers: ($row.nbrMembers + .nbrMembers), - nbrWallets: ($row.nbrWallets + .nbrWallets), - sMembers: ($row.sMembers + .sMembers|roundit), - rMembers: ($row.rMembers + .rMembers|roundit), - sWallets: ($row.sWallets + .sWallets|roundit), - rWallets: ($row.rWallets + .rWallets|roundit) - }; - $row * . -)] +[foreach .[] as $row (null; + .nbrMembers += $row.nbrMembers | + .nbrWallets += $row.nbrWallets | + .sMembers = ($row.sMembers + .sMembers|roundit) | + .rMembers = ($row.rMembers + .rMembers|roundit) | + .sWallets = ($row.sWallets + .sWallets|roundit) | + .rWallets = ($row.rWallets + .rWallets|roundit); + $row + . )] \ No newline at end of file diff --git a/tpl/js/graph.js b/tpl/js/graph.js index 9fc5683..41a891e 100644 --- a/tpl/js/graph.js +++ b/tpl/js/graph.js @@ -15,7 +15,9 @@ var jsonfileRW = $.getJSON( "../data/cum-daily.json", function(data) { return e.nbrMembers; }); - //ReceivedGraph + //var optionsGen = 'pointBorderWidth: 1, pointHoverRadius: 6, pointHoverBackgroundColor: "beige", pointHoverBorderColor: "brown", pointHoverBorderWidth: 2, pointRadius: 1, pointHitRadius: 4'; + + //Received Graph var ctx = document.getElementById("chartRW"); var config = { type: 'line', @@ -26,23 +28,23 @@ var jsonfileRW = $.getJSON( "../data/cum-daily.json", function(data) { data: rwallets, backgroundColor: 'rgba(0, 119, 204, 0.3)', pointBorderWidth: 1, - pointHoverRadius: 8, + pointHoverRadius: 6, pointHoverBackgroundColor: "beige", pointHoverBorderColor: "brown", pointHoverBorderWidth: 2, - pointRadius: 3, - pointHitRadius: 8 + pointRadius: 1, + pointHitRadius: 4 }, { label: 'Ḡ1 reçus sur les portefeuilles membres', data: rmembers, backgroundColor: 'rgba(0, 178, 0, 0.3)', pointBorderWidth: 1, - pointHoverRadius: 8, + pointHoverRadius: 6, pointHoverBackgroundColor: "beige", pointHoverBorderColor: "brown", pointHoverBorderWidth: 2, - pointRadius: 3, - pointHitRadius: 8 + pointRadius: 1, + pointHitRadius: 4 }] }, options: { @@ -53,11 +55,6 @@ var jsonfileRW = $.getJSON( "../data/cum-daily.json", function(data) { var myChartRW = new Chart(ctx, config); - - - - - // NbrWallets Graph var ctx = document.getElementById("chartNBRW"); var config = { @@ -69,23 +66,23 @@ var jsonfileRW = $.getJSON( "../data/cum-daily.json", function(data) { data: nbrwallets, backgroundColor: 'rgba(0, 119, 204, 0.3)', pointBorderWidth: 1, - pointHoverRadius: 8, + pointHoverRadius: 6, pointHoverBackgroundColor: "beige", pointHoverBorderColor: "brown", pointHoverBorderWidth: 2, - pointRadius: 3, - pointHitRadius: 8 + pointRadius: 1, + pointHitRadius: 4 }, { label: 'Nombre de portefeuilles membres', data: nbrmembers, backgroundColor: 'rgba(0, 178, 0, 0.3)', pointBorderWidth: 1, - pointHoverRadius: 8, + pointHoverRadius: 6, pointHoverBackgroundColor: "beige", pointHoverBorderColor: "brown", pointHoverBorderWidth: 2, - pointRadius: 3, - pointHitRadius: 8 + pointRadius: 1, + pointHitRadius: 4 }] }, options: { @@ -97,38 +94,3 @@ var jsonfileRW = $.getJSON( "../data/cum-daily.json", function(data) { var myChartNBRW = new Chart(ctx, config); }); - - - - - - - - - - - - - - - - - - - - - - - -/*var jqxhr = $.getJSON( "example.json", function() { - console.log( "success" ); - }) - .done(function() { - console.log( "second success" ); - }) - .fail(function() { - console.log( "error" ); - }) - .always(function() { - console.log( "complete" ); - });*/