Skip to content

Commit

Permalink
finished release 0.10.0;
Browse files Browse the repository at this point in the history
  • Loading branch information
Basti Tee committed Feb 26, 2018
1 parent 644813f commit a77e098
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 27 deletions.
39 changes: 19 additions & 20 deletions d3-wb/d3-wb-modules/d3-wb-add.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@
let width = 500;
let height = 400;
let fill = 'white';
let backgroundColor = 'blue'
let backgroundColor = 'blue';
let padding = 0;
let borderRadius = 0;
let adjustBackgroundHeight = false;
Expand All @@ -385,7 +385,7 @@

data = []; // convert to objects
// remove multiple linebreaks
text = text.replace(/\n+/, '\n')
text = text.replace(/\n+/, '\n');
text.split('\n').forEach(function(d) {
data.push({
'text': d.trim(),
Expand All @@ -395,7 +395,7 @@
// base group for text box
let g = s.append('g')
.attr('class', 'wb-textbox')
.attr('transform', 'translate(' + x + ',' + y + ')')
.attr('transform', 'translate(' + x + ',' + y + ')');

// background color
let bg = g.append('rect')
Expand All @@ -405,7 +405,7 @@
.attr('height', height + padding * 2)
.attr('rx', borderRadius)
.attr('ry', borderRadius)
.attr('fill', backgroundColor)
.attr('fill', backgroundColor);

// draw and autoscale text
let totalHeight = 0;
Expand All @@ -428,11 +428,11 @@
d.numberBox = nodes[i].getBBox();
totalHeight += d.numberBox.height;
})
.call(d3wb.util.makeUnselectable())
.call(d3wb.util.makeUnselectable());

let totalShift = data.legend == 1 ? 0 :
(height - totalHeight) / (data.length - 1)
totalShift = totalShift > 0 ? 0 : totalShift
(height - totalHeight) / (data.length - 1);
totalShift = totalShift > 0 ? 0 : totalShift;

// relocate lines according to bounding box
g.selectAll('.wb-textbox-line')
Expand All @@ -456,17 +456,16 @@
totalShift;
}
return y;
})
});
d.numberBox = nodes[i].getBBox();
});

if (adjustBackgroundHeight) {
bg.attr('height', totalHeight +
padding * 2 + totalShift * (data.length - 1))
padding * 2 + totalShift * (data.length - 1));
}

drawDebugFrames(s, data, g);

});
};

Expand All @@ -478,7 +477,7 @@
let drawDebugFrames = function(s, data, g) {
if (!debug) return;

d3.selectAll('.wb-textbox-debug').remove()
d3.selectAll('.wb-textbox-debug').remove();
g.append('g').attr('class', 'wb-textbox-debug')
.selectAll('.wb-textbox-line-debug')
.data(data)
Expand All @@ -502,7 +501,7 @@

g.append('circle')
.attr('r', 4)
.style('fill', 'yellow')
.style('fill', 'yellow');
};

chart.x = function(value) {
Expand All @@ -524,10 +523,10 @@
};

chart.height = function(value) {
if (!arguments.length) return height
if (!arguments.length) return height;
height = value;
return chart;
}
};

chart.fill = function(value) {
if (!arguments.length) return fill;
Expand All @@ -536,10 +535,10 @@
};

chart.backgroundColor = function(value) {
if (!arguments.length) return backgroundColor
if (!arguments.length) return backgroundColor;
backgroundColor = value;
return chart;
}
};

chart.padding = function(value) {
if (!arguments.length) return padding;
Expand All @@ -548,16 +547,16 @@
};

chart.borderRadius = function(value) {
if (!arguments.length) return borderRadius
if (!arguments.length) return borderRadius;
borderRadius = value;
return chart;
}
};

chart.adjustBackgroundHeight = function(value) {
if (!arguments.length) return adjustBackgroundHeight
if (!arguments.length) return adjustBackgroundHeight;
adjustBackgroundHeight = value;
return chart;
}
};

return chart;
};
Expand Down
9 changes: 4 additions & 5 deletions d3-wb/d3-wb-reusable-charts/d3-wb-barchart-posneg.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ let wbBarChartPosNeg = function() {
let ySelector = 'y';
let scaleX;
let scaleY;
let yExtent;
let sortBy;
let sortDirection = 'desc';
let fillPos = 'green';
Expand Down Expand Up @@ -53,9 +52,9 @@ let wbBarChartPosNeg = function() {
});
// handle cases where there is no zero crossing
if (yExtent[0] < 0 && yExtent[1] < 0) {
yExtent[1] = 0
yExtent[1] = 0;
} else if (yExtent[0] > 0 && yExtent[1] > 0) {
yExtent[0] = 0
yExtent[0] = 0;
}
scaleY.domain(yExtent);
let zeroHeight = scaleY(yExtent[0]) - scaleY(0);
Expand Down Expand Up @@ -169,10 +168,10 @@ let wbBarChartPosNeg = function() {
};

chart.sortBy = function(value) {
if (!arguments.length) return sortBy
if (!arguments.length) return sortBy;
sortBy = value;
return chart;
}
};

chart.sortDirection = function(value) {
if (!arguments.length) return sortDirection;
Expand Down
2 changes: 1 addition & 1 deletion default-content/d3-wb-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.9.2
0.10.0
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "d3-workbench",
"version": "0.9.2",
"version": "0.10.0",
"description": "A d3.js-powered workbench for rapid visualization prototyping",
"repository": {
"type": "git",
Expand Down

0 comments on commit a77e098

Please sign in to comment.