Forgot to update README file

This commit is contained in:
Phyks 2014-04-18 21:59:42 +02:00
parent aa5534f8df
commit dd37d440b3
1 changed files with 11 additions and 11 deletions

View File

@ -2,7 +2,7 @@ Timeline.js
===========
Timeline.js is a lightweight JS library to plot graphs using SVG. As it uses SVG, you can add event listeners on the plotted graph very easily.
Timeline.js is a lightweight JS library to plot graphs using Timeline. As it uses Timeline, you can add event listeners on the plotted graph very easily.
I coded it because I couldn't find any basic JS library to do this, without any external dependencies and extra features. Timeline.js is only 13k once minified, and can be reduced under 10k with obfuscation. Better results may be obtained with a little refactor, but that's enough for me. Plus it can be very easily customised to fit your needs.
@ -23,27 +23,27 @@ I coded it because I couldn't find any basic JS library to do this, without any
First, you must include the `timeline.js` or `timeline.min.js` script.
Then, you need to init the SVG drawing, using `SVG.init({'id': 'holder', 'height': '100%', 'width': '100%', 'grid': 'both', 'x_axis': true, 'rounded': false, 'x_callback': false});`. The arguments are all optional and are:
* `id` : the id of the parent element that will contain the SVG
* `width` / `height` : width and height of the created SVG
Then, you need to init the Timeline drawing, using `Timeline.init({'id': 'holder', 'height': '100%', 'width': '100%', 'grid': 'both', 'x_axis': true, 'rounded': false, 'x_callback': false});`. The arguments are all optional and are:
* `id` : the id of the parent element that will contain the Timeline
* `width` / `height` : width and height of the created Timeline
* `grid` : none / small / big / both to choose which type of grid you want
* `x_axis` : true / false to show / hide the x axis
* `line` : none / line / dashed to choose line type. You can edit the dasharray by replacing `SVG.dash_style` value
* `line` : none / line / dashed to choose line type. You can edit the dasharray by replacing `Timeline.dash_style` value
* `fill` : true / false to fill the area below the graph or not
* `rounded` : true / false to use splines to smoothen the graph or not
* `x_callback` : callback function to call to get texts for the x legend. Not yet implemented
Then, you can add as many graphs as you want, with `SVG.addGraph(NAME, COLOR);` where COLOR must be a valid CSS color.
And you can add points using `SVG.addPoints(GRAPH_NAME, POINTS);`. Points is an array of point objects, which are of the type `{'x': ABSCISSA, 'y': ORDINATE, 'label': LABEL}`. LABEL is the text to display in the infobox when the mouse is over the point. You can use '%x' and '%y' in labels and they will be automatically replaced by the coordinates. You can also use `<sup>` and `<sub>` HTML tags. You can add another (optional) element `click` which must be a ffunction to bind to onclick event on this point.
Then, you can add as many graphs as you want, with `Timeline.addGraph(NAME, COLOR);` where COLOR must be a valid CSS color.
And you can add points using `Timeline.addPoints(GRAPH_NAME, POINTS);`. Points is an array of point objects, which are of the type `{'x': ABSCISSA, 'y': ORDINATE, 'label': LABEL}`. LABEL is the text to display in the infobox when the mouse is over the point. You can use '%x' and '%y' in labels and they will be automatically replaced by the coordinates. You can also use `<sup>` and `<sub>` HTML tags. You can add another (optional) element `click` which must be a ffunction to bind to onclick event on this point.
_Note_ : You don't have to sort the points inside a same list of points in a SVG.addGraph call. They will be sorted for you. But, if you call SVG.addPoints multiple times, you must sort the points yourself between each call. The script won't do it for you and it will result in weird graphs if you don't do it.
_Note_ : You don't have to sort the points inside a same list of points in a Timeline.addGraph call. They will be sorted for you. But, if you call Timeline.addPoints multiple times, you must sort the points yourself between each call. The script won't do it for you and it will result in weird graphs if you don't do it.
Finally, you can draw the SVG with `SVG.draw();`.
Finally, you can draw the Timeline with `Timeline.draw();`.
## Other functions
* `SVG.clearGraph(GRAPH);` to delete the data for the graph GRAPH, or for all graphs + the graphs definition if GRAPH is not specified.
* `SVG.hasGraph(GRAPH);` to check if a graph with name GRAPH has already been defined or not.
* `Timeline.clearGraph(GRAPH);` to delete the data for the graph GRAPH, or for all graphs + the graphs definition if GRAPH is not specified.
* `Timeline.hasGraph(GRAPH);` to check if a graph with name GRAPH has already been defined or not.
## License