XKCD style narrative charts layout engine for d3.
This is just a layout engine; how you go about presenting and styling the result is entirely up to you.
See annotated source.
The inputs to the layout are two arrays of character and scene objects. These lists are then linked, grouped and sorted in various ways in an attempt to generate an optimal layout.
The resulting data structures are documented below.
Properties:
id
[int] a unique ID for the groupcharacters
[array of objects] an unordered array of characters assigned to this groupappearances
[array of objects] an ordered array of unique characters appearing in scenes assigned to this group (note that this is different from other.appearances
properties)min
[int] position on the y-axis that this group startsmax
[int] position on the y-axis that this group endsmedianCount
[int] the scenes in which this group is the median group of appearing charactersorder
[int] the appearance order of this group
Properties:
name
[string] the character's nameappearances
[array of objects] ordered array of appearances--see below for object structureaverageScenePosition
[number] the average group position of scenes this character appears in
Properties:
character
[object] the character appearingscene
[object] the scene the character is appearing iny
[int] the y-axis position of this appearance relative to the scene
Properties:
characters
[array of objects] an array of characters appearing in this sceneappearances
[array of objects] an array of apparances in this scenegroup
[object] the group this scene belongs to (the median group of all characters in scene)duration
[int] the duration of this scene (translated to x-axis space after the scene)start
[int] the raw start position of the scene (scaled to available x-axis space)height
[int] the height in pixels of this scenex
[number] the x-axis position of the sceney
[number] the y-axis position of the scene