Skip to content

Bar charts with rangeChart breaks mouse zoom on second render call. #1857

@Spacarar

Description

@Spacarar

Description of problem

When you have a bar chart that includes a mouse-zoomable range chart attached, calling render more than once breaks the mouse zooming. After the second render call, any attempt to zoom the mouse will yield only a small section of the selectable area.

Steps to reproduce

Screen Shot 2022-01-11 at 11 42 26 AM

discussion

The reason I'm calling render more than once, is because it's the easiest way for the charts to resize themselves properly when the window changes size that I have found. If there is a better, or more correct solution for this problem then I would like to know.

The problem appears to lie somewhere in the _configureMouseZoom() call and replacing the _doRender function to exclude this after the first call seems to fix the solution at least temporarily.

so, my temporary fix is to do something like

let chart = new dc.BarChart('#the-chart')
   ...chartStuff
 
let focusChart = new dc.BarChart('#the-chart-scale')
   ...focusChartStuff

chart.rangeChart(focusChart)

chart.render()
focusChart.render()

// take out this._configureMouseZoom()
// see coordinate grid mixin docs above for original function definition that we are overriding
chart._doRender = function() {
  this.resetSvg();
  this._preprocessData();
  this._generateG();
  this._generateClipPath();
  this._drawChart(true);
  return this
}

Thanks for your consideration and any input you have on how to fix this issue going forward.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions