|
|
|
@ -100,7 +100,9 @@ function drawColorLegend( |
|
|
|
|
minValue: number |
|
|
|
|
) { |
|
|
|
|
const legendElem = $(elem).find('svg'); |
|
|
|
|
const legend = d3.select(legendElem.get(0)); |
|
|
|
|
const legendDomElement = legendElem.get(0); |
|
|
|
|
if (legendDomElement) { |
|
|
|
|
const legend = d3.select(legendDomElement); |
|
|
|
|
clearLegend(elem); |
|
|
|
|
|
|
|
|
|
const legendWidth = Math.floor(legendElem.outerWidth() ?? 10) - 30; |
|
|
|
@ -128,6 +130,7 @@ function drawColorLegend( |
|
|
|
|
|
|
|
|
|
drawLegendValues(elem, rangeFrom, rangeTo, maxValue, minValue, legendWidth, valuesRange); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function drawOpacityLegend( |
|
|
|
|
elem: JQuery, |
|
|
|
@ -138,7 +141,9 @@ function drawOpacityLegend( |
|
|
|
|
minValue: number |
|
|
|
|
) { |
|
|
|
|
const legendElem = $(elem).find('svg'); |
|
|
|
|
const legend = d3.select(legendElem.get(0)); |
|
|
|
|
const legendDomElement = legendElem.get(0); |
|
|
|
|
if (legendDomElement) { |
|
|
|
|
const legend = d3.select(legendDomElement); |
|
|
|
|
clearLegend(elem); |
|
|
|
|
|
|
|
|
|
const legendWidth = Math.floor(legendElem.outerWidth() ?? 30) - 30; |
|
|
|
@ -167,6 +172,7 @@ function drawOpacityLegend( |
|
|
|
|
|
|
|
|
|
drawLegendValues(elem, rangeFrom, rangeTo, maxValue, minValue, legendWidth, valuesRange); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function drawLegendValues( |
|
|
|
|
elem: JQuery, |
|
|
|
@ -178,9 +184,11 @@ function drawLegendValues( |
|
|
|
|
valuesRange: number[] |
|
|
|
|
) { |
|
|
|
|
const legendElem = $(elem).find('svg'); |
|
|
|
|
const legend = d3.select(legendElem.get(0)); |
|
|
|
|
const legendDomElement = legendElem.get(0); |
|
|
|
|
if (legendDomElement) { |
|
|
|
|
const legend = d3.select(legendDomElement); |
|
|
|
|
|
|
|
|
|
if (legendWidth <= 0 || legendElem.get(0).childNodes.length === 0) { |
|
|
|
|
if (legendWidth <= 0 || legendDomElement.childNodes.length === 0) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -193,7 +201,7 @@ function drawLegendValues( |
|
|
|
|
const posY = getSvgElemHeight(legendElem) + LEGEND_VALUE_MARGIN; |
|
|
|
|
const posX = getSvgElemX(colorRect) + LEGEND_PADDING_LEFT; |
|
|
|
|
|
|
|
|
|
d3.select(legendElem.get(0)) |
|
|
|
|
d3.select(legendDomElement) |
|
|
|
|
.append('g') |
|
|
|
|
.attr('class', 'axis') |
|
|
|
|
.attr('transform', 'translate(' + posX + ',' + posY + ')') |
|
|
|
@ -201,6 +209,7 @@ function drawLegendValues( |
|
|
|
|
|
|
|
|
|
legend.select('.axis').select('.domain').remove(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function drawSimpleColorLegend(elem: JQuery, colorScale: any) { |
|
|
|
|
const legendElem = $(elem).find('svg'); |
|
|
|
@ -214,7 +223,9 @@ function drawSimpleColorLegend(elem: JQuery, colorScale: any) { |
|
|
|
|
const rangeStep = Math.floor(legendWidth / valuesNumber); |
|
|
|
|
const valuesRange = d3.range(0, legendWidth, rangeStep); |
|
|
|
|
|
|
|
|
|
const legend = d3.select(legendElem.get(0)); |
|
|
|
|
const legendDomElement = legendElem.get(0); |
|
|
|
|
if (legendDomElement) { |
|
|
|
|
const legend = d3.select(legendDomElement); |
|
|
|
|
const legendRects = legend.selectAll('.heatmap-color-legend-rect').data(valuesRange); |
|
|
|
|
|
|
|
|
|
legendRects |
|
|
|
@ -228,12 +239,15 @@ function drawSimpleColorLegend(elem: JQuery, colorScale: any) { |
|
|
|
|
.attr('fill', (d) => colorScale(d)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function drawSimpleOpacityLegend(elem: JQuery, options: { colorScale: string; exponent: number; cardColor: string }) { |
|
|
|
|
const legendElem = $(elem).find('svg'); |
|
|
|
|
const legendDomElement = legendElem.get(0); |
|
|
|
|
if (legendDomElement) { |
|
|
|
|
clearLegend(elem); |
|
|
|
|
|
|
|
|
|
const legend = d3.select(legendElem.get(0)); |
|
|
|
|
const legend = d3.select(legendDomElement); |
|
|
|
|
const legendWidth = Math.floor(legendElem.outerWidth() ?? 30); |
|
|
|
|
const legendHeight = legendElem.attr('height') as any; |
|
|
|
|
|
|
|
|
@ -261,6 +275,7 @@ function drawSimpleOpacityLegend(elem: JQuery, options: { colorScale: string; ex |
|
|
|
|
.style('opacity', (d) => legendOpacityScale(d)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function clearLegend(elem: JQuery) { |
|
|
|
|
const legendElem = $(elem).find('svg'); |
|
|
|
|