fix: removeChild error on ie11 fixed with d3 remove

This commit is contained in:
Ivan Mikheykin
2019-02-26 15:53:18 +03:00
parent 570fe11341
commit 803504befd
3 changed files with 5 additions and 21 deletions
+2 -10
View File
@@ -19,14 +19,6 @@ System.register(['angular', 'lodash', 'jquery', 'd3', './libs/d3-scale-chromatic
var widthFactor = legendWidth / (rangeTo - rangeFrom); var widthFactor = legendWidth / (rangeTo - rangeFrom);
var valuesRange = d3.range(rangeFrom, rangeTo, rangeStep); var valuesRange = d3.range(rangeFrom, rangeTo, rangeStep);
// console.debug({
// "rangeStep": rangeStep,
// "widthFactor": widthFactor,
// "legendWidth": legendWidth,
// "steps": (rangeTo - rangeFrom)/rangeStep,
// });
// console.debug(valuesRange);
var colorScale = getColorScale(colorScheme, maxValue, minValue); var colorScale = getColorScale(colorScheme, maxValue, minValue);
legend.selectAll(".status-heatmap-color-legend-rect").data(valuesRange).enter().append("rect") legend.selectAll(".status-heatmap-color-legend-rect").data(valuesRange).enter().append("rect")
// translate from range space into pixels // translate from range space into pixels
@@ -88,13 +80,13 @@ System.register(['angular', 'lodash', 'jquery', 'd3', './libs/d3-scale-chromatic
// calculate max width of tooltip and use it as width for each item // calculate max width of tooltip and use it as width for each item
var textWidth = []; var textWidth = [];
legend.selectAll(".hidden-texts").data(tooltips).enter().append("text").attr("class", "axis tick").attr("font-family", "sans-serif").text(function (d) { legend.selectAll(".hidden-texts").data(tooltips).enter().append("text").attr("class", "axis tick hidden-texts").attr("font-family", "sans-serif").text(function (d) {
return d; return d;
}).each(function (d, i) { }).each(function (d, i) {
var thisWidth = this.getBBox().width; var thisWidth = this.getBBox().width;
textWidth.push(thisWidth); textWidth.push(thisWidth);
this.parentElement.removeChild(this); // remove them just after displaying them in IE friendly way
}); });
legend.selectAll(".hidden-texts").remove();
var legendWidth = Math.floor(_.min([graphWidth - 30, (_.max(textWidth) + 3) * valuesNumber])); var legendWidth = Math.floor(_.min([graphWidth - 30, (_.max(textWidth) + 3) * valuesNumber]));
legendElem.attr("width", legendWidth); legendElem.attr("width", legendWidth);
+1 -1
View File
File diff suppressed because one or more lines are too long
+2 -10
View File
@@ -101,14 +101,6 @@ function drawColorLegend(elem, colorScheme, rangeFrom, rangeTo, maxValue, minVal
let widthFactor = legendWidth / (rangeTo - rangeFrom); let widthFactor = legendWidth / (rangeTo - rangeFrom);
let valuesRange = d3.range(rangeFrom, rangeTo, rangeStep); let valuesRange = d3.range(rangeFrom, rangeTo, rangeStep);
// console.debug({
// "rangeStep": rangeStep,
// "widthFactor": widthFactor,
// "legendWidth": legendWidth,
// "steps": (rangeTo - rangeFrom)/rangeStep,
// });
// console.debug(valuesRange);
let colorScale = getColorScale(colorScheme, maxValue, minValue); let colorScale = getColorScale(colorScheme, maxValue, minValue);
legend.selectAll(".status-heatmap-color-legend-rect") legend.selectAll(".status-heatmap-color-legend-rect")
.data(valuesRange) .data(valuesRange)
@@ -176,14 +168,14 @@ function drawDiscreteColorLegend(elem, colorOptions, discreteHelper) {
legend.selectAll(".hidden-texts") legend.selectAll(".hidden-texts")
.data(tooltips) .data(tooltips)
.enter().append("text") .enter().append("text")
.attr("class", "axis tick") .attr("class", "axis tick hidden-texts")
.attr("font-family", "sans-serif") .attr("font-family", "sans-serif")
.text(d => d) .text(d => d)
.each(function(d,i) { .each(function(d,i) {
let thisWidth = this.getBBox().width; let thisWidth = this.getBBox().width;
textWidth.push(thisWidth); textWidth.push(thisWidth);
this.parentElement.removeChild(this); // remove them just after displaying them in IE friendly way
}); });
legend.selectAll(".hidden-texts").remove();
let legendWidth = Math.floor(_.min([ let legendWidth = Math.floor(_.min([
graphWidth - 30, graphWidth - 30,