chess-dataviz is a visualization library for chess, written for D3. It has a number of visualizations to show statistics on games, and plays nicely with other D3 plugins.
Getting started is super easy. Make sure to include the ChessDataViz JS/CSS files in your page, and you have graphs!
You can download the latest release as zip file, or use bower to get it:
$ bower install chess-dataviz
HeatMap visualization shows a chess board with squares overlaid to indicate how "hot" that square is. It's great for showing important squares, utilization, capture squares, etc. aggregated from thousands of games.
Default options with some data.
Dynamic data update, custom color scaling and d3.tip integration.
argument | description |
---|---|
selector | DOM selector that you would pass to d3.select() |
options | options configuration object
|
data | data formatted as:
The data consists of an array of 64 elements (only 2 shown in the example above) representing the squares, from top-left to bottom-right in row order ( |
Set or change the data of the graph. This method will automatically call update()
. The data format needs to be the same as the one that the constructor
accepts.
Change graph options. This method will automatically call update()
. You can change all the options as described in constructor
except width and margin.
Updates and re-draws the graph. You shouldn't need to call this under normal circumstances.
Holds the reference to the DOM object containing the <svg>
element. Same object as if you had called d3.select(selector)
.
Holds the reference to the <g>
element containing the data elements
d3 event dispatcher. You can hook your event handler to this property to listen to graph events.
The events are dispatched via this.dispatch
.
Will fire when mouse enters a heat square. The handler will be passed the current data
(count) for the square.
Will fire when mouse moves around a heat square.
Will fire when mouse leaves a heat square.
The CSS classes for styleable elements of the heatmap.
rect
corresponding to a heat squareOpenings visualization is a sunburst graph which shows openings in a given set of games, with customizable properties and interactive hover events. It's great for getting an idea of most popular openings in a glance, and digging into variations without hassle.
Default options with some data.
Data update, event handlers and custom colors.
argument | description |
---|---|
selector | DOM selector that you would pass to d3.select() |
options | options configuration object
|
data | data formatted as:
The data structure is what |
Set or change the data of the graph. This method will automatically call update()
. The data format needs to be the same as the one that the constructor
accepts.
Change graph options. This method will automatically call update()
. You can change all the options as described in constructor
except width and height.
Updates and re-draws the graph. You shouldn't need to call this under normal circumstances.
Holds the reference to the DOM object containing the <svg>
element. Same object as if you had called d3.select(selector)
.
Holds the reference to the <g>
element containing the data elements
d3 event dispatcher. You can hook your event handler to this property to listen to graph events.
The events are dispatched via this.dispatch
.
Will fire when mouse enters a heat square. The handler will be passed (data, moves)
for the arc. data
contains the data of the arc that is under the mouse, and moves
will be an array of moves up until that point (e.g. ['e4', 'e5', 'Nf3', 'Nf6']
if you were on the Nf6 arc).
Will fire when mouse moves around an arc.
Will fire when mouse leaves an arc.
The CSS classes for styleable elements of the sunburst graph.
Move Paths show the route that a particular piece takes through its life on the chess board. They are lines (quadratic bezier curves) that connect travelled squares together to give a sense of the piece's journey. It's a great way to see preferred moves, common manuevers and looks kinda pretty :)
Default options with some data and custom board colors.
argument | description |
---|---|
selector | DOM selector that you would pass to d3.select() |
options | options configuration object
|
data | data formatted as:
The data is an object with keys containing all the pieces' starting points, where the key values are objects with keys of the format |
Set or change the data of the graph. This method will automatically call update()
. The data format needs to be the same as the one that the constructor
accepts.
Change graph options. This method will automatically call update()
. You can change all the options as described in constructor
except width and margin.
Updates and re-draws the graph. You shouldn't need to call this under normal circumstances.
Holds the reference to the DOM object containing the <svg>
element. Same object as if you had called d3.select(selector)
.
Holds the reference to the <g>
element containing the data elements
The CSS classes for styleable elements of the board and paths.
path
corresponding to a path lineEval and Time graph is a combination of a line graph representing evaluation per move, and a bar graph representing time spent per move. It gives great sense of how much time players spend on what parts of the game, and how this reflects on the evaluation of the position.
Custom options with some data and interactive toggle.
argument | description |
---|---|
selector | DOM selector that you would pass to d3.select() |
options | options configuration object
|
data | data formatted as:
The data format is an array of objects describing the moves as |
Set or change the data of the graph. This method will automatically call update()
. The data format needs to be the same as the one that the constructor
accepts.
Change graph options. This method will automatically call update()
. You can change all the options as described in constructor
except width, height and margin.
Updates and re-draws the graph. You shouldn't need to call this under normal circumstances.
Holds the reference to the DOM object containing the <svg>
element. Same object as if you had called d3.select(selector)
.
d3 event dispatcher. You can hook your event handler to this property to listen to graph events.
The events are dispatched via this.dispatch
.
Will fire when mouse enters the graph area.
Will fire when mouse moves around on the graph, passing the current data point to the handler.
Will fire when mouse leaves the graph.
The CSS classes for styleable elements of the graph.
Heatmaps inspired by:
Move paths inspired by: