Add error bar capability

Chris Leonello avatarChris Leonello 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 =>

    {renderer:$.jqplot.OHLCRenderer,rendererOptions:{errorBar:true}}
    
  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

    Hi,

    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
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.