Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graph with KivyMD won't render labels #27

Open
Tyrn opened this issue Apr 5, 2020 · 1 comment
Open

Graph with KivyMD won't render labels #27

Tyrn opened this issue Apr 5, 2020 · 1 comment

Comments

@Tyrn
Copy link

Tyrn commented Apr 5, 2020

Run on MDApp, a Graph example gets shorn of labels and other peripheral decorations.

Run the following example with and without a command line argument:

$ python graphlayout.py [anything]

I can't tell where the wrinkle belongs, yet I hope there's something to be done about it.

graphlayout.py:

import sys
from math import sin
from kivy.lang import Builder
from kivy.properties import ObjectProperty
if len(sys.argv) > 1:
    from kivy.app import App
else:
    from kivymd.app import MDApp as App
from kivy.uix.widget import Widget
from kivy_garden.graph import Graph, MeshLinePlot


class SetGraph(Widget):
    def update_graph(self):
        plot = MeshLinePlot(color=[1, 0, 0, 1])
        plot.points = [(x, sin(x / 10.0)) for x in range(0, 101)]
        App.get_running_app().root.ids.graph_test.add_plot(plot)


class GraphLayoutApp(App):
    def build(self):
        return Builder.load_file("graphlayout.kv")

    def on_start(self):
        """On Start"""
        ids = self.root.ids
        ids.g_test.update_graph()


if __name__ == "__main__":
    GraphLayoutApp().run()

graphlayout.kv:

#:import MeshLinePlot kivy_garden.graph.MeshLinePlot
BoxLayout:
    orientation: "vertical"
    SetGraph:
        id: g_test
        Graph:
            id: graph_test
            plot: MeshLinePlot
            xlabel:'X'
            ylabel:'Y'
            x_ticks_minor:5
            x_tics_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
            pos: 0, root.height / 6
            size: root.width * 2 / 4 , root.height * 18 / 24
@ArtemSBulgakov
Copy link

@Tyrn I found a fix. You just need to add a color for labels:

Graph:
    label_options: {"color": [.5, .5, .5, 1], "bold": True}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants