我在代码中使用了zingchart量规。我的问题是我无法动态更改仪表值。
我收到此错误:
无法设置未定义的属性“值”
我正在使用flask API。如何使用Flask API更改此变量值?您有什么想法可以用于动态量规吗?
start_time = time.time() #grabs the system time
class CustomStreamListener(tweepy.StreamListener):
def __init__(self, start_time, time_limit):
self.time = start_time
self.limit = time_limit
self.tweet_data = []
def on_data(self, data):
while (time.time() - self.time) < self.limit:
try:
with open('unlimited.json', 'a') as f:
f.write(data)
return True
except BaseException as e:
print("Error on_data: %s" % str(e))
return True
def on_error(self, status_code):
print >> sys.stderr, 'Encountered error with status code:', status_code
time.sleep(61*15)
return True # Don't kill the stream
def on_timeout(self):
print >> sys.stderr, 'Timeout...'
return True # Don't kill the stream
sapi = tweepy.streaming.Stream(auth, CustomStreamListener(start_time, time_limit=59*15))
sapi.filter(locations=[-73.79,-11.12,-34.41,-4.29,-70.23,-4.29,-34.41,2.67,-52.37,2.67,-50.61,5.41,-65.03,2.67,-59.33,5.41,-65.31,-14.2,-36.76,-11.11,-60.6,-16.43,-38.45,-14.2,-58.49,-22.4,-38.73,-16.43,-55.96,-24.27,-41.83,-22.4,-55.96,-28.37,-46.61,-24.27,-57.65,-31.65,-48.43,-28.37,-54.27,-33.96,-51.6,-31.65])
答案 0 :(得分:1)
您可以使用setseriesvalues
并将数组用作值。
success: function(data, status, xhr) {
a = JSON.parse(data);
zingchart.exec('myChart', 'setseriesvalues', {
plotindex: 0,
'values': [20]
});
//console.log(a);
}