pocorschi
pocorschi

Reputation: 3665

D3js json structure

I'm doing some charts with analytics regarding a game. Here is the basic assumptions.

There are three possible actions a player can make. Player can attack Player can deffend

Player can run ( in 2 directions forwards and backwards)

Each action can happen in one of the three battlegrounds (bg a, bg b, bg c)

A player can be human or alien. Each player regarding of race can have a level.

Each player executes a particular action at a particular time.

Now i need to chart these things.

Piechart of the players race Piechart of where the actions took place(in which of the 3 battlegrounds) A barchart of the players level A line chart for attacks based on time A line chart for defends based on time A linechart for runs( oneline for each direction of running) based on time

Each chart needs to be connected to the other ones (kondof the crossfilter flight charts are) . So for example if i click on the piechart with the player race and chose human the other charts update accordingly to reflect levels, and battlegrounds and actions pertaining just to that race.

Bottom line is i am having a hard time structuring my json input. Can any experts give me some hints? Thank you for your time.

Upvotes: 0

Views: 649

Answers (1)

meetamit
meetamit

Reputation: 25157

As I see it, the most flexible way is to build up an array of "events" (an event can be anything a player might do) with timestamps. Something like:

var playerEvents = [
  { timestamp: 1352848500, player:'human', action:'attack', location:'bg A' },
  { timestamp: 1352848600, player:'alien', action:'run', meta:'dir=left', location:'bg B' },
  ....
]

Once you have that, any stats you want display would involve filtering this array of events down to whatever you need for the given graphic.

Upvotes: 1

Related Questions