So I have a Chart Range Selector on a view and I’m writing a binding on the data property such that I get an array of objects.
data = [{time:1,633,560,052,327, speed:148.1},etc...]
My first attempt looked like this:
#add a time column into the pen names list
names = ['time'] + names
results = []
for r in range(queryResults.rowCount):
result= {}
for c,name in enumerate(names):
result[name] = queryResults.getValueAt(r,c) if name is not 'time' else system.date.toMillis(queryResults.getValueAt(r,c))
results.append(result)
return results
I thought this would work, however, the time was always converted back into a date.
My second attempt, doesn’t have this issue.
#the 'time' key was not added into the names list.
results = []
for r in range(queryResults.rowCount):
result= {'time':system.date.toMillis(queryResults.getValueAt(r,0))}
for c,name in enumerate(names):
result[name] = queryResults.getValueAt(r,c + 1)
results.append(result)
return results
My question is, why it is converted to a date in the first example, but not in the second one? Is this some kind of jython bug? system.date.toMillis()
obviously returns and integer.
Also, in case it’s mentioned it doesn’t matter if the inline if statement is broken to a traditional if statement or not.
Any insight would be appriciated.