1. Chris Leonello
  2. jqplot
Issue #35 new

Add error bar capability

Chris Leonello
repo owner created an issue

Possibilities are some percentage, constant amount, standard deviation, or custom hi & low error values.

Comments (9)

  1. Miquel Torres

    I would consider this very useful, it would make jqplot attractive for the scientific and engineering community.

    As for the possibilities you mention, standard deviation is very common, but I guess custom hi&low error values would make everyone happy (may be a bit more tedious a method though).

  2. Jeremiah Faith

    This can be done with a small addition to the ohlc plugin. after line 293 add =>

                    else if (r.errorBar) {
    //                      console.log('in error bar');
                        prevColor = opts.color;
                        if (r.openColor) {
                            opts.color = r.openColor;
                        // draw open tick
                        opts.color = prevColor;
                        // draw wick
                        if (r.wickColor) {
                            opts.color = r.wickColor;
                        // draw horizontal line of upper and lower bound
                        r.shapeRenderer.draw(ctx, [[x, hi], [x, low]], opts);
                        opts.color  = prevColor;
                        // draw upper bound horizontal line 
                        r.shapeRenderer.draw(ctx, [[x+r._tickLength/2, hi], [x-r._tickLength/2, hi]], opts);
                        // draw lower bound horizontal line
                        r.shapeRenderer.draw(ctx, [[x+r._tickLength/2, low], [x-r._tickLength/2, low]], opts);
                        // draw the mean
                        opts.fillRect = true;
                        r.shapeRenderer.draw(ctx, [Math.round(x-(r._tickLength/4)), Math.round(close-(r._tickLength/4)), r._tickLength/2, r._tickLength/2], opts);
                        opts.color = prevColor;
                        opts.fillRect = false;

    then when calling $.jqplot() use the OHLCRenderer with the following options =>

  3. Anonymous

    jQplot is a great product. Any plans for implementing error bars?

    Many plots can be misleading without error bars. Without them, jQplot is useful for displaying counts of things, but for calculated or measured data it suffers for want of error bars. Many areas of business are becoming increasingly quantified with scientific methods used. Don't assume error bars are only for scientists and engineers. I've been advocating jQplot over R in our company, only to run into this issue. I've never heard of a plot package without error bars, so I assumed you had them.

    What I'd like is for each point to have it's own error value in the same units as the data, from which an error bar is generated with appropriate length above and below. Having separate high and low values and other options would be useful as Miquel suggested. Treating the errors similar to how you supply tick labels for the x-axis would be convenient.

    I've invested a bit in jQplot already, so I'll give it a good college try to hack in error bars into the other renders I use (not OHLC). At this point, I know absolutely nothing about the code (except for the above!) is this a good place for feedback?

  4. Fabian Sturm


    just in case you don't know, the lineRenderer supports error bars and confidence intervals as a band. See examples/bandedLine.html in the source distribution. It's nowhere on the website so I also only found it by chance.

  5. Log in to comment