creation of the graph
const graph = new WILCO.Graph(container, options)
container
: a d3<g>
element that will host the graph (ex:my_anim.go()
). A sub container will be created within it and translated accordinglyoptions
: it is an object that defines customizations:width
: the width of the graph (number). If not passed, then the bounding box of the container is usedheight
: the height of the graph (number) If not passed, then the bounding box of the container is usedxScale
: a d3 scale:d3.time.scale()
to force the X spanyScale
: a d3 scale:d3.scale
to force the Y spanmargin
: a structure likemargin: {left:0, top:0, bottom:10,right:0}
to set the margins of the chart. By default, it ismargin: {left:30, top:30, bottom:30,right:30}
,axis
: do you want to display the axis. See below for options:axis: { showX:{grid:true}, showY:false}
Please note that the bounding box of a container (
g
) is the bounding box of its content. It means that if you define the container as an empty group, it will have x, y, height and width set to 0. To have a correct bounding box, we suggest you add a<rect>
in it so that the bounding box is the rect properties
Here is the definition of the axis object:
grid
: a boolean to display or not the gridticks
: the count of tickssize
: the size of the text displayed for each tick
example:
Last updated
Was this helpful?