我目前有以下数据结构来绘制图表:
[
{"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",.........}
]
如您所见,为了完成 classID ,名称和 memDegree 的平面数据结构,tickID,AgentID始终存在重复值,geometryTableName和其他列。所以接下来的3行总是加倍。为什么我创建了这个数据结构,因为这是唯一的数据结构,使我能够从 name 和 memDegree 列创建饼图。是否有可能创建一个更好的数据结构,我没有多余的值,我还可以从名称和 memDegree 创建一个饼图?
我已经尝试创建一个新的数据结构,删除了重复的值,但后来我无法创建饼图。
[
{"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",.........},
]
还尝试了以下数据结构,但是使用这种结构我与其他图表没有任何联系。当我点击一个酒吧的东西时,另一个酒吧的一切都是空的。 (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}]}
]
解释
通常我的数据集看起来像下面的例子。所以你可以看到有八个条目。数据来自模拟,因此每个tick和代理应代表一个数据行。所以我有多个代理可以在刻度期间改变。代理具有由代理属性之后的列表示的属性。因此,具有四个刻度和两个代理的数据集可能看起来像以下结果:
[
{"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",.........}
]
因为我需要柱屋顶,屋顶,鞍形屋顶和其他屋顶的饼图我更改了数据结构,因为饼图需要这样的记录:
type roof value
flat roof 0.2
other roof 0.4
我将结构改为:
[
{"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",.........}
]
现在这就是为什么我最终得到了重复的行。平屋顶,屋顶,鞍形屋顶和其他屋顶的值是不同的,但所有其他列的值都是重复的,因为我改变了数据结构。现在我的问题是,如果我在数据表中显示其他数据,我有重复的值(见截图)。