Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/models/multiChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,12 @@ nv.models.multiChart = function() {
})
});

x .domain(d3.extent(d3.merge(series1.concat(series2)), function(d) { return d.x }))
.range([0, availableWidth]);
var ex = d3.extent(d3.merge(series1.concat(series2)), function(d) { return d.x }); // Allow extent to be used multiple times
for(var i = 0; i < charts.length; i++){ // Loop through all charts except bars1 and bars2 (because it's ordinal)
if(!(i === 4 || i === 5)){ charts[i].xDomain(ex); } // Set xDomain for each chart individually
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using the index, this should be checking if the charts are ordinal... otherwise someone adding/changing that array of charts will break this in a non-obvious way.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the response.
Sounds like you've got a good point there. I will look into it later.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@liquidpele
I'm truly sorry for this late reply.
It has been quite a long time since I have seen and touched this code. And unfortunately I don't really understand what you mean. Do you mean the for loop?

}

x.domain(ex).range([0, availableWidth]);

var wrap = container.selectAll('g.wrap.multiChart').data([data]);
var gEnter = wrap.enter().append('g').attr('class', 'wrap nvd3 multiChart').append('g');
Expand Down