Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No innerHTML and pseudo-html cleanup #1792

Merged
merged 37 commits into from
Jun 19, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
3ad11f6
standardize on attr over style for text-anchor
alexcjohnson Jun 15, 2017
9949092
centralize data-unformatted and use it for bBox cache key
alexcjohnson Jun 15, 2017
951a75e
let Drawing.bBox handle tspan.line position reset
alexcjohnson Jun 15, 2017
639878e
fix pseudo-html rendering in rangeselectors and updatemenus
alexcjohnson Jun 15, 2017
16d7515
call bBox on text node when possible
alexcjohnson Jun 15, 2017
0b2a7b2
clean up legend sizing and fallback on missing node
alexcjohnson Jun 15, 2017
a5a578f
minor lint to bar text
alexcjohnson Jun 15, 2017
5d3648c
cleaner data-math usage
alexcjohnson Jun 15, 2017
d29159a
fix sliders with pseudo-HTML line breaks
alexcjohnson Jun 15, 2017
6eedaa5
make `positionText` and `lineCount` fns
alexcjohnson Jun 16, 2017
76fc8b8
linting related to tspan.line centralization
alexcjohnson Jun 16, 2017
61dd3b1
use display:none instead of visibility:hidden
alexcjohnson Jun 16, 2017
936936b
remove Drawing.measureText and support pseudo-HTML in carpets
alexcjohnson Jun 16, 2017
4ae49f5
prohibit Math.sign and .innerHTML in syntax test
alexcjohnson Jun 16, 2017
9f4ec66
remove Math.sign
alexcjohnson Jun 16, 2017
1a5679e
fix title alignment
alexcjohnson Jun 16, 2017
af5b7f2
update snapshot test
alexcjohnson Jun 16, 2017
4886985
oops, we need y=0 on tspan.line after all
alexcjohnson Jun 16, 2017
717c7d8
hover labels need explicit position reset for proper positioning later
alexcjohnson Jun 16, 2017
7c3dc3b
get correct bbox for carpet tick labels
alexcjohnson Jun 16, 2017
378c805
fixed range selector mocks
alexcjohnson Jun 16, 2017
f8101b0
update binding mock - new label positions are slightly different
alexcjohnson Jun 16, 2017
3b293ac
update updatemenus test
alexcjohnson Jun 16, 2017
c908ed4
lint axes.js
alexcjohnson Jun 16, 2017
0bb38e9
reorder sliders findDimensions so dummy calculations always succeed
alexcjohnson Jun 16, 2017
6c72c77
test #984 - ensure we never override visibility
alexcjohnson Jun 16, 2017
30b9fa5
remove some obsolete code and comments from sliders/draw
alexcjohnson Jun 16, 2017
930e58e
updatemenus point in the direction they'll open
alexcjohnson Jun 16, 2017
301fba7
update updatemenus_positioning mock for new arrows
alexcjohnson Jun 16, 2017
4b87b2e
fix #1782 (second half: arrowheads broken) - :hocho: parentElement
alexcjohnson Jun 16, 2017
a68f861
note about innerHTML prohibition
alexcjohnson Jun 16, 2017
c5fa44b
pull 1.3 out into alignment constants
alexcjohnson Jun 16, 2017
82ba7ee
null transform, rather than empty string
alexcjohnson Jun 16, 2017
27b4be3
selectAll -> select because it can only be one node
alexcjohnson Jun 16, 2017
46d6e44
lint titles var statements
alexcjohnson Jun 17, 2017
8305c02
let drawing.bBox cache simple nested elements
alexcjohnson Jun 17, 2017
8e3d4fa
don't recalculate nodehash for recursive bBox
alexcjohnson Jun 17, 2017
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: 4 additions & 4 deletions src/components/rangeselector/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,10 @@ function reposition(gd, buttons, opts, axName) {
buttons.each(function() {
var button = d3.select(this),
text = button.select('.selector-text'),
tspans = text.selectAll('tspan');
tspans = text.selectAll('tspan.line');

var tHeight = opts.font.size * 1.3,
tLines = tspans[0].length || 1,
tLines = tspans.size() || 1,
hEff = Math.max(tHeight * tLines, 16) + 3;

opts.height = Math.max(opts.height, hEff);
Expand All @@ -197,11 +197,11 @@ function reposition(gd, buttons, opts, axName) {
var button = d3.select(this),
rect = button.select('.selector-rect'),
text = button.select('.selector-text'),
tspans = text.selectAll('tspan');
tspans = text.selectAll('tspan.line');

var tWidth = text.node() && Drawing.bBox(text.node()).width,
tHeight = opts.font.size * 1.3,
tLines = tspans[0].length || 1;
tLines = tspans.size() || 1;

var wEff = Math.max(tWidth + 10, constants.minButtonWidth);

Expand Down
20 changes: 12 additions & 8 deletions src/components/updatemenus/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,10 @@ function drawItemText(item, menuOpts, itemOpts, gd) {
text.enter().append('text')
.classed(constants.itemTextClassName, true)
.classed('user-select-none', true)
.attr('text-anchor', 'start');
.attr({
'text-anchor': 'start',
'data-notex': 1
});

text.call(Drawing.font, menuOpts.font)
.text(itemOpts.label)
Expand Down Expand Up @@ -521,15 +524,15 @@ function findDimensions(gd, menuOpts) {
button.call(drawItem, menuOpts, buttonOpts, gd);

var text = button.select('.' + constants.itemTextClassName),
tspans = text.selectAll('tspan');
tspans = text.selectAll('tspan.line');

// width is given by max width of all buttons
var tWidth = text.node() && Drawing.bBox(text.node()).width,
wEff = Math.max(tWidth + constants.textPadX, constants.minWidth);

// height is determined by item text
var tHeight = menuOpts.font.size * constants.fontSizeToHeight,
tLines = tspans[0].length || 1,
tLines = tspans.size() || 1,
Copy link
Contributor

Choose a reason for hiding this comment

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

Oops. My bad for putting these in.

hEff = Math.max(tHeight * tLines, constants.minHeight) + constants.textOffsetY;

hEff = Math.ceil(hEff);
Expand Down Expand Up @@ -626,28 +629,29 @@ function setItemPosition(item, menuOpts, posOpts, overrideOpts) {
overrideOpts = overrideOpts || {};
var rect = item.select('.' + constants.itemRectClassName),
text = item.select('.' + constants.itemTextClassName),
tspans = text.selectAll('tspan'),
tspans = text.selectAll('tspan.line'),
borderWidth = menuOpts.borderwidth,
index = posOpts.index;

Drawing.setTranslate(item, borderWidth + posOpts.x, borderWidth + posOpts.y);

var isVertical = ['up', 'down'].indexOf(menuOpts.direction) !== -1;
var finalHeight = overrideOpts.height || (isVertical ? menuOpts.heights[index] : menuOpts.height1);

rect.attr({
x: 0,
y: 0,
width: overrideOpts.width || (isVertical ? menuOpts.width1 : menuOpts.widths[index]),
height: overrideOpts.height || (isVertical ? menuOpts.heights[index] : menuOpts.height1)
height: finalHeight
});

var tHeight = menuOpts.font.size * constants.fontSizeToHeight,
tLines = tspans[0].length || 1,
spanOffset = ((tLines - 1) * tHeight / 4);
tLines = tspans.size() || 1,
spanOffset = ((tLines - 1) * tHeight / 2);

var textAttrs = {
x: constants.textOffsetX,
y: menuOpts.heights[index] / 2 - spanOffset + constants.textOffsetY
y: finalHeight / 2 - spanOffset + constants.textOffsetY
};

text.attr(textAttrs);
Expand Down
Binary file modified test/image/baselines/range_selector_style.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/updatemenus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion test/image/mocks/range_selector_style.json
Original file line number Diff line number Diff line change
Expand Up @@ -1060,7 +1060,7 @@
"step": "year",
"stepmode": "todate",
"count": 1,
"label": "year<br>to<br>date"
"label": "<i>year<br>to<br>date</i>"
},
{
"step": "all",
Expand Down
6 changes: 3 additions & 3 deletions test/image/mocks/updatemenus.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,23 +91,23 @@
"line.color",
"red"
],
"label": "red"
"label": "<span style='color:red'>red</span><br>color"
},
{
"method": "restyle",
"args": [
"line.color",
"blue"
],
"label": "blue"
"label": "<span style='color:blue'>blue</span><br>color"
},
{
"method": "restyle",
"args": [
"line.color",
"green"
],
"label": "green"
"label": "<span style='color:green'>green</span><br>trace<br>color"
}
],
"active": 1
Expand Down