Issue #513 open

Bar width doesn't change when resizing the plot

Bruno Harbulot
created an issue

When resizing (as described in //examples/resizablePlot.html//) a plot that uses the BarRenderer, the bar width stays the same as when the plot was initially drawn.

This leads to bars overlapping each other when the size is reduced and too large gaps when the size is increased.

In //$.jqplot.BarRenderer.prototype.draw// and in //$.jqplot.BarRenderer.prototype.drawShadow//, calling setBarWidth whether there is a value for this.barWidth or not seems to fix the problem. (Not sure if it's a good solution...)

{{{ //if (this.barWidth == null) { this.renderer.setBarWidth.call(this); //} }}}

Comments (10)

  1. Chris Leonello repo owner
    • changed status to open

    Thanks for pointing this out. The fix, however will override any user specified barWidth option. It will *always* auto calculate bar width. I'll implement a more permanent fix.

    Thanks again!

  2. Anonymous

    thanks Bruno for idea

    in my case I make this

    if (this.barWidth == null || this.rendererOptions.barWidth == null) {
                this.renderer.setBarWidth.call(this);
            }
    
  3. Paul Pritchard

    Alexander, to make progress on this, we need a test case: a version of examples/resizablePlot.html that has bar charts instead of line charts. Ideally, this page would have two bar charts that both use the second resizing method. The first bar chart would not specify a barWidth, and the second chart would have a barWidth. If you want to speed things up by creating that, it would help.

  4. cdaragorn

    It's been 2 years since the pull request for this issue was submitted. I just ran into it and after looking at the code went ahead and just edited those 2 lines in my own copy, but I was wondering if there are any plans to merge this fix into the release ever?

  5. Log in to comment