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

low performance if use grid and memory Overflow Error #12

Open
ryzenX opened this issue Apr 27, 2018 · 1 comment
Open

low performance if use grid and memory Overflow Error #12

ryzenX opened this issue Apr 27, 2018 · 1 comment

Comments

@ryzenX
Copy link

ryzenX commented Apr 27, 2018

Hello i have big problem with kivy, i want to plot 10 point, my values range from -100000 to 100000

the problem, when i change ymin=-100000 and ymax=100000, kivy is very very slow but if i define ymin=-1 and ymax=1 i have good performance

in this example i denife ymin=-1000 and ymax=1000 and i have already slow performance, if you try with -100000 to 100000 my window make five minute to load...

but i have only 10 point to print....

from math import sin
from kivy.garden.graph import Graph, MeshLinePlot
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.properties import NumericProperty


class RootWidget(BoxLayout):
    _touch_count = NumericProperty(0)

    def __init__(self, **kwargs):
        super(RootWidget, self).__init__(**kwargs)

        self.graph = Graph(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=-1000, ymax=1000)

        plot = MeshLinePlot(color=[1, 0, 0, 1])
        plot.points = [(x*100, sin(x)*100000) for x in range(0, 10)]
        self.graph.add_plot(plot)
        self.add_widget(self.graph)


class GraphDemo(App):

    def build(self):
        return RootWidget()


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

i solved my problem, i must to hide y grid for have good performance but i found new error with memory :

from math import sin
from kivy.garden.graph import Graph, MeshLinePlot
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.properties import NumericProperty


class RootWidget(BoxLayout):
    _touch_count = NumericProperty(0)

    def __init__(self, **kwargs):
        super(RootWidget, self).__init__(**kwargs)

        self.graph = Graph(xlabel='X', ylabel='Y', x_ticks_minor=5,
                           x_ticks_major=25, y_ticks_major=1,
                           y_grid_label=False, x_grid_label=True, padding=5,
                           x_grid=True, y_grid=False, xmin=-0, xmax=100, ymin=-10000, ymax=30000)

        plot = MeshLinePlot(color=[1, 0, 0, 1])
        plot.points = [(x*1000, sin(x)*100000) for x in range(0, 10)]
        self.graph.add_plot(plot)
        self.add_widget(self.graph)


class GraphDemo(App):

    def build(self):
        return RootWidget()


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

if i have a interval > 32767 i have this error :

   File "kivy\graphics\memory.pxi", line 72, in kivy.graphics.vertex_instruction
s._ensure_ushort_view (kivy\graphics\vertex_instructions.c:6404)
 OverflowError: value too large to convert to unsigned short
@ryzenX ryzenX changed the title low performance if use grid and memory error low performance if use grid and memory Overflow Error Apr 27, 2018
@dsball
Copy link

dsball commented Dec 23, 2018

This error is coming from the ticks settings. Your y axis is 40,000 units and you are attempting to place a tick for every unit. The value you showed is 2^15-1, i.e. the maximum value for a signed short. I suspect it's related. If you change your axis to, say, 100,000 but have your y_ticks_major at a reasonable value, e.g. 1000 rather than 1, it would work fine.

I suggest choosing a reasonable interval for your y ticks, or possibly inheriting this module and adding the check to the inherited class.

@matham matham transferred this issue from kivy-garden/garden.graph Jun 16, 2019
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