2

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}]}
]

enter image description here

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).

Community
  • 1
  • 1
user2644964
  • 763
  • 2
  • 10
  • 28
  • 1
    If you're using Crossfilter, you really should go with the repetitive values in your data structure. Given your example, the volume of data shouldn't be causing a problem. If you are having trouble with volume, please explain the issue you're having and maybe we can help. – Ethan Jewett Jul 26 '15 at 16:44
  • Hi, thanks for your reply. My problem is when I'm using a data table and I show the entries ellipticfit and mainDirection they are duplicate. Indstead of one time they appear 4 times. So I'm not able to show distinct rows. – user2644964 Jul 27 '15 at 05:48
  • 1
    They're not really duplicate because they have different names, right? I think you should put together a working example showing what you have and explain exactly what you'd like to see instead. I suspect the solution will be to create a facade dimension that collapses duplicate values to feed to to the data table. – Ethan Jewett Jul 27 '15 at 14:29
  • Hi, I added above a screenshoot from the current result. Currently I'm using the first data structure which is in my main post. The problem is in the details table you can see that an entry apperas 4 times with the same values because I had to store the values redundant. Did the screenshoot helps you or do you need an working example? – user2644964 Jul 27 '15 at 17:30
  • 1
    A working example makes it a lot easier to demonstrate a solution. But, theoretically, why not just add the 'name' field to the table? – Ethan Jewett Jul 27 '15 at 20:26
  • Hi Ethan, now I created a working example: https://jsfiddle.net/zz3gd1fy/1/. – user2644964 Jul 28 '15 at 17:19
  • There was something wrong with the link. This one should work now: http://jsfiddle.net/zz3gd1fy/1/. – user2644964 Jul 28 '15 at 19:54
  • 1
    Ok, but I still don't get what you are trying to do here. They are separate records. What do these records actually represent? Two options for you: Add name to the table so it is clear they are unique records (https://jsfiddle.net/1h5owma7/) or you can create a fake dimension to filter out duplicate records by whatever key you choose (https://jsfiddle.net/53kt455m/) – Ethan Jewett Jul 28 '15 at 20:58
  • Hi Ethan, thanks for your reply. I added an explanation part of the data set in the main post. How did you mean that with the unique records to filter duplicate values? – user2644964 Jul 29 '15 at 05:35
  • 1
    Thanks for the explanation. Makes the problem much more clear. In that case, you would want to use the technique in the 2nd fiddle link I posted: https://jsfiddle.net/53kt455m/ Specifically, take a look at the definition of the fakeDim. – Ethan Jewett Jul 29 '15 at 13:41
  • Thank you very much the fake dimension worked. :) – user2644964 Jul 29 '15 at 15:36
  • Thanks :) It helps me a lot – Sanjay Kumar N S Jun 27 '16 at 12:38

0 Answers0