Skip to content

Commit

Permalink
Fix Tests and make reading width only if width unset (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
dkaoster authored Jan 11, 2021
1 parent e3f013f commit f0353be
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 3 additions & 2 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
module.exports = {
presets: [['@babel/preset-env', { modules: false }]],
module.exports = (api) => {
if (api.env('test')) return { presets: [['@babel/preset-env', { targets: { node: 'current' } }]] };
return { presets: [['@babel/preset-env', { modules: false }]] };
};
6 changes: 4 additions & 2 deletions src/parliament-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ export default (data = [], width = 0) => {
// This function gets called on instances such as:
// d3.select('g').call(parliamentChart())
const parliamentChart = (selection) => {
// Sets the graphicWidth based on our selected container
graphicWidth = selection.node().getBoundingClientRect().width;
if (graphicWidth === 0) {
// Sets the graphicWidth based on our selected container
graphicWidth = selection.node().getBoundingClientRect().width;
}

// Get the processed data (filter for entries that have x and y locations)
const processedData = parliamentChart.data().filter((r) => r.x && r.y);
Expand Down

0 comments on commit f0353be

Please sign in to comment.