A layout that arranges nodes in a grid where the x and y axis values can be determined by function(s) of the data.
var display = new thinkmap.display.Display(document.getElementById('mydiv'));
thinkmap.layout.gridLayout(display)
.scaleX( thinkmap.scale.linear() )
.valueX( function(e) { return e.data.cost; } )
.scaleY( thinkmap.scale.linear() )
.valueY( function(e) { return e.data.revenue; } );
display.layout();
Returns a new scale that can be used to make sure that all entities plotted on the x axis are visible within the display. This is typically used when a developer wants to see all entities at once on the grid layout as opposed to zooming in and and out to achieve the same effect.
This method is almost always used directly with the scaleX function as this method just returns a new scale and doesn't directly scale the grid. That is up to the scaleX function.
More importantly, this function also allows calculating the best fit using an optional selection, this is ideal for cases where only the best fit for a certain group of entities should be used.
the optional value in pixels where the leftmost boundary of the leftmost entity will be placed. Default is 0.
the optional value in pixels where the rightmost boundary of the rightmost entity will be placed. Default is the width of the display containing the layout.
the optional scale to be used. This is typically null in which case the default scale for the X axis will be used.
an optional selection that contains only the entities that will be included when calculating the best fit. This selection should a subset of the entities already in the display. The default is all the entities in the display that pass the filter function of this GridLayout.
var graph = new thinkmap.graph.Graph();
var display = new thinkmap.display.Display();
var layout = thinkmap.layout.gridLayout(display)
.filter(function(e) { return e.data.runtime != null; } )
.valueX(function(e) { return e.data.runtime;})
.scaleX(thinkmap.scale.linear());
graph.datasource("/server.tas");
graph.query('movie').execute() // load all movies and add to display
.onresult(display.add);
.oncomplete(function(results) {
gridLayout.scaleX(
gridLayout.bestFitX(20,20);
);
display.layout();
});
var graph = new thinkmap.graph.Graph();
var display = new thinkmap.display.Display();
var layout = thinkmap.layout.gridLayout(display)
.filter(function(e) { return e.data.release != null })
.valueX(function(e) { return e.data.release;})
.scaleX(thinkmap.scale.time());
graph.datasource("/server.tas");
graph.query('movie').execute() // load all movies and add to display
.onresult(display.add);
.oncomplete(function(results) {
// create a selection of only movies coming after 1984
var selection = display.nodes().filter(function(e) {
return e.data.release.getFullYear() >= 1985;
});
gridLayout.scaleX( // use that selection for the best fit
gridLayout.bestFitX(20,20,null,selection);
);
display.layout();
});
Returns a new scale that can be used to make sure that all entities plotted on the y axis are visible within the display. This is typically used when a developer wants to see all entities at once as the grid layout as opposed to zooming in and and out to achieve the same effect.
This method is almost always used directly with the scaleY function as this method just returns a new scale and doesn't directly scale the grid. That is up to the scaleY function.
the optional value in pixels where the topmost boundary of the topmost entity will be placed. Default is 0.
the optional value in pixels where the bottommost boundary of the bottommost entity will be placed. Default is the height of the display containing the layout.
the optional scale to be used. This is typically null in which case the default scale for the Y axis will be used.
an optional selection that contains only the entities that will be included when calculating the best fit. This selection should a subset of the entities already in the display. The default is all the entities in the display that pass the filter function of this GridLayout.
var graph = new thinkmap.graph.Graph();
var display = new thinkmap.display.Display();
var layout = thinkmap.layout.gridLayout(display)
.filter(function(e) { return e.data.runtime != null; } )
.valueY(function(e) { return e.data.runtime;})
.scaleY(thinkmap.scale.linear());
graph.datasource("/server.tas");
graph.query('movie').execute() // load all movies and add to display
.onresult(display.add);
.oncomplete(function(results) {
gridLayout.scaleY(
gridLayout.bestFitY(20,20);
);
display.layout();
});
var graph = new thinkmap.graph.Graph();
var display = new thinkmap.display.Display();
var layout = thinkmap.layout.gridLayout(display)
.filter(function(e) { return e.data.release != null })
.valueY(function(e) { return e.data.release;})
.scaleY(thinkmap.scale.time());
graph.datasource("/server.tas");
graph.query('movie').execute() // load all movies and add to display
.onresult(display.add);
.oncomplete(function(results) {
// create a selection of only movies coming after 1984
var selection = display.nodes().filter(function(e) {
return e.data.release.getFullYear() >= 1985;
});
gridLayout.scaleY( // use that selection for the best fit
gridLayout.bestFitY(20,20,null,selection);
);
display.layout();
});
Returns the display used with this GridLayout
Sets (or gets) the function used to filter which entities the grid layout will evaluate. The default value is null which means all entities in the display are evaluated.
the optional argument that sets the filter function
returns the filter function if no arguments are passed in, else the filter function is set and this GridLayout is returned.
thinkmap.layout.gridLayout(display)
.filter(function(e) { return e.data.usgross != null })
.valueX(function(e) { return e.data.usgross })
.scaleX(thinkmap.scale.linear())
Sets (or gets) the formatX function used by this GridLayout.
The formatX method determines the way in which values along the x-axis are formatted. A good example would be values that deal with currency may want to have labels that pretty print the value and add a $ sign. The formatX method takes a function that receives a calculated integer value and returns the string representation of this value. The default is value is no formatX is set which means the built in string representation of the value is used as the label.
returns the formatX value if no arguments are passed to this method, else the formatX value is set and this GridLayout is returned.
Sets (or gets) the formatY function used by this GridLayout.
The formatY method determines the way in which values along the x-axis are formatted. A good example would be values that deal with currency may want to have labels that pretty print the value and add a $ sign. The formatY method takes a function that receives a calculated integer value and returns the string representation of this value. The default is value is no formatY is set which means the built in string representation of the value is used as the label.
returns the formatY value if no arguments are passed to this method, else the formatY value is set and this GridLayout is returned.
Sets (or gets) the array of colors used to draw the grid lines of this GridLayout.
The Grid uses three colors for the grid lines. They are arranged such that each color corresponds to drawing the largest, medium, and smallest units along the grid. It is possible to in fact use clear colors in cases where a user may only want one or two lines to be drawn rather than all three.
The default value is this array of colors: ['#CCCCCC', '#E0E0E0', '#F3F3F3' ]
the current value of grid colors if no arguments are used, else the new array of colors is set and this GridLayout is returned
gridLayout.gridColors(['#CCCCCC', '#E0E0E0', '#F3F3F3' ])
Sets (or gets) the amount of spacing between entities in each group.
In swim lanes, the entities in each group are stacked on top of each other. This number represents the amount of spacing for each entity when stacking them in a group.
the optional argument that sets the amount of stacking space between each entity in a swim lane.
returns the group item spacing if no arguments are passed else the group item spacing is set and this GridLayout is returned.
Sets (or gets) the amount of margin space added to each group (swim lane) in the grid layout.
For instance, if the swim lanes were horizontal, and the group margin was 5, then 5px will be added to the the top and bottom of the each swim lane. This way any entities in each swim lane are not on top of the lines demarcating each swim lane, thus making them more readable.
the optional margin object that describes the spacing
returns group margin if no arguments are passed else the group margin is set and this GridLayout is returned.
gridLayout.groupMargin({top:20,left:20,bottom:20,right:20})
Sets (or gets) the sort used within each group along the x-axis(i.e. swimlanes).
When using groups, the entities that share the same group are stacked on top of each other. The groupXSort handles the actual ordering of how the entities themselves are stacked.
The sort is the typical standard JavaScript function where two values are passed and -1, 1, and 0 are returned regarding equality. The parameters to the sort function are the values calculated by the valueX method of this GridLayout.
The default value is null which means if grouping is used, then the natural ordering of the elements will be the sort.
if no arguments are passed, then the current groupYSort is returned, else the groupYSort is set and this GridLayout is returned
Sets (or gets) the sort used within each group (i.e. swimlanes).
When using groups, the entities that share the same group are stacked next to each other. The groupYSort handles the actual ordering of how the entities themselves are stacked.
The sort is the typical standard JavaScript function where two values are passed and -1, 1, and 0 are returned regarding equality. The parameters to the sort function are the values calculated by the valueY method of this GridLayout.
The default value is null which means if grouping is used, then the natural ordering of the elements will be the sort.
if no arguments are passed, then the current groupYSort is returned, else the groupYSort is set and this GridLayout is returned
Redraws and repaints the entire grid
Sets (or gets) the scale for the x-axis. If the scale is null, then the grid layout will use swim lanes for unique values along the x-axis
There are currently two types of scales which can be used: thinkmap.scale.linear() and thinkmap.scale.time()
the optional scale argument to set
returns the scale function if no arguments are passed in, else the new scale function is set and this GridLayout is returned
thinkmap.layout.gridLayout(display)
.filter(function(e) { return e.data.runtime != null; } )
.valueX(function(e) { return e.data.runtime;})
.scaleX(thinkmap.scale.linear());
thinkmap.layout.gridLayout(display)
.filter(function(e) { return e.data.release != null; } )
.valueX(function(e) { return e.data.release;})
.scaleX(thinkmap.scale.time());
thinkmap.layout.gridLayout(display)
.filter(function(e) { return e.data.stars != null; } )
.valueX(function(e) { return e.data.stars;})
.scaleX(null);
thinkmap.layout.gridLayout(display)
.filter(function(e) { return e.data.stars != null; } )
.valueX(function(e) { return e.data.stars;})
.scaleX(null);
Sets (or gets) the scale for the y-axis. If the scale is null, then the grid layout will use swim lanes for unique values along the y-axis
There are currently two types of scales which can be used: thinkmap.scale.linear() and thinkmap.scale.time()
the optional scale argument to set
returns the scale function if no arguments are passed in, else the new scale function is set and this GridLayout is returned
thinkmap.layout.gridLayout(display)
.filter(function(e) { return e.data.runtime != null; } )
.valueY(function(e) { return e.data.runtime;})
.scaleY(thinkmap.scale.linear());
thinkmap.layout.gridLayout(display)
.filter(function(e) { return e.data.release != null; } )
.valueY(function(e) { return e.data.release;})
.scaleY(thinkmap.scale.time());
thinkmap.layout.gridLayout(display)
.filter(function(e) { return e.data.stars != null; } )
.valueY(function(e) { return e.data.stars;})
.scaleY(null);
Gets the target position of the given node given the last layout state of this grid layout. If the node was not in the last layout, then null is returned.
Returns a transition that can be used to set the scale
Sets (or gets) the valueX value of this GridLayout.
The valueX is used to calculate the x value of a given entity. The valueX is represented as a function that takes an entity and returns a number which is then used by the GridLayout to determine the position of this entity along the GridLayout (in respect to the x-axis).
The valueX should also correspond correctly with the scaleX function, as the scaleX will be used to scale this value appropriately for the GridLayout.
the optional valueX function to set. The default value is a function which returns nothing.
returns the valueX function if no argument is passed, else the valueX function is set and this GridLayout is returned.
Sets (or gets) the valueY value of this GridLayout.
The valueY is used to calculate the y value of a given entity. The valueY is represented as a function that takes an entity and returns a number which is then used by the GridLayout to determine the position of this entity along the GridLayout (in respect to the y-axis).
The valueY should also correspond correctly with the scaleY function, as the scaleY will be used to scale this value appropriately for the GridLayout.
the optional valueY function to set. The default value is a function which returns nothing.
returns the valueY function if no argument is passed, else the valueY function is set and this GridLayout is returned.
Sets (or Gets) where the x axis location is placed. This can either be 'top' or 'bottom'. The default is 'top'.
the optional parameter of where the x axis is drawn. The values can be either 'top' or 'bottom'. The default is 'top'
returns the current x axis location if no parameters are passed, else the x axis location is set and the GridLayout is returned.
Sets (or gets) the stroke color used to draw the horizontal line that runs along the x-axis and separates the labels along the x axis from the actual data points.
the optional color to set as the stroke used for the x-axis line
returns the string representation of the stroke color if no arguments are passed to this method, else the new stroke color is set and this GridLayout is returned.
gridLayout.xAxisStrong('#FF0000');
Sets (or Gets) where the y axis location is placed. This can either be 'left' or 'right'. The default is 'left'.
the optional parameter of where the y axis is drawn. The values can be either 'right' or 'right'. The default is 'left'
returns the current y axis location if no parameters are passed, else the y axis location is set and the GridLayout is returned.
Sets (or gets) the stroke color used to draw the vertical line that runs along the y-axis and separates the labels along the y axis from the actual data points.
the optional color to set as the stroke used for the y-axis line
returns the string representation of the stroke color if no arguments are passed to this method, else the new stroke color is set and this GridLayout is returned.
gridLayout.xAxisStrong('#FF0000');
Enables or disables this layout.
If called with zero arguments, returns true if this layout is enabled.
true to enable this layout
this layout, or a boolean if called with zero arguments.