I have currently the following data structure to draw graphs:
[
{"tickID":0,"AgentID":"0","geometryTableName":"geometryTableName_tick0","classID":8,"name":"flat roof","memDegree":0.2,"ellipticfit":6.21025,"mainDirection",.........},
{"tickID":0,"AgentID":"0","geometryTableName":"geometryTableName_tick0","classID":1,"name":"roof","memDegree":0.4,"ellipticfit":6.21025,"mainDirection",.........},
{"tickID":0,"AgentID":"0","geometryTableName":"geometryTableName_tick0","classID":7,"name":"saddled roof","memDegree":0.2,"ellipticfit":6.21025,"mainDirection",.........},
{"tickID":0,"AgentID":"0","geometryTableName":"geometryTableName_tick0","classID":9,"name":"other roof","memDegree":0.2,"ellipticfit":6.21025,"mainDirection",.........},
{"tickID":0,"AgentID":"1","geometryTableName":"geometryTableName_tick1","classID":8,"name":"flat roof","memDegree":0.6,"ellipticfit":6.21025,"mainDirection",.........},
{"tickID":0,"AgentID":"1","geometryTableName":"geometryTableName_tick1","classID":1,"name":"roof","memDegree":0,"ellipticfit":6.21025,"mainDirection",.........},
{"tickID":0,"AgentID":"1","geometryTableName":"geometryTableName_tick1","classID":7,"name":"saddled roof","memDegree":0.2,"ellipticfit":6.21025,"mainDirection",.........},
{"tickID":0,"AgentID":"1","geometryTableName":"geometryTableName_tick1","classID":9,"name":"other roof","memDegree":0.2,"ellipticfit":6.21025,"mainDirection",.........}
]
As you can see, to accomplish a flat data structure for classID, name and memDegree there are always duplicate values for tickID, AgentID, geometryTableName and the other columns. So the next 3 rows are always double. Why I created this data structure, because this was the only data structure which enabled me to make a pie chart from the columns name and memDegree. Is it possible to create a better datastructure where I have no redundant values and where I can also create a pie chart from name and memDegree?
I already tried to create a new data structure which removed the duplicate values but then I wasn't able to create the pie chart.
[
{"tickID":0,"AgentID":"0","geometryTableName":"geometryTableName_tick0","flat roof":0.2,"roof":0.4,"saddled roof":0.2,"other roof":0.2,"ellipticfit":6.21025,"mainDirection",.........},
{"tickID":0,"AgentID":"1","geometryTableName":"geometryTableName_tick1","flat roof":0.6,"roof":0,"saddled roof":0.2,"other roof":0.2,"ellipticfit":6.21025,"mainDirection",.........},
]
Also tried the following data structure but with this structure I had no connection with the other charts. When I clicked something at the one bar everything was empty at the other. (Is there a way to tell crossfilter to treat elements of array as separate records instead of treating whole array as single key?)
[
{agentID: "0", tick: "0", valuesn:[{methodName: "flatRoof", valuen: 0.7}, {methodName: "roof", valuen: 0.3}]},
{agentID: "1", tick: "1", valuesn:[{methodName: "flatRoof", valuen: 0.8}, {methodName: "roof", valuen: 0.2}]},
{agentID: "2", tick: "2", valuesn:[{methodName: "flatRoof", valuen: 0.4}, {methodName: "roof", valuen: 0.6}]},
{agentID: "0", tick: "3", valuesn:[{methodName: "flatRoof", valuen: 0.1}, {methodName: "roof", valuen: 0.9}]},
{agentID: "1", tick: "4", valuesn:[{methodName: "flatRoof", valuen: 0.4}, {methodName: "roof", valuen: 0.6}]},
{agentID: "2", tick: "5", valuesn:[{methodName: "flatRoof", valuen: 0.1}, {methodName: "roof", valuen: 0.9}]}
]
Explanation
Normally my data set would look like the below example. So you can see there are eight entries. The data is from a simulation, so each tick and an agent should represent one data row. So I have multiple agents which can change during the ticks. An agent has properties which are represented by the columns after the agent property. So a data set with four ticks and two agents could look like the following result:
[
{"tickID":0,"AgentID":"0","geometryTableName":"geometryTableName_tick0","flat roof":0.2,"roof":0.4,"saddled roof":0.2,"other roof":0.2,"ellipticfit":6.21025,"mainDirection",.........},
{"tickID":0,"AgentID":"1","geometryTableName":"geometryTableName_tick0","flat roof":0.61,"roof":0,"saddled roof":0.23,"other roof":0.23,"ellipticfit":6.4,"mainDirection",.........},
{"tickID":1,"AgentID":"0","geometryTableName":"geometryTableName_tick1","flat roof":0.62,"roof":0.1,"saddled roof":0.21,"other roof":0.21,"ellipticfit":6.6,"mainDirection",.........},
{"tickID":1,"AgentID":"1","geometryTableName":"geometryTableName_tick1","flat roof":0.63,"roof":0.2,"saddled roof":0.2,"other roof":0.2,"ellipticfit":6.21025,"mainDirection",.........}
{"tickID":2,"AgentID":"0","geometryTableName":"geometryTableName_tick2","flat roof":0.64,"roof":0,"saddled roof":0.2,"other roof":0.2,"ellipticfit":6.4,"mainDirection",.........}
{"tickID":2,"AgentID":"1","geometryTableName":"geometryTableName_tick2","flat roof":0.65,"roof":0,"saddled roof":0.2,"other roof":0.2,"ellipticfit":6.1,"mainDirection",.........}
{"tickID":3,"AgentID":"0","geometryTableName":"geometryTableName_tick3","flat roof":0.66,"roof":0,"saddled roof":0.2,"other roof":0.2,"ellipticfit":6.2,"mainDirection",.........}
{"tickID":3,"AgentID":"1","geometryTableName":"geometryTableName_tick3","flat roof":0.61,"roof":0,"saddled roof":0.2,"other roof":0.2,"ellipticfit":6.2,"mainDirection",.........}
]
Because I needed a pie chart of the columns flat roof, roof, saddled roof and other roof I changed the data strucutre because for the pie chart you need records like these:
type roof value
flat roof 0.2
other roof 0.4
I changed the strucutre to the following:
[
{"tickID":0,"AgentID":"0","geometryTableName":"geometryTableName_tick0","classID":8,"name":"flat roof","memDegree":0.2,"ellipticfit":6.21025,"mainDirection",.........},
{"tickID":0,"AgentID":"0","geometryTableName":"geometryTableName_tick0","classID":1,"name":"roof","memDegree":0.4,"ellipticfit":6.21025,"mainDirection",.........},
{"tickID":0,"AgentID":"0","geometryTableName":"geometryTableName_tick0","classID":7,"name":"saddled roof","memDegree":0.2,"ellipticfit":6.21025,"mainDirection",.........},
{"tickID":0,"AgentID":"0","geometryTableName":"geometryTableName_tick0","classID":9,"name":"other roof","memDegree":0.2,"ellipticfit":6.21025,"mainDirection",.........},
{"tickID":0,"AgentID":"1","geometryTableName":"geometryTableName_tick1","classID":8,"name":"flat roof","memDegree":0.6,"ellipticfit":6.21025,"mainDirection",.........},
{"tickID":0,"AgentID":"1","geometryTableName":"geometryTableName_tick1","classID":1,"name":"roof","memDegree":0,"ellipticfit":6.21025,"mainDirection",.........},
{"tickID":0,"AgentID":"1","geometryTableName":"geometryTableName_tick1","classID":7,"name":"saddled roof","memDegree":0.2,"ellipticfit":6.21025,"mainDirection",.........},
{"tickID":0,"AgentID":"1","geometryTableName":"geometryTableName_tick1","classID":9,"name":"other roof","memDegree":0.2,"ellipticfit":6.21025,"mainDirection",.........}
]
Now this is why I ended up with duplicate rows. The values for flat roof, roof, saddled roof and other roof are distinct but the values for all the other columns are duplicate because I changed the data structure. And my problem is now if I show the other data in an data table I have duplicate values (see screenshot).