Javascript library to implement a interactive zoomable treemap.
Below is quick example how to use :
Download the latest version library and include it in your html.
<script src="js/jquery.js"></script>
<script src="js/d3.min.js"></script>
<script src="js/d3plus.min.js"></script>
<script src="js/map3.js"></script>
<link href="map3.css" rel="stylesheet">
Add a container in your html :
...
<div id="treemap"></div>
This code build a simple treemap
...
var viz = new Map3({
container: "#treemap",
label: "value",
size: "size"
});
viz.data(vizData);
The available configuration options from a treemap:
Type: String
Container where the list will build.
Type: Array|String
The json attribute name that determines the label of the box.
Type: Array
The json attribute name that determines the size of the box.
Type: Array|String
The Array of attributes that define the hierarchy of treemap.
Type: d3plus.time
Define the timeline of the treemap. See d3plus
Type: Options
{String}region
: See d3plus location.{Object}translate
: the translation map.
Support specifying a locale to use for translating common interface words and phrases into a different language.
var viz = new Map3({
container: "#treemap",
...
locale: {
region: "es_ES",
translate: {
"size": "Monto"
}
}
});
The available functions to interact with the treemap:
Type: Function
{Array}data
: the visualization data.
Sets the data associated with your visualization.
var vizData = [{
"value": "Data1",
"size": 2065724632,
}, {
"value": "Data2",
"size": 141765766652,
}, {
"value": "Data3",
"size": 48130171902,
}];
var viz = new Map3({
container: "#treemap",
label: "value",
size: "size"
});
//do something
//setting data
viz.data(vizData);
Type: Function
{Array}data
: the visualization data.
Redraw the visualization with new data.
Type: Function
{Object} options
: the value to format.
Wrapper method for d3plus.config.
var viz = new Map3({...});
viz.config({
color: {
scale: [
"#fdae6b",
"#EACE3F",
...
"#e099cf",
"#889ca3"
]
}
});
//setting data
viz.data(vizData);
Type: Function
{String}event
: the name of the event.{Function}handler
: handler function.
The events available are:
drill-down
: triggered when a box of the multilevel treemap is clicked.drill-up
: triggered when a element of breadcrumb is clicked.
var viz = new Map3({...});
viz.on("drill-down", function (d) {
//do something
console.log(d);
});
viz.on("drill-up", function (d) {
//do something
console.log(d);
});
//setting data
viz.data(vizData);
If you've found a bug or have a great idea for new feature let me know by [adding your suggestion] (http://github.com/mbaez/3map/issues/new) to issues list.