diff --git a/lib/functions.sh b/lib/functions.sh index ecf3d47..738018a 100755 --- a/lib/functions.sh +++ b/lib/functions.sh @@ -69,9 +69,6 @@ web() { sed -i "s/style=\"display:none;\" class=\"next\"/class=\"next\"/g" $WEBPATH/history/index_$datePrevious.html fi - # Export JSON for graph - source $GPATH/lib/transform_json.sh - # chown www-data for nginx needs chown -R www-data:www-data $WEBPATH >/dev/null 2>&1 } diff --git a/lib/transform_json.sh b/lib/transform_json.sh deleted file mode 100755 index 9c5c6ad..0000000 --- a/lib/transform_json.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/bash - -# Varialbes -n=2 # Nombre de jours pour les pas en abscisse - -#GPATH="$( cd "$(dirname "$0")" ; pwd -P )" -#if [[ -e $GPATH/.env ]]; then source $GPATH/.env; else echo "Veuillez créer votre fichier .env inspiré de .env.example" && exit 1; fi - - -## Ḡ1 reçus -rWallets() { - rWallets=$(grep -E "Date:|Reçus simples wallets|Reçus simples portefeuille|Reçus membres" $WEBPATH/history/index_*.html | awk -F '' '{ print $2 }' | awk '{ print $1 }' | tr -d '.' | tr ',' '.') - rWallets=$(sed '/-/i !' <<< $rWallets) - - local j=0 - local IFS=$'!' - for i in $rWallets; do - ((j++)) - [[ $j == 1 || ! $(( $j % $n )) == 0 ]] && continue - local dateN=$(sed '2q;d' <<< $i) - local RW=$(sed '3q;d' <<< $i) - local RM=$(sed '4q;d' <<< $i) - - local jsonTPL=$(sed s/_DATE/$dateN/g $GPATH/tpl/daily.json) - local jsonTPL=$(sed s/_RWALLETS/$RW/g <<< $jsonTPL) - local result+=$(sed s/_RMEMBERS/$RM/g <<< $jsonTPL) - done - - sed "s/_JSONDATA/$result/g" $GPATH/tpl/recus.html > $WEBPATH/graph/recus.html - sed "s/_JSONDATARW/$result/g" $GPATH/tpl/mixed.html > $WEBPATH/graph/mixed.html -} - -nbrWallets() { - ## Nombre de wallets - nbrWallets=$(grep -E "Date:|Nombre de membres|Nombre de simple portefeuille" $WEBPATH/history/index_*.html | awk -F '' '{ print $2 }' | awk -F '' '{ print $1 }' | awk '{ print $1 }') - nbrWallets=$(sed '/-/i !' <<< $nbrWallets) - - local j=0 - local IFS=$'!' - for i in $nbrWallets; do - ((j++)) - [[ $j == 1 || ! $(( $j % $n )) == 0 ]] && continue - local dateN=$(sed '2q;d' <<< $i) - local NBRM=$(sed '3q;d' <<< $i) - local NBRW=$(sed '4q;d' <<< $i) - - local jsonTPL=$(sed s/_DATE/$dateN/g $GPATH/tpl/nbr_wallets.json) - local jsonTPL=$(sed s/_NBRWALLETS/$NBRW/g <<< $jsonTPL) - local result+=$(sed s/_NBRMEMBERS/$NBRM/g <<< $jsonTPL) - done - - sed "s/_JSONDATA/$result/g" $GPATH/tpl/nbr_wallets.html > $WEBPATH/graph/nbr_wallets.html - sed -i "s/_JSONDATANBRW/$result/g" $WEBPATH/graph/mixed.html -} - -rWallets -nbrWallets diff --git a/tpl/css/charts.css b/tpl/css/charts.css index 9a3682e..d664528 100644 --- a/tpl/css/charts.css +++ b/tpl/css/charts.css @@ -1,6 +1,7 @@ #charts { width: 98%; margin-left: 0px; + overflow-x: scroll; } @media only screen and (max-width: 1100px) { diff --git a/tpl/graph.js b/tpl/graph.js new file mode 100644 index 0000000..7bc110d --- /dev/null +++ b/tpl/graph.js @@ -0,0 +1,134 @@ +var jsonfileRW = $.getJSON( "daily.json", function(data) { + var date = jsonfileRW.responseJSON.map(function(e) { + return e.date; + }); + var rwallets = jsonfileRW.responseJSON.map(function(e) { + return e.rWallets; + }); + var rmembers = jsonfileRW.responseJSON.map(function(e) { + return e.rMembers; + }); + var nbrwallets = jsonfileRW.responseJSON.map(function(e) { + return e.nbrWallets; + }); + var nbrmembers = jsonfileRW.responseJSON.map(function(e) { + return e.nbrMembers; + }); + + //ReceivedGraph + var ctx = document.getElementById("chartRW"); + var config = { + type: 'line', + data: { + labels: date, + datasets: [{ + label: 'Ḡ1 reçus sur les simples portefeuilles', + data: rwallets, + backgroundColor: 'rgba(0, 119, 204, 0.3)', + pointBorderWidth: 1, + pointHoverRadius: 8, + pointHoverBackgroundColor: "beige", + pointHoverBorderColor: "brown", + pointHoverBorderWidth: 2, + pointRadius: 3, + pointHitRadius: 8 + }, { + label: 'Ḡ1 reçus sur les portefeuilles membres', + data: rmembers, + backgroundColor: 'rgba(0, 178, 0, 0.3)', + pointBorderWidth: 1, + pointHoverRadius: 8, + pointHoverBackgroundColor: "beige", + pointHoverBorderColor: "brown", + pointHoverBorderWidth: 2, + pointRadius: 3, + pointHitRadius: 8 + }] + }, + options: { + maintainAspectRatio: true, + responsive: true + } + }; + var myChartRW = new Chart(ctx, config); + + + + + + + + // NbrWallets Graph + var ctx = document.getElementById("chartNBRW"); + var config = { + type: 'line', + data: { + labels: date, + datasets: [{ + label: 'Nombre de simple portefeuilles', + data: nbrwallets, + backgroundColor: 'rgba(0, 119, 204, 0.3)', + pointBorderWidth: 1, + pointHoverRadius: 8, + pointHoverBackgroundColor: "beige", + pointHoverBorderColor: "brown", + pointHoverBorderWidth: 2, + pointRadius: 3, + pointHitRadius: 8 + }, { + label: 'Nombre de portefeuilles membres', + data: nbrmembers, + backgroundColor: 'rgba(0, 178, 0, 0.3)', + pointBorderWidth: 1, + pointHoverRadius: 8, + pointHoverBackgroundColor: "beige", + pointHoverBorderColor: "brown", + pointHoverBorderWidth: 2, + pointRadius: 3, + pointHitRadius: 8 + }] + }, + options: { + maintainAspectRatio: true, + responsive: true + } + }; + + 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" ); + });*/ \ No newline at end of file diff --git a/tpl/mixed.html b/tpl/mixed.html index b3757d2..ecc39bd 100644 --- a/tpl/mixed.html +++ b/tpl/mixed.html @@ -4,8 +4,14 @@ Ḡ1 Stats - Graphiques - - + + + + + + + + @@ -22,121 +28,6 @@ - -