我有一个非常简单的Kivy花园图表在我的应用程序。我想通过向数据系列添加值来实时更新此图表。当我向图表显示的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
我做错什么了?真令人费解。在
目前没有回答
相关问题 更多 >
编程相关推荐