diff --git a/public/app/plugins/panel/heatmap/color_legend.ts b/public/app/plugins/panel/heatmap/color_legend.ts index 25a81a7c166..cae1e5fac7f 100644 --- a/public/app/plugins/panel/heatmap/color_legend.ts +++ b/public/app/plugins/panel/heatmap/color_legend.ts @@ -8,13 +8,18 @@ import { getColorScale, getOpacityScale } from './color_scale'; let module = angular.module('grafana.directives'); +const LEGEND_HEIGHT_PX = 6; +const LEGEND_WIDTH_PX = 100; +const LEGEND_TICK_SIZE = 0; +const LEGEND_VALUE_MARGIN = 0; + /** * Color legend for heatmap editor. */ module.directive('colorLegend', function() { return { restrict: 'E', - template: '
', + template: '
', link: function(scope, elem, attrs) { let ctrl = scope.ctrl; let panel = scope.ctrl.panel; @@ -50,7 +55,7 @@ module.directive('colorLegend', function() { module.directive('heatmapLegend', function() { return { restrict: 'E', - template: '
', + template: `
`, link: function(scope, elem, attrs) { let ctrl = scope.ctrl; let panel = scope.ctrl.panel; @@ -163,10 +168,10 @@ function drawLegendValues(elem, colorScale, rangeFrom, rangeTo, maxValue, minVal let xAxis = d3 .axisBottom(legendValueScale) .tickValues(ticks) - .tickSize(2); + .tickSize(LEGEND_TICK_SIZE); let colorRect = legendElem.find(':first-child'); - let posY = getSvgElemHeight(legendElem) + 2; + let posY = getSvgElemHeight(legendElem) + LEGEND_VALUE_MARGIN; let posX = getSvgElemX(colorRect); d3 diff --git a/public/app/plugins/panel/heatmap/rendering.ts b/public/app/plugins/panel/heatmap/rendering.ts index 77a32732dfd..90dac42dc8d 100644 --- a/public/app/plugins/panel/heatmap/rendering.ts +++ b/public/app/plugins/panel/heatmap/rendering.ts @@ -66,8 +66,7 @@ export default function link(scope, elem, attrs, ctrl) { height = parseInt(height.replace('px', ''), 10); } - height -= 5; // padding - height -= panel.title ? 24 : 9; // subtract panel title bar + height -= panel.legend.show ? 28 : 11; // bottom padding and space for legend $heatmap.css('height', height + 'px'); diff --git a/public/app/plugins/panel/heatmap/specs/renderer_specs.ts b/public/app/plugins/panel/heatmap/specs/renderer_specs.ts index 6c1a94c96eb..88e4953936b 100644 --- a/public/app/plugins/panel/heatmap/specs/renderer_specs.ts +++ b/public/app/plugins/panel/heatmap/specs/renderer_specs.ts @@ -51,6 +51,9 @@ describe('grafanaHeatmap', function() { colorScheme: 'interpolateOranges', fillBackground: false, }, + legend: { + show: false, + }, xBucketSize: 1000, xBucketNumber: null, yBucketSize: 1, diff --git a/public/sass/components/_panel_heatmap.scss b/public/sass/components/_panel_heatmap.scss index c0bdee7ec90..279b9392caa 100644 --- a/public/sass/components/_panel_heatmap.scss +++ b/public/sass/components/_panel_heatmap.scss @@ -1,3 +1,5 @@ +$font-size-heatmap-tick: 11px; + .heatmap-canvas-wrapper { // position: relative; cursor: crosshair; @@ -10,7 +12,7 @@ text { fill: $text-color; color: $text-color; - font-size: $font-size-sm; + font-size: $font-size-heatmap-tick; } line { @@ -56,12 +58,12 @@ .heatmap-legend-wrapper { @include clearfix(); margin: 0 $spacer; - padding-top: 10px; + padding-top: 4px; svg { width: 100%; max-width: 300px; - height: 33px; + height: 18px; float: left; white-space: nowrap; padding-left: 10px; @@ -75,7 +77,7 @@ text { fill: $text-color; color: $text-color; - font-size: $font-size-sm; + font-size: $font-size-heatmap-tick; } line {