Kivy花园图表画在自己身上

时间:2014-05-09 19:26:03

标签: python kivy

我在我的应用程序中绘制了一个非常简单的Kivy Garden Chart。我想通过向数据系列添加值来实时更新此图表。当我向图表显示的MeshLinePlot系列添加额外数据时,图表会很好地更新,但不幸的是,屏幕上显示旧图表。如果我调整窗口大小,则会使用正确的数据重新绘制图表,而不会重新绘制任何工件,但我无法找到在代码中强制执行此操作的方法。我使用的代码是:

class ChartView(BoxLayout):
    dataPoints = NumericProperty(0)
    dataPlot = MeshLinePlot(color=[1, 0, 0, 1])
    def __init__(self, **kwargs):
        super(ChartView, self).__init__(**kwargs)
        myChart = kvFind(self, 'rcid', 'testGraph')
        self.add_test_data()
        myChart.add_plot(self.dataPlot)

    def add_test_data(self):
        myChart = kvFind(self, 'rcid', 'testGraph')
        self.dataPoints += 1000
        self.dataPlot.points = [(x, random() - random() + sin(x / 100.)) for x in xrange(0, self.dataPoints)]
        myChart.xmax = self.dataPoints

我做错了什么?这太令人困惑了。

0 个答案:

没有答案