Fix heatmap Y axis rendering (#9580)

* heatmap: fix Y axis rendering, #9576

* heatmap: fix color legend rendering
This commit is contained in:
Alexander Zobnin 2017-10-18 16:19:20 +03:00 committed by Torkel Ödegaard
parent c2c5f529f3
commit 92c67e8c83
2 changed files with 13 additions and 5 deletions

View File

@ -152,7 +152,7 @@ function drawLegendValues(elem, colorScale, rangeFrom, rangeTo, maxValue, minVal
.tickSize(2); .tickSize(2);
let colorRect = legendElem.find(":first-child"); let colorRect = legendElem.find(":first-child");
let posY = colorRect.height() + 2; let posY = getSvgElemHeight(legendElem) + 2;
let posX = getSvgElemX(colorRect); let posX = getSvgElemX(colorRect);
d3.select(legendElem.get(0)).append("g") d3.select(legendElem.get(0)).append("g")
@ -256,7 +256,16 @@ function getOpacityScale(options, maxValue, minValue = 0) {
function getSvgElemX(elem) { function getSvgElemX(elem) {
let svgElem = elem.get(0); let svgElem = elem.get(0);
if (svgElem && svgElem.x && svgElem.x.baseVal) { if (svgElem && svgElem.x && svgElem.x.baseVal) {
return elem.get(0).x.baseVal.value; return svgElem.x.baseVal.value;
} else {
return 0;
}
}
function getSvgElemHeight(elem) {
let svgElem = elem.get(0);
if (svgElem && svgElem.height && svgElem.height.baseVal) {
return svgElem.height.baseVal.value;
} else { } else {
return 0; return 0;
} }

View File

@ -71,9 +71,8 @@ export default function link(scope, elem, attrs, ctrl) {
function getYAxisWidth(elem) { function getYAxisWidth(elem) {
let axis_text = elem.selectAll(".axis-y text").nodes(); let axis_text = elem.selectAll(".axis-y text").nodes();
let max_text_width = _.max(_.map(axis_text, text => { let max_text_width = _.max(_.map(axis_text, text => {
let el = $(text); // Use SVG getBBox method
// Use JQuery outerWidth() to compute full element width return text.getBBox().width;
return el.outerWidth();
})); }));
return max_text_width; return max_text_width;