A canvas widget used by all visualizations. The canvas object can be accessed by doing viz.canvas. If you want to know more about Canvas options take a look at Options.Canvas.
A canvas widget is a set of DOM elements that wrap the native canvas DOM Element providing a consistent API and behavior across all browsers. It can also include Elements to add DOM (SVG or HTML) label support to all visualizations.
Example
Suppose we have this HTML
<div id="infovis"></div>
Now we create a new Visualization
var viz = new $jit.Viz({
//Where to inject the canvas. Any div container will do.
'injectInto':'infovis',
//width and height for canvas.
//Default's to the container offsetWidth and Height.
'width': 900,
'height':500
});
The generated HTML will look like this
<div id="infovis">
<div id="infovis-canvaswidget" style="position:relative;">
<canvas id="infovis-canvas" width=900 height=500
style="position:absolute; top:0; left:0; width:900px; height:500px;" />
<div id="infovis-label"
style="overflow:visible; position:absolute; top:0; left:0; width:900px; height:0px">
</div>
</div>
</div>
As you can see, the generated HTML consists of a canvas DOM Element of id infovis-canvas and a div label container of id infovis-label, wrapped in a main div container of id infovis-canvaswidget.
Summary
Functions | |
getCtx | Returns the main canvas context object |
getConfig | Returns the current Configuration for this Canvas Widget. |
getElement | Returns the main Canvas DOM wrapper |
getSize | Returns canvas dimensions. |
resize | Resizes the canvas. |
translate | Applies a translation to the canvas. |
scale | Scales the canvas. |
getPos | Returns the canvas position as an x, y object. |
clear | Clears the canvas. |