jsGraph can display error bars and error boxes in
bar series. Error bars are used to display the uncertainty in a measurement that can be represented by one standard deviation, one standard error, or a certain interval of considence. They are used to visually check for stastical significance between different measurements. jsGraph implements multiple levels of error bars.
For instance, you could assign 1 σ to the box and 3 σ to the bars. (**Note: ** The syntax used to define error bars in line and scatter series is exactly the same. It can be used interchangeably.)
Error data are essentially stored in multi-level array, such as :
[ [ [ [ 0.5, 0.2 ], [ 0.8, 0.2 ] ] ] ]
- The first level corresponds to your data. Error at index n of the array will be assigned to dat at index n.
- The second level differentiates error bars in the x or the y direction. First argument is y, second is x. You can omit the x value if needed, but there still needs to be an array.
- The third level reprensents bars or boxes. To know which one is which, refer to the order you specified in the
nullnot to display errors of this level for this particular point
- The fourth level represents above/below or lefthand/righthand error bars/boxes. Use only one argument to make it symmetric.
Here are a few examples to help the reader understand
[ null, [ [ 3 ], [ [ 4, 5 ] ] ] ] Assigns to the second point of your data a value in the y direction (3) and a value in the x direction (4 and 5). Both of these values are in the first level of error (they have the same type). The value in the y direction (3) is symmetrical above and below the point (+3 and -3). While in the x dimension, the value on the lefthand side is 4 and on the righthand side 5.
[ null, null, [ null, [ 4, 5 ] ] ] assigns to the third point of your data no error bar in the y dimension, and two error bar (or boxes) in the x dimension (level 3, remember ?). Both values are symmetrical left and right of the point.
[ null, null, [ null, [ 4, [ 3, 2 ] ] ] ] same as before, except that the second error level is no more symmetrical, but takes the value 3 (left) and 2 (right).
Setting error data is not enough. You need to tell jsGraph how you want the error to be handled. For that, you need to call the method
setErrorStyle that takes only one parameter: an array which elements are styles for each level of error. Example:
Here is an example that displays error bars over a scatter plot