mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
heatmap: minor legend fixes
This commit is contained in:
@@ -52,7 +52,8 @@ module.directive('heatmapLegend', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function render() {
|
function render() {
|
||||||
if (!_.isEmpty(ctrl.data)) {
|
clearLegend(elem);
|
||||||
|
if (!_.isEmpty(ctrl.data) && !_.isEmpty(ctrl.data.cards)) {
|
||||||
let legendElem = $(elem).find('svg');
|
let legendElem = $(elem).find('svg');
|
||||||
let legendWidth = Math.floor(legendElem.outerWidth());
|
let legendWidth = Math.floor(legendElem.outerWidth());
|
||||||
|
|
||||||
@@ -131,6 +132,10 @@ function drawOpacityLegend(elem, options, rangeFrom, rangeTo, maxValue, minValue
|
|||||||
}
|
}
|
||||||
|
|
||||||
function drawLegendValues(elem, colorScale, rangeFrom, rangeTo, maxValue, minValue, legendWidth) {
|
function drawLegendValues(elem, colorScale, rangeFrom, rangeTo, maxValue, minValue, legendWidth) {
|
||||||
|
if (legendWidth <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let legendElem = $(elem).find('svg');
|
let legendElem = $(elem).find('svg');
|
||||||
let legend = d3.select(legendElem.get(0));
|
let legend = d3.select(legendElem.get(0));
|
||||||
|
|
||||||
@@ -142,11 +147,11 @@ function drawLegendValues(elem, colorScale, rangeFrom, rangeTo, maxValue, minVal
|
|||||||
let ticks = buildLegendTicks(0, rangeTo, maxValue, minValue);
|
let ticks = buildLegendTicks(0, rangeTo, maxValue, minValue);
|
||||||
let xAxis = d3.axisBottom(legendValueScale)
|
let xAxis = d3.axisBottom(legendValueScale)
|
||||||
.tickValues(ticks)
|
.tickValues(ticks)
|
||||||
.tickSize(3);
|
.tickSize(2);
|
||||||
|
|
||||||
let legendElemHeight = legendElem.height();
|
let colorRect = legendElem.find(":first-child");
|
||||||
let posY = legendElemHeight - 23;
|
let posY = colorRect.height() + 2;
|
||||||
let posX = getSvgElemX(legendElem.find(":first-child"));
|
let posX = getSvgElemX(colorRect);
|
||||||
d3.select(legendElem.get(0)).append("g")
|
d3.select(legendElem.get(0)).append("g")
|
||||||
.attr("class", "axis")
|
.attr("class", "axis")
|
||||||
.attr("transform", "translate(" + posX + "," + posY + ")")
|
.attr("transform", "translate(" + posX + "," + posY + ")")
|
||||||
@@ -257,7 +262,7 @@ function getSvgElemX(elem) {
|
|||||||
function buildLegendTicks(rangeFrom, rangeTo, maxValue, minValue) {
|
function buildLegendTicks(rangeFrom, rangeTo, maxValue, minValue) {
|
||||||
let range = rangeTo - rangeFrom;
|
let range = rangeTo - rangeFrom;
|
||||||
let tickStepSize = tickStep(rangeFrom, rangeTo, 3);
|
let tickStepSize = tickStep(rangeFrom, rangeTo, 3);
|
||||||
let ticksNum = Math.floor(range / tickStepSize);
|
let ticksNum = Math.round(range / tickStepSize);
|
||||||
let ticks = [];
|
let ticks = [];
|
||||||
|
|
||||||
for (let i = 0; i < ticksNum; i++) {
|
for (let i = 0; i < ticksNum; i++) {
|
||||||
|
|||||||
@@ -62,7 +62,7 @@
|
|||||||
svg {
|
svg {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-width: 300px;
|
max-width: 300px;
|
||||||
height: 38px;
|
height: 33px;
|
||||||
float: left;
|
float: left;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
padding-left: 10px;
|
padding-left: 10px;
|
||||||
|
|||||||
Reference in New Issue
Block a user