]> git.immae.eu Git - perso/Denise/oms.git/commitdiff
couleurs personnalisables, affichage amélioré (on peut masquer notamment).
authorDenise sur Lya <sekhmet@lya>
Thu, 18 Jun 2020 21:52:53 +0000 (23:52 +0200)
committerDenise sur Lya <sekhmet@lya>
Thu, 18 Jun 2020 21:52:53 +0000 (23:52 +0200)
14 files changed:
.gitignore [new file with mode: 0644]
COPYING [new file with mode: 0644]
app.py
configuration.py
data/changelog_data.txt
data_OMS/licence [new file with mode: 0644]
gestionOMS.py
gestion_couleurs.py [new file with mode: 0644]
gestion_donnees.py
licence [new file with mode: 0644]
static/style.css
templates/apropos.html
templates/index.html
trace_courbe.py

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..b25c15b
--- /dev/null
@@ -0,0 +1 @@
+*~
diff --git a/COPYING b/COPYING
new file mode 100644 (file)
index 0000000..d50c38d
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,5 @@
+--------------
+Attention : application de licences :
+
+Le dossier data_OMS est sous licence CC BY-NC-SA 3.0 IGO
+Le reste du projet est sous licence 
diff --git a/app.py b/app.py
index 0d2054bbc9cc4a825b2525fa0e9d078b95a190ab..3deb7f68eaf9911c06bd5449886cd1662054f56f 100644 (file)
--- a/app.py
+++ b/app.py
@@ -45,6 +45,8 @@ def courbe_image(ext):
     # Régler la configuration et les données    
     config = gere_configuration(data,liste_err)    
     l_jours,l_poids = gere_donneespoids(data,config["naissance"],liste_err)
     # Régler la configuration et les données    
     config = gere_configuration(data,liste_err)    
     l_jours,l_poids = gere_donneespoids(data,config["naissance"],liste_err)
+    
+    #print(config)
 
     texte = donnees_vers_json(l_jours,l_poids,config)
     
 
     texte = donnees_vers_json(l_jours,l_poids,config)
     
@@ -56,6 +58,7 @@ def courbe_image(ext):
         fig = cree_figure(config,l_jours,l_poids,liste_err)
         result = "success"
         output = io.BytesIO()
         fig = cree_figure(config,l_jours,l_poids,liste_err)
         result = "success"
         output = io.BytesIO()
+        #warning("Là ça va",liste_err)
         FigureCanvas(fig).print_png(output)
         plt.close(fig)
     except:
         FigureCanvas(fig).print_png(output)
         plt.close(fig)
     except:
index ef017faff4613aae6ee96d4b522bdbda009788b4..e173ad92a2751639ebd427d641f4a651ab17e1fa 100644 (file)
@@ -17,9 +17,11 @@ f_poids_perc_mixte = chemin_oms+"wfa_mix_p_exp.txt"
 # Pour les courbes percentiles
 liste_data_choisie_p = [(5,1),(7,5),(8,10),(10,25),(11,50),(12,75), (14,90),
               (15,95),(17,99)]
 # Pour les courbes percentiles
 liste_data_choisie_p = [(5,1),(7,5),(8,10),(10,25),(11,50),(12,75), (14,90),
               (15,95),(17,99)]
+liste_data_choisie_p.sort(reverse=True)
 
 # pour le sigma : (colonne,sigma)
 liste_data_choisie_z = [(2,-3),(3,-2),(4,-1),(5,0),(6,1),(7,2),(8,3)]
 
 # pour le sigma : (colonne,sigma)
 liste_data_choisie_z = [(2,-3),(3,-2),(4,-1),(5,0),(6,1),(7,2),(8,3)]
+liste_data_choisie_z.sort(reverse=True)
 
 liste_unites_valides = ["jours", "semaines", "mois", "années"]
 
 
 liste_unites_valides = ["jours", "semaines", "mois", "années"]
 
@@ -52,6 +54,24 @@ hauteur_graphique_min = 2
 # Nombre de lignes par défaut dans le formulaire
 nombre_lignes_form = 5
 
 # Nombre de lignes par défaut dans le formulaire
 nombre_lignes_form = 5
 
+# couleurs par défaut
+couleur_defaut_1 = "#0000FF" # bleu
+couleur_defaut_2 = "#00FF00" # vert
+couleur_defaut_3 = "#FF0000" # rouge
+couleur_defaut_1_tuple = (0,0,1)
+couleur_defaut_2_tuple = (0,1,0)
+couleur_defaut_3_tuple = (1,0,0)
+
+# couleurs par défaut fond
+couleur_defaut_fond = "#FFFFFF"
+couleur_defaut_fond_tuple = (1,1,1)
+couleur_defaut_cadretxt = "#000000"
+couleur_defaut_cadretxt_tuple = (0,0,0)
+couleur_defaut_grille = "#7f7f7f"
+couleur_defaut_grille_tuple = (0.5,0.5,0.5)
+
+#couleur_defaut_erreur = (0,0,0) # noir
+
 
 # initialiser la config
 def config_init():
 
 # initialiser la config
 def config_init():
@@ -60,6 +80,13 @@ def config_init():
             "nb_data":nombre_lignes_form,
             "age_0": "0j",
             "legende": "oui",
             "nb_data":nombre_lignes_form,
             "age_0": "0j",
             "legende": "oui",
-            "positionlegende": "hg"}
+            "positionlegende": "hg",
+            "couleur1": couleur_defaut_1,
+            "couleur2": couleur_defaut_2,
+            "couleur3": couleur_defaut_3,
+            "couleur_fond": couleur_defaut_fond,
+            "couleur_grille": couleur_defaut_grille,
+            "couleur_cadretxt": couleur_defaut_cadretxt
+            }
     
     
     
     
index f9394445dc47f5f1bffa828d5891d0cd98059b0e..c10f53e208cc7808986e291a86a8ced4e84c9f9c 100644 (file)
@@ -1,6 +1,8 @@
 "Version 0.4","18/06/2020","<ul>
 <li>Mis certaines sections en masquées par défaut, on peut cliquer pour les afficher</li>
 <li>Encore des ajouts dans la FAQ</li>
 "Version 0.4","18/06/2020","<ul>
 <li>Mis certaines sections en masquées par défaut, on peut cliquer pour les afficher</li>
 <li>Encore des ajouts dans la FAQ</li>
+<li>Possibilité de choisir sa gamme de couleurs pour les courbes, voire même des couleurs pour le reste du graphique (joli, ou pas...)</li>
+<li>Début d'amélioration du style (merci cerise)</li>
 <li>Si je continue comme ça je vais arriver à une version 1.0 avant d'avoir fini !</li>
 </ul>"
 
 <li>Si je continue comme ça je vais arriver à une version 1.0 avant d'avoir fini !</li>
 </ul>"
 
diff --git a/data_OMS/licence b/data_OMS/licence
new file mode 100644 (file)
index 0000000..1e96007
--- /dev/null
@@ -0,0 +1,100 @@
+--------------
+Les documents de ce dossier sont sous licence CC BY-NC-SA 3.0 IGO
+
+Les quatre fichiers : wfa_boys_p_exp.txt  wfa_girls_p_exp.txt wfa_boys_z_exp.txt  wfa_girls_z_exp.txt sont les données de l'Organisation Mondiale de la Santé (OMS) et peuvent être retrouvés ici :
+https://www.who.int/childgrowth/standards/weight_for_age/en/
+
+Les deux autres fichiers : wfa_mix_p_exp.txt et wfa_mix_z_exp.txt ont été générés à partir des fichiers de l'OMS.
+
+--------------
+Résumé de la licence en français (voir https://creativecommons.org/licenses/by-nc-sa/3.0/igo/deed.fr)
+
+Vous êtes autorisé à :
+
+Partager - copier, distribuer et communiquer le matériel par tous moyens et sous tous formats
+Adapter - remixer, transformer et créer à partir du matériel
+
+    L'Offrant ne peut retirer les autorisations concédées par la licence tant que vous appliquez les termes de cette licence.
+
+Selon les conditions suivantes :
+
+    Attribution - Vous devez créditer l'Oeuvre, intégrer un lien vers la licence et indiquer si des modifications ont été effectuées à l'Oeuvre. Vous devez indiquer ces informations par tous les moyens raisonnables, sans toutefois suggérer que l'Offrant vous soutient ou soutient la façon dont vous avez utilisé son Oeuvre.
+
+    Pas d'Utilisation Commerciale - Vous n'êtes pas autorisé à faire un usage commercial de cette Oeuvre, tout ou partie du matériel la composant.
+
+    Partage dans les Mêmes Conditions - Dans le cas où vous effectuez un remix, que vous transformez, ou créez à partir du matériel composant l'Oeuvre originale, vous devez diffuser l'Oeuvre modifiée dans les même conditions, c'est à dire avec la même licence avec laquelle l'Oeuvre originale a été diffusée.
+
+    Pas de restrictions complémentaires - Vous n'êtes pas autorisé à appliquer des conditions légales ou des mesures techniques qui restreindraient légalement autrui à utiliser l'Oeuvre dans les conditions décrites par la licence.
+
+--------------
+Texte complet de licence, en anglais
+
+License
+
+THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE (“LICENSE”). THE LICENSOR (DEFINED BELOW) HOLDS COPYRIGHT AND OTHER RIGHTS IN THE WORK. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE IS PROHIBITED.
+
+BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED HERE IN CONSIDERATION FOR YOUR ACCEPTANCE AND AGREEMENT TO THE TERMS OF THE LICENSE.
+
+1. Definitions
+
+    “IGO” means, solely and exclusively for purposes of this License, an organization established by a treaty or other instrument governed by international law and possessing its own international legal personality. Other organizations established to carry out activities across national borders and that accordingly enjoy immunity from legal process are also IGOs for the sole and exclusive purposes of this License. IGOs may include as members, in addition to states, other entities.
+    "Work" means the literary and/or artistic work eligible for copyright protection, whatever may be the mode or form of its expression including digital form, and offered under the terms of this License. It is understood that a database, which by reason of the selection and arrangement of its contents constitutes an intellectual creation, is considered a Work.
+    "Licensor" means the individual, individuals, entity or entities that offer(s) the Work under the terms of this License and may be, but is not necessarily, an IGO.
+    "You" means an individual or entity exercising rights under this License.
+    "License Elements" means the following high-level license attributes as selected by the Licensor and indicated in the title of this License: Attribution, Noncommercial, ShareAlike.
+    "Reproduce" means to make a copy of the Work in any manner or form, and by any means.
+    "Distribute" means the activity of making publicly available the Work or Adaptation (or copies of the Work or Adaptation), as applicable, by sale, rental, public lending or any other known form of transfer of ownership or possession of the Work or copy of the Work.
+    "Publicly Perform" means to perform public recitations of the Work and to communicate to the public those public recitations, by any means or process, including by wire or wireless means or public digital performances; to make available to the public Works in such a way that members of the public may access these Works from a place and at a place individually chosen by them; to perform the Work to the public by any means or process and the communication to the public of the performances of the Work, including by public digital performance; to broadcast and rebroadcast the Work by any means including signs, sounds or images.
+    "Adaptation" means a work derived from or based upon the Work, or upon the Work and other pre-existing works. Adaptations may include works such as translations, derivative works, or any alterations and arrangements of any kind involving the Work. For purposes of this License, where the Work is a musical work, performance, or phonogram, the synchronization of the Work in timed-relation with a moving image is an Adaptation. For the avoidance of doubt, including the Work in a Collection is not an Adaptation.
+    "Collection" means a collection of literary or artistic works or other works or subject matter other than works listed in Section 1(b) which by reason of the selection and arrangement of their contents, constitute intellectual creations, in which the Work is included in its entirety in unmodified form along with one or more other contributions, each constituting separate and independent works in themselves, which together are assembled into a collective whole. For the avoidance of doubt, a Collection will not be considered as an Adaptation.
+
+2. Scope of this License. Nothing in this License is intended to reduce, limit, or restrict any uses free from copyright protection.
+
+3. License Grant. Subject to the terms and conditions of this License, the Licensor hereby grants You a worldwide, royalty-free, non-exclusive license to exercise the rights in the Work as follows:
+
+    to Reproduce, Distribute and Publicly Perform the Work, to incorporate the Work into one or more Collections, and to Reproduce, Distribute and Publicly Perform the Work as incorporated in the Collections; and,
+    to create, Reproduce, Distribute and Publicly Perform Adaptations, provided that You clearly label, demarcate or otherwise identify that changes were made to the original Work.
+
+This License lasts for the duration of the term of the copyright in the Work licensed by the Licensor. The above rights may be exercised in all media and formats whether now known or hereafter devised. The above rights include the right to make such modifications as are technically necessary to exercise the rights in other media and formats. All rights not expressly granted by the Licensor are hereby reserved, including but not limited to the rights set forth in Section 4(e).
+
+4. Restrictions. The license granted in Section 3 above is expressly made subject to and limited by the following restrictions:
+
+    You may Distribute or Publicly Perform the Work only under the terms of this License. You must include a copy of, or the Uniform Resource Identifier (URI) for, this License with every copy of the Work You Distribute or Publicly Perform. You may not offer or impose any terms on the Work that restrict the terms of this License or the ability of the recipient of the Work to exercise the rights granted to that recipient under the terms of the License. You may not sublicense the Work (see section 8(a)). You must keep intact all notices that refer to this License and to the disclaimer of warranties with every copy of the Work You Distribute or Publicly Perform. When You Distribute or Publicly Perform the Work, You may not impose any effective technological measures on the Work that restrict the ability of a recipient of the Work from You to exercise the rights granted to that recipient under the terms of the License. This Section 4(a) applies to the Work as incorporated in a Collection, but this does not require the Collection apart from the Work itself to be made subject to the terms of this License. If You create a Collection, upon notice from a Licensor You must, to the extent practicable, remove from the Collection any credit (inclusive of any logo, trademark, official mark or official emblem) as required by Section 4(d), as requested. If You create an Adaptation, upon notice from a Licensor You must, to the extent practicable, remove from the Adaptation any credit (inclusive of any logo, trademark, official mark or official emblem) as required by Section 4(d), as requested.
+    You may Distribute or Publicly Perform an Adaptation only under the terms of: (i) this License; (ii) a later version of this License with the same License Elements as this License; or (iii) either the unported Creative Commons license or a ported Creative Commons license (either this or a later license version) containing the same License Elements (the “Applicable License”). (I) You must include a copy of, or the URI for, the Applicable License with every copy of each Adaptation You Distribute or Publicly Perform. (II) You may not offer or impose any terms on the Adaptation that restrict the terms of the Applicable License or the ability of the recipient of the Adaptation to exercise the rights granted to that recipient under the terms of the Applicable License. (III) You must keep intact all notices that refer to this License and to the disclaimer of warranties with every copy of the Work as included in the Adaptation You Distribute or Publicly Perform. (IV) When You Distribute or Publicly Perform the Adaptation, You may not impose any effective technological measures on the Adaptation that restrict the ability of a recipient of the Adaptation from You to exercise the rights granted to that recipient under the terms of the Applicable License. This Section 4(b) applies to the Adaptation as incorporated in a Collection, but this does not require the Collection apart from the Adaptation itself to be made subject to the terms of the Applicable License.
+    You may not exercise any of the rights granted to You in Section 3 above in any manner that is primarily intended for or directed toward commercial advantage or private monetary compensation. The exchange of the Work for other copyrighted works by means of digital file-sharing or otherwise shall not be considered to be primarily intended for or directed toward commercial advantage or private monetary compensation, provided there is no payment of any monetary compensation in connection with the exchange of copyrighted works.
+    If You Distribute, or Publicly Perform the Work or any Adaptations or Collections, You must, unless a request has been made pursuant to Section 4(a), keep intact all copyright notices for the Work and provide, reasonable to the medium or means You are utilizing: (i) any attributions that the Licensor indicates be associated with the Work as indicated in a copyright notice, (ii) the title of the Work if supplied; (iii) to the extent reasonably practicable, the URI, if any, that the Licensor specifies to be associated with the Work, unless such URI does not refer to the copyright notice or licensing information for the Work; and, (iv) consistent with Section 3(b), in the case of an Adaptation, a credit identifying the use of the Work in the Adaptation. The credit required by this Section 4(d) may be implemented in any reasonable manner; provided, however, that in the case of an Adaptation or Collection, at a minimum such credit will appear, if a credit for all contributors to the Adaptation or Collection appears, then as part of these credits and in a manner at least as prominent as the credits for the other contributors. For the avoidance of doubt, You may only use the credit required by this Section for the purpose of attribution in the manner set out above and, by exercising Your rights under this License, You may not implicitly or explicitly assert or imply any connection with, sponsorship or endorsement by the Licensor or others designated for attribution, of You or Your use of the Work, without the separate, express prior written permission of the Licensor or such others.
+
+    For the avoidance of doubt:
+        Non-waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme cannot be waived, the Licensor reserves the exclusive right to collect such royalties for any exercise by You of the rights granted under this License;
+        Waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme can be waived, the Licensor reserves the exclusive right to collect such royalties for any exercise by You of the rights granted under this License if Your exercise of such rights is for a purpose or use which is otherwise than noncommercial as permitted under Section 4(c) and otherwise waives the right to collect royalties through any statutory or compulsory licensing scheme; and,
+        Voluntary License Schemes. To the extent possible, the Licensor waives the right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary licensing scheme. In all other cases the Licensor expressly reserves the right to collect such royalties.
+    Except as otherwise agreed in writing by the Licensor, if You Reproduce, Distribute or Publicly Perform the Work either by itself or as part of any Adaptations or Collections, You must not distort, mutilate, modify or take other derogatory action in relation to the Work which would be prejudicial to the honor or reputation of the Licensor where moral rights apply.
+
+5. Representations, Warranties and Disclaimer
+
+THE LICENSOR OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ERRORS, WHETHER OR NOT DISCOVERABLE.
+
+6. Limitation on Liability
+
+IN NO EVENT WILL THE LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF THE LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. Termination
+
+    Subject to the terms and conditions set forth in this License, the license granted here lasts for the duration of the term of the copyright in the Work licensed by the Licensor as stated in Section 3. Notwithstanding the above, the Licensor reserves the right to release the Work under different license terms or to stop distributing the Work at any time; provided, however that any such election will not serve to withdraw this License (or any other license that has been, or is required to be, granted under the terms of this License), and this License will continue in full force and effect unless terminated as stated below.
+    If You fail to comply with this License, then this License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License. Individuals or entities who have received Adaptations or Collections from You under this License, however, will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will survive any termination of this License. Notwithstanding the foregoing, this License reinstates automatically as of the date the violation is cured, provided it is cured within 30 days of You discovering the violation, or upon express reinstatement by the Licensor. For the avoidance of doubt, this Section 7(b) does not affect any rights the Licensor may have to seek remedies for violations of this License by You.
+
+8. Miscellaneous
+
+    Each time You Distribute or Publicly Perform the Work or a Collection, the Licensor offers to the recipient a license to the Work on the same terms and conditions as the license granted to You under this License.
+    Each time You Distribute or Publicly Perform an Adaptation, the Licensor offers to the recipient a license to the original Work on the same terms and conditions as the license granted to You under this License.
+    If any provision of this License is invalid or unenforceable, it shall not affect the validity or enforceability of the remainder of the terms of this License, and without further action, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+    No term or provision of this License shall be deemed waived and no breach consented to unless such waiver or consent shall be in writing and signed by the Licensor.
+    This License constitutes the entire agreement between You and the Licensor with respect to the Work licensed here. There are no understandings, agreements or representations with respect to the Work not specified here. The Licensor shall not be bound by any additional provisions that may appear in any communication from You. This License may not be modified without the mutual written agreement of the Licensor and You.
+    The rights granted under, and the subject matter referenced, in this License were drafted utilizing the terminology of the Berne Convention for the Protection of Literary and Artistic Works (as amended on September 28, 1979), the Rome Convention of 1961, the WIPO Copyright Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996 and the Universal Copyright Convention (as revised on July 24, 1971). Interpretation of the scope of the rights granted by the Licensor and the conditions imposed on You under this License, this License, and the rights and conditions set forth herein shall be made with reference to copyright as determined in accordance with general principles of international law, including the above mentioned conventions.
+    Nothing in this License constitutes or may be interpreted as a limitation upon or waiver of any privileges and immunities that may apply to the Licensor or You, including immunity from the legal processes of any jurisdiction, national court or other authority.
+
+    Where the Licensor is an IGO, any and all disputes arising under this License that cannot be settled amicably shall be resolved in accordance with the following procedure:
+        Pursuant to a notice of mediation communicated by reasonable means by either You or the Licensor to the other, the dispute shall be submitted to non-binding mediation conducted in accordance with rules designated by the Licensor in the copyright notice published with the Work, or if none then in accordance with those communicated in the notice of mediation. The language used in the mediation proceedings shall be English unless otherwise agreed.
+        If any such dispute has not been settled within 45 days following the date on which the notice of mediation is provided, either You or the Licensor may, pursuant to a notice of arbitration communicated by reasonable means to the other, elect to have the dispute referred to and finally determined by arbitration. The arbitration shall be conducted in accordance with the rules designated by the Licensor in the copyright notice published with the Work, or if none then in accordance with the UNCITRAL Arbitration Rules as then in force. The arbitral tribunal shall consist of a sole arbitrator and the language of the proceedings shall be English unless otherwise agreed. The place of arbitration shall be where the Licensor has its headquarters. The arbitral proceedings shall be conducted remotely (e.g., via telephone conference or written submissions) whenever practicable.
+        Interpretation of this License in any dispute submitted to mediation or arbitration shall be as set forth in Section 8(f), above.
+
index 0ff4d5dd672150dac1f0094b06f63a45297926dd..5b773d97b0510384e3a99c4986f80300642cdbe2 100644 (file)
@@ -7,6 +7,7 @@ Created on Mon May 18 08:59:11 2020
 """
 from gestion_erreurs import *
 from configuration import *
 """
 from gestion_erreurs import *
 from configuration import *
+from gestion_couleurs import *
 
 import csv
 
 
 import csv
 
@@ -35,13 +36,20 @@ def affichepercentile(pc):
 def afficheecarttype(z):
     if z==0:
         return "Moyenne"
 def afficheecarttype(z):
     if z==0:
         return "Moyenne"
-    elif z<0:
-        return str(z)+"z"
     else:
     else:
-        return "+"+str(z)+"z"
-    
-liste_data_labels_p = [(nocol,affichepercentile(pc),degrade(pc)) for (nocol,pc) in liste_data_choisie_p]
-liste_data_labels_z = [(nocol,afficheecarttype(z),degrade((z+3)/3*50) ) for (nocol,z) in liste_data_choisie_z]
+        #return ("z = "+str(z))
+        if z>0:
+            chaine = r"$+"+str(z)+" \sigma$"
+        else:
+            chaine = r"$"+str(z)+"\sigma$"
+        return (chaine)
+
+def renvoie_liste_labels(conf,liste_data_choisie_p,liste_data_choisie_z,liste_err):
+    """ fabrique les deux listes de labels OMS"""
+    #warning(str(liste_data_choisie_p),liste_err)
+    liste_data_labels_p = [(nocol,affichepercentile(pc),degrade_choix(conf["couleur1"],conf["couleur2"],conf["couleur3"],pc)) for (nocol,pc) in liste_data_choisie_p]
+    liste_data_labels_z = [(nocol,afficheecarttype(z),degrade_choix(conf["couleur1"],conf["couleur2"],conf["couleur3"],(z+3)/3*50) ) for (nocol,z) in liste_data_choisie_z]
+    return liste_data_labels_p,liste_data_labels_z
     
 #liste_data_labels= liste_data_labels_z
 
     
 #liste_data_labels= liste_data_labels_z
 
diff --git a/gestion_couleurs.py b/gestion_couleurs.py
new file mode 100644 (file)
index 0000000..c1b3690
--- /dev/null
@@ -0,0 +1,62 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+
+### Gérer les couleurs
+
+from gestion_erreurs import *
+
+def rgb_vers_tuple(chaine,defaut,liste_err):
+    """ convertit une chaine rgb genre #00FF1B
+    vers un tuple python (entre 0 et 1)
+    En cas d'erreur, on met un warning et on renvoie
+    le defaut"""
+    chaine2 = chaine.lstrip("#")
+    try:
+        r = int(chaine2[0:2],16)/255
+        v = int(chaine2[2:4],16)/255
+        b = int(chaine2[4:6],16)/255                  
+    except:
+        warning("Impossible de convertir la couleur "+chaine,liste_err)
+        return defaut
+    return (r,v,b)
+
+def tuple_vers_rgb( t):
+    """ conversion inverse : renvoie une chaine
+    de type #FF0045"""
+    (r,v,b) = t
+    if (r>1):
+        r=1
+    elif r<0:
+        r=0
+    if (v>1):
+        v=1
+    elif v<0:
+        v=0
+    if (b>1):
+        b=1
+    elif b<0:
+        b=0        
+        
+    r = int(r*255)
+    v = int(v*255)
+    b = int(b*255)
+    return '#%02x%02x%02x' % (r,v,b)
+
+def progressif(x,y,nb):
+    """ renvoie x pour 0, y pour 50, 
+    et entre deux pour les intermédiaires"""
+    return (x*(50-nb)/50 + y*nb/50)
+
+def degrade_choix(col1,col2,col3,nb):
+    """ retourne un dégradé entre col1 et col2 (nb<50)
+    et entre col2 et col3 (nb>50)"""
+    if nb>100:
+        nb=100
+    elif nb<0:
+        nb = 0
+        
+    if nb<50:
+        return tuple( progressif(col1[i],col2[i],nb) for i in (0,1,2) )
+    else:
+        return tuple( progressif(col2[i],col3[i],nb-50) for i in (0,1,2) ) 
\ No newline at end of file
index a2d0a1e2b819431a83391243e9764a62613dd7ff..caacaf0c0e75c09a1d828260b5192bd52adad4ca 100644 (file)
@@ -3,6 +3,7 @@
 
 from configuration import *
 from gestion_erreurs import *
 
 from configuration import *
 from gestion_erreurs import *
+from gestion_couleurs import *
 import datetime
 import json
 import unidecode
 import datetime
 import json
 import unidecode
@@ -239,19 +240,29 @@ def gere_configuration(data,liste_err):
         positionlegende = "upper left"
     configuration["positionlegende"] = positionlegende
     
         positionlegende = "upper left"
     configuration["positionlegende"] = positionlegende
     
+    #warning("bla"+data["couleur1"],liste_err)
+    coul1 = rgb_vers_tuple(data.get("couleur1",""),couleur_defaut_1_tuple,liste_err)
+    coul2 = rgb_vers_tuple(data.get("couleur2",""),couleur_defaut_2_tuple,liste_err)
+    coul3 = rgb_vers_tuple(data.get("couleur3",""),couleur_defaut_3_tuple,liste_err)
+    #warning("bla2"+str(coul1),liste_err)
+    configuration["couleur1"] = coul1
+    configuration["couleur2"] = coul2
+    configuration["couleur3"] = coul3
+    
+    # couleur de fond
+    coul_fond = rgb_vers_tuple(data.get("couleur_fond",""),couleur_defaut_fond_tuple,liste_err)
+    configuration["couleur_fond"] = coul_fond
+    
+    # couleur d'axes et de texte
+    coul_cadretxt = rgb_vers_tuple(data.get("couleur_cadretxt",""),couleur_defaut_cadretxt_tuple,liste_err)
+    configuration["couleur_cadretxt"] = coul_cadretxt
+    
+    # couleur de la grille
+    coul_grille = rgb_vers_tuple(data.get("couleur_grille",""),couleur_defaut_grille_tuple,liste_err)
+    configuration["couleur_grille"] = coul_grille
+    #warning(str(configuration["couleur1"]),liste_err)
+    
     return configuration   
     return configuration   
-
-#def configuration_vers_texte(config):
-#    """ exporte le texte associé à une configuration 
-#    on dumpe simplement sauf pour maxi """
-#    texte = "# Section configuration\n"
-#    for (cle,val) in config.items():
-#        if cle != "maxi":
-#            texte+= cle + "=" + str(val) + "\n"
-#        else:
-#            texte+= cle + "=" + convertit_age_vers_texte(val)+"\n"
-#    texte +="\n"
-#    return texte
  
 
 def gere_donneespoids(data,naissance,liste_err):
  
 
 def gere_donneespoids(data,naissance,liste_err):
@@ -289,18 +300,6 @@ def gere_donneespoids(data,naissance,liste_err):
     l_poids = [x[1] for x in liste_donnees]   
     
     return (l_jours,l_poids)
     l_poids = [x[1] for x in liste_donnees]   
     
     return (l_jours,l_poids)
-    
-    
-#def donnees_poids_vers_texte(l_jours,l_poids):
-#    """ retourne le texte correspondant aux données de poids """
-#    texte = "# Section données\n"
-#    
-#    for i in range(len(l_poids)):
-#        texte +=convertit_age_vers_texte(l_jours[i])+","+convertit_poids_vers_texte(l_poids[i])+"\n"
-#        
-#    texte+="\n"
-#    return texte
-
 
 
 
 
 
 
@@ -316,41 +315,14 @@ def donnees_vers_json(l_jours,l_poids,config):
         gros_dico["naissance"] = convertit_date_vers_texte(gros_dico["naissance"])
     # gérer l'age maxi
     gros_dico["maxi"] = convertit_age_vers_texte(gros_dico["maxi"])
         gros_dico["naissance"] = convertit_date_vers_texte(gros_dico["naissance"])
     # gérer l'age maxi
     gros_dico["maxi"] = convertit_age_vers_texte(gros_dico["maxi"])
+    # gérer les couleurs
+    for cle in ["couleur1", "couleur2", "couleur3", "couleur_fond","couleur_grille","couleur_cadretxt"]:
+        gros_dico[cle] = tuple_vers_rgb(gros_dico[cle])
+    
+    
         
     return json.dumps(gros_dico, indent=2,ensure_ascii=False )
 
         
     return json.dumps(gros_dico, indent=2,ensure_ascii=False )
 
-#def fichier_texte_vers_configdonnees(fichier,liste_err):
-#    """ prend le texte importé et l'exporte vers configuration et données
-#    sous forme de valeurs du formulaire """
-#    
-#    valform = {}
-#    indice_formulaire = 0 # l'indice du formulaire pour les données : age_1, date_1, poids_1 etc
-#    num_ligne = 0
-#    lignes = fichier.readlines()
-#    for ligne in lignes:
-#        num_ligne +=1
-#        ligne = str(ligne,"utf8")
-#        ligne = ligne.rstrip("\n")
-#        if ligne != "" and ligne[0] != "#" and not(ligne.isspace()): # les lignes commençant par # sont des commentaires
-#            # On essaie de partitionner pour voir
-#            (var,egal,val) = ligne.partition("=")
-#            if egal == "=": # c'est une ligne de config 
-#                valform[var] = val
-#            else:
-#                (age,virgule,poids) = ligne.partition(",") # On partitionne avec ,
-#                if virgule == ",":
-#                    # c'est une ligne de data
-#                    valform["age_"+str(indice_formulaire)] = age
-#                    valform["poids_"+str(indice_formulaire)] = poids
-#                    indice_formulaire +=1
-#                    
-#                else:
-#                    warning("La ligne "+str(num_ligne)+" n'est pas reconnue et sera ignorée : <"+ligne+">",liste_err)
-#    
-#    #le nb max du formulaire
-#    valform["nb_data"] = max(indice_formulaire +2,nombre_lignes_form)
-#    
-#    return valform
 
 def fichier_json_vers_configdonnees(fichier,liste_err):
     """ prend le json importé et l'exporte vers les valeurs du formulaire """
 
 def fichier_json_vers_configdonnees(fichier,liste_err):
     """ prend le json importé et l'exporte vers les valeurs du formulaire """
diff --git a/licence b/licence
new file mode 100644 (file)
index 0000000..f9241d4
--- /dev/null
+++ b/licence
@@ -0,0 +1,20 @@
+Copyright (c) 2020 Denise Maurice
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
index 58fdd2418fd554889d8ac4de0b224d7f0a49ad27..97f20d92c0421fa70c403b6255b053bcb9a3926d 100644 (file)
@@ -1,7 +1,25 @@
 body {
 body {
-       background-color:#CCCCCC;
+       background-color:#EEEEEE;
 }
 
 }
 
+h1 {
+       background: #55f;
+       padding: 5px 10px;
+       border-radius: 10px;
+       color: #ffc0b0;
+       text-align: center;
+}
+
+#warnings {
+       background: #ff8060;
+}
+
+input[type="text"] {
+       max-width: 20vw;
+}
+
+
+
 #sectioncourbe {
        display: none;
 }
 #sectioncourbe {
        display: none;
 }
index ba8ade31cffadf8208b1065da9651a49bc2c1b1f..9f2b0768d9494724ae2410393644abc429532755 100644 (file)
@@ -5,5 +5,6 @@
 
 <p>Ces données, ainsi que ce site web, sont sous licence <a href="https://creativecommons.org/licenses/by-nc-sa/3.0/igo/">CC BY-NC-SA 3.0 IGO</a></p>
 
 
 <p>Ces données, ainsi que ce site web, sont sous licence <a href="https://creativecommons.org/licenses/by-nc-sa/3.0/igo/">CC BY-NC-SA 3.0 IGO</a></p>
 
+<p>Le code source (<a href="https://fr.wikipedia.org/wiki/Licence_MIT">licence MIT</a> sauf en ce qui concerne les données) est disponible là.</p>
 
 {% endblock %}
 
 {% endblock %}
index 60693d40f8b68fc7bef171135f83a8fdd8e8f173..2b1b82bfbe0b2d45deed48fc3c6b1508a4b81424 100644 (file)
@@ -76,7 +76,7 @@
                        <option value="{{ unite }}"{% if valform.unite == unite %} selected {% endif %} >{{ unite }}</option>
        {% endfor %}
                </select></li>
                        <option value="{{ unite }}"{% if valform.unite == unite %} selected {% endif %} >{{ unite }}</option>
        {% endfor %}
                </select></li>
-       <li><label>valeur maximum du graphique (facultatif, syntaxe similaire à l'âge, voir plus bas) </label><input type="text" name="maxi" value="{{ valform.maxi }}"></li>
+       <li><label>valeur maximum du graphique (facultatif, syntaxe similaire à l'âge) </label><input type="text" name="maxi" value="{{ valform.maxi }}"></li>
        <li>Dimensions du graphique&nbsp;: <label>largeur&nbsp;: </label><input type="text" name="largeur" value="{{ valform.largeur }}"> 
        <label>hauteur&nbsp;: </label><input type="text" name="hauteur" value="{{ valform.hauteur }}"></li>
        <li><label>Légende&nbsp;: </label><input type="checkbox" name="legende" {% if valform.legende == 'oui' %} checked{% endif %}> 
        <li>Dimensions du graphique&nbsp;: <label>largeur&nbsp;: </label><input type="text" name="largeur" value="{{ valform.largeur }}"> 
        <label>hauteur&nbsp;: </label><input type="text" name="hauteur" value="{{ valform.hauteur }}"></li>
        <li><label>Légende&nbsp;: </label><input type="checkbox" name="legende" {% if valform.legende == 'oui' %} checked{% endif %}> 
@@ -86,24 +86,18 @@ Position&nbsp;: <select name="positionlegende">
 {% endfor %}
 </select>
        </li>
 {% endfor %}
 </select>
        </li>
+       <li>Couleur courbe du bas <input type="color" name="couleur1" value="{{ valform.couleur1 }}"> | Couleur courbe du milieu <input type="color" name="couleur2"  value="{{ valform.couleur2 }}"> | Couleur courbe du haut <input type="color" name="couleur3" value="{{ valform.couleur3 }}"> </li>
+       <li>Couleur du fond <input type="color" name="couleur_fond" value="{{ valform.couleur_fond }}"> | Couleur de la grille <input type="color" name="couleur_grille" value="{{ valform.couleur_grille }}"> | Couleur des axes, texte et courbe <input type="color" name="couleur_cadretxt" value="{{ valform.couleur_cadretxt }}"></li>
 </ul>
 
 
 </form>
 </ul>
 
 
 </form>
-
+<!-- section retour -->
 <hr>
 
 <button onclick="appelle_image()">Je veux la courbe !</button>
 
 <hr>
 <hr>
 
 <button onclick="appelle_image()">Je veux la courbe !</button>
 
 <hr>
-<div id="sectioncourbe">
-
-       <h2>Courbe</h2>
-       <img id="courbe">
-       <div>
-       <button id="courbe_dl">Télécharger la courbe</button>
-       </div>
-</div>
 <div id="courbe_warnings">
        <p><strong>Alerte&nbsp;:</strong> la courbe a eu quelques soucis à se générer. Voici la liste des erreurs.</p>
        <ul></ul>
 <div id="courbe_warnings">
        <p><strong>Alerte&nbsp;:</strong> la courbe a eu quelques soucis à se générer. Voici la liste des erreurs.</p>
        <ul></ul>
@@ -112,6 +106,15 @@ Position&nbsp;: <select name="positionlegende">
        <p><strong>Alerte&nbsp;:</strong> La courbe n'a pas pu être générée. Vérifiez les données saisies, ou contactez l'administratrice. Erreurs&nbsp;: </p>
        <ul></ul>
 </div>
        <p><strong>Alerte&nbsp;:</strong> La courbe n'a pas pu être générée. Vérifiez les données saisies, ou contactez l'administratrice. Erreurs&nbsp;: </p>
        <ul></ul>
 </div>
+<div id="sectioncourbe">
+
+       <h2>Courbe</h2>
+       <img id="courbe">
+       <div>
+       <button id="courbe_dl">Télécharger la courbe</button>
+       </div>
+</div>
+
 
 <div id="sectionexport">
        <h2>Export des données</h2>
 
 <div id="sectionexport">
        <h2>Export des données</h2>
index d0f0b4203119b788f7f1a97713f0995579b63bcd..c86dbd995761d4d4d9fd1cd30594be6321d073fb 100644 (file)
@@ -3,12 +3,19 @@
 from configuration import *
 from gestionOMS import *
 from gestion_unites import *
 from configuration import *
 from gestionOMS import *
 from gestion_unites import *
+
 import matplotlib.pyplot as plt
 
 def cree_figure(conf,l_jours,l_poids,liste_err):
 import matplotlib.pyplot as plt
 
 def cree_figure(conf,l_jours,l_poids,liste_err):
-    
-    
-    if conf["maxi"] == 0:
+    #warning("debut de cree_figure",liste_err)
+    try:
+        liste_data_labels_p,liste_data_labels_z = renvoie_liste_labels(conf,liste_data_choisie_p,liste_data_choisie_z,liste_err)
+    except:
+        erreur("bug avec liste data labels",liste_err)
+        return ""
+
+    #warning("bla",liste_err)
+    if conf["maxi"] ==0:
         if l_jours != []:
             jour_maxi = max(l_jours)# pas la peine d'aller très au delà du jour max
             jour_maxi = int(jour_maxi* 1.1)+3 # on rajoute un peu
         if l_jours != []:
             jour_maxi = max(l_jours)# pas la peine d'aller très au delà du jour max
             jour_maxi = int(jour_maxi* 1.1)+3 # on rajoute un peu
@@ -26,9 +33,13 @@ def cree_figure(conf,l_jours,l_poids,liste_err):
     # Attention, comme les jours commencent à partir de 0, faut enlever 1 pour avoir la borne...
     age_maxi = convertitunite(jour_maxi-1,conf["unite"],liste_err)
     
     # Attention, comme les jours commencent à partir de 0, faut enlever 1 pour avoir la borne...
     age_maxi = convertitunite(jour_maxi-1,conf["unite"],liste_err)
     
-    
+
     titre = "Courbe de poids OMS"
     
     titre = "Courbe de poids OMS"
     
+#    warning("cree_figure : ça va jusque là ",liste_err)
+    #warning("bli"+str(conf),liste_err)
+    #warninf("coucou")
+    
     if conf["typecourbe"] == "P":
         # percentiles
         liste_data_labels = liste_data_labels_p
     if conf["typecourbe"] == "P":
         # percentiles
         liste_data_labels = liste_data_labels_p
@@ -52,7 +63,13 @@ def cree_figure(conf,l_jours,l_poids,liste_err):
         else:
             fichier_oms = f_poids_z_mixte
             titre += " (moyenne et écarts-types)"
         else:
             fichier_oms = f_poids_z_mixte
             titre += " (moyenne et écarts-types)"
-            
+    else:
+        warning("Type de courbe invalide"+conf["typecourbe"],liste_err)
+
+#    warning("cree_figure : ça va jusque là ",liste_err)
+#    warning("bli"+str(conf),liste_err)
+   
+        
     # Si y'a un nom on met "courbe de machin"
     if conf["nom"] !="":
         titre += " de " +conf["nom"]
     # Si y'a un nom on met "courbe de machin"
     if conf["nom"] !="":
         titre += " de " +conf["nom"]
@@ -67,16 +84,26 @@ def cree_figure(conf,l_jours,l_poids,liste_err):
         liste_err[0].append("Impossible d'ouvrir le fichier "+fichier_oms)
     coljour = convertit_tableau(extraire_colonne(t,0,jour_maxi),conf["unite"],liste_err)
     
         liste_err[0].append("Impossible d'ouvrir le fichier "+fichier_oms)
     coljour = convertit_tableau(extraire_colonne(t,0,jour_maxi),conf["unite"],liste_err)
     
-    
+
     #### La figure
     #### La figure
-    fig = plt.figure(num=None, figsize=(conf["largeur"], conf["hauteur"]), dpi=100, facecolor='w', edgecolor='k')
-    
+    fig = plt.figure(num=None, figsize=(conf["largeur"], conf["hauteur"]), dpi=100, facecolor=conf["couleur_fond"])
+    plt.rcParams['axes.facecolor'] = conf["couleur_fond"]
+    plt.rcParams['axes.edgecolor']= conf["couleur_cadretxt"]
+    plt.rcParams['xtick.color'] = conf["couleur_cadretxt"]
+    plt.rcParams['ytick.color'] = conf["couleur_cadretxt"]
+    plt.rcParams['grid.color'] = conf["couleur_grille"]
+    plt.rcParams['legend.edgecolor'] = conf["couleur_grille"]
+
+    #warning("bla"+str(liste_data_labels),liste_err)  
     for (i,label,couleur) in liste_data_labels:
         plt.plot(coljour,extraire_colonne(t,i,jour_maxi),label=label,color=couleur)
     for (i,label,couleur) in liste_data_labels:
         plt.plot(coljour,extraire_colonne(t,i,jour_maxi),label=label,color=couleur)
+        #warning("colonne"+str(i)+str(label)+str(couleur),liste_err)
+
+
     
     # On extrait la valeur min et la valeur max des poids
     
     # On extrait la valeur min et la valeur max des poids
-    (colonne_min,_,_) = liste_data_labels[0]
-    (colonne_max,_,_) = liste_data_labels[-1]
+    (colonne_min,_,_) = liste_data_labels[-1]
+    (colonne_max,_,_) = liste_data_labels[0]
     
     poids_min = min(extraire_colonne(t,colonne_min,jour_maxi))
     poids_max = max(extraire_colonne(t,colonne_max,jour_maxi))
     
     poids_min = min(extraire_colonne(t,colonne_min,jour_maxi))
     poids_max = max(extraire_colonne(t,colonne_max,jour_maxi))
@@ -89,17 +116,22 @@ def cree_figure(conf,l_jours,l_poids,liste_err):
     #max : +5% 
     poids_max = poids_max * 1.05
     
     #max : +5% 
     poids_max = poids_max * 1.05
     
+    #warning("Jusque là ça marche",liste_err)
+    
     if l_jours != []:
     if l_jours != []:
-        plt.plot(l_jours_conv,l_poids,label=conf["nom"],color="black",marker='o')
+        plt.plot(l_jours_conv,l_poids,label=conf["nom"],color=conf["couleur_cadretxt"],marker='o')
     
     
-    plt.xlabel("Âge en "+conf["unite"])
-    plt.ylabel("Poids en kg")
-    plt.title(titre)
+    plt.xlabel("Âge en "+conf["unite"],color=conf["couleur_cadretxt"])
+    plt.ylabel("Poids en kg",color=conf["couleur_cadretxt"])
+    plt.title(titre,color=conf["couleur_cadretxt"])
     plt.axis([0,age_maxi,poids_min,poids_max])
     
     if conf['legende']=="oui":
     plt.axis([0,age_maxi,poids_min,poids_max])
     
     if conf['legende']=="oui":
-        plt.legend(loc=conf['positionlegende'])
+        legende = plt.legend(loc=conf['positionlegende'])
+        plt.setp(legende.get_texts(), color=conf["couleur_cadretxt"])
     plt.grid(conf["grille"]=="oui")
 
     fig.tight_layout()
     plt.grid(conf["grille"]=="oui")
 
     fig.tight_layout()
+    
+    #warning("Jusque là ça marche",liste_err)
     return fig
\ No newline at end of file
     return fig
\ No newline at end of file