Outils pour utilisateurs

Outils du site


kivy_graph_examples

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Prochaine révision
Révision précédente
kivy_graph_example [2020/01/18 11:04] – créée sergekivy_graph_examples [2020/10/28 12:17] (Version actuelle) – ↷ Liens modifiés en raison d'un déplacement. serge
Ligne 1: Ligne 1:
-====== Kivy: Graph example ====== +====== Kivy: Exemples de Kivy Garden Graph  ======
- +
 <WRAP center round box 60% centeralign> <WRAP center round box 60% centeralign>
 **{{tagpage>kivy|Toutes les pages Kivy}}**   **{{tagpage>kivy|Toutes les pages Kivy}}**  
-**[[http://translate.google.com/translate?hl=&sl=auto&tl=en&u=https%3A%2F%2Fressources.labomedia.org%2Fkivy_application_android_smart_citizen|English Version]]**+**[[http://translate.google.com/translate?hl=&sl=auto&tl=en&u=https%3A%2F%2Fressources.labomedia.org%2Fkivy_graph_examples|English Version]]** 
 +</WRAP> 
 +<WRAP center round box 40% centeralign> 
 +**[[les_pages_kivy_en_details|Les pages Kivy en détails]]**
 </WRAP> </WRAP>
 +
 +Retour à **[[kivy_garden|Kivy Garden]]**
  
 =====Ressources===== =====Ressources=====
 +  * Cet exemple est instiré de **[[https://github.com/kivy/plyer/tree/master/examples/accelerometer/using_graph|accelerometer using graph]]** qui est un exemple de [[https://github.com/kivy/plyer|]]
 +  * **[[kivy_plyer|La page du wiki sur plyer]]**
 +  * **[[https://github.com/kivy-garden/graph|https://github.com/kivy-garden/graph]]**
 +  * **[[https://kivy-garden.github.io/graph/flower.html|Docs » The Graph API » Graph]]** 
 +
 +Les exemples sont disponible dans le projet Smart Citizen: https://github.com/sergeLabo/smartcitizen/tree/master/smartcitizen/garden_graph_example
 +=====Exemple très simple=====
 +Pour expliquer, inutile d'introduire les Nombres Complexes (y = a + b*i) avec i*i = -1 ou les arctg(ln(0.154236987))!
 +
 +{{ media_06:graphexample_1.png?500 |}}
 +
 +<code python graphexemple.py>
 +#! /usr/bin/env python3
 +# -*- coding: utf-8 -*-
 +
 +"""
 +Inspiré de:
 +https://github.com/kivy/plyer/tree/master/examples/accelerometer/using_graph
 +"""
 +
 +from math import sin
 +
 +import kivy
 +kivy.require('1.11.1')
 +from kivy.app import App
 +from kivy.properties import ObjectProperty
 +from kivy.uix.boxlayout import BoxLayout
 +from kivy_garden.graph import Graph, MeshLinePlot
 +
 +
 +class GraphExample(BoxLayout):
 +
 +    graph = ObjectProperty()
 +
 +    def __init__(self, **kwargs):
 +
 +        super().__init__(**kwargs)
 +
 +        plot = MeshLinePlot(color=[1, 0, 0, 1])
 +        plot.points = [(x, sin(x / 10.)) for x in range(0, 101)]
 +
 +        # Recherche des widgets
 +        print([type(widget) for widget in self.walk(loopback=True)])
 +
 +        # Appel du widget avec l'id graph
 +        self.ids.graph.add_plot(plot)
 +
 +
 +class GraphExampleApp(App):
 +    def build(self):
 +        return GraphExample()
 +
 +if __name__ == '__main__':
 +    GraphExampleApp().run()
 +</code>
 +
 +<code python graphexemple.kv>
 +#:kivy 1.11.1
 +
 +<GraphExample>:
 +    BoxLayout:
 +        orientation: 'vertical'
 +        padding: 20
 +
 +        Graph:
 +            size_hint_y: 0.8
 +            id: graph
 +            background_color: 0, 1, 1, 1
 +            border_color: 1, 1, 0, 1
 +            xlabel: 'X'
 +            ylabel: 'Y'
 +            x_ticks_minor: 5
 +            x_ticks_major: 25
 +            y_ticks_major: 1
 +            y_grid_label: True
 +            x_grid_label: True
 +            padding: 5
 +            x_grid: True
 +            y_grid: True
 +            xmin:0
 +            xmax:100
 +            ymin:-1
 +            ymax:1
 +</code>
 +
 +=====Le même exemple avec la sinusoïde qui glisse=====
 +  * **[[https://github.com/sergeLabo/smartcitizen/tree/master/smartcitizen/garden_graph_example/graph_2|graph_2]]**
 +
 +
 +{{tag> kivy python sb }}
  
  
-{{tag>kivy sb}} 
kivy_graph_examples.1579345468.txt.gz · Dernière modification : 2020/01/18 11:04 de serge