mirror of
https://github.com/timberjoegithub/grafana-statusmap.git
synced 2026-07-21 23:42:03 +00:00
Last fixes for 0.0.1
- fix prometheus request error - remove console.log - bring back drawSimpleColorLegend
This commit is contained in:
@@ -287,6 +287,31 @@ function drawDiscreteLegendValues(elem, colorOptions, legendWidth) {
|
|||||||
legend.select(".axis").select(".domain").remove();
|
legend.select(".axis").select(".domain").remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function drawSimpleColorLegend(elem, colorScale) {
|
||||||
|
let legendElem = $(elem).find('svg');
|
||||||
|
clearLegend(elem);
|
||||||
|
|
||||||
|
let legendWidth = Math.floor(legendElem.outerWidth());
|
||||||
|
let legendHeight = legendElem.attr("height");
|
||||||
|
|
||||||
|
if (legendWidth) {
|
||||||
|
let valuesNumber = Math.floor(legendWidth / 2);
|
||||||
|
let rangeStep = Math.floor(legendWidth / valuesNumber);
|
||||||
|
let valuesRange = d3.range(0, legendWidth, rangeStep);
|
||||||
|
|
||||||
|
let legend = d3.select(legendElem.get(0));
|
||||||
|
var legendRects = legend.selectAll(".status-heatmap-color-legend-rect").data(valuesRange);
|
||||||
|
|
||||||
|
legendRects.enter().append("rect")
|
||||||
|
.attr("x", d => d)
|
||||||
|
.attr("y", 0)
|
||||||
|
.attr("width", rangeStep + 1) // Overlap rectangles to prevent gaps
|
||||||
|
.attr("height", legendHeight)
|
||||||
|
.attr("stroke-width", 0)
|
||||||
|
.attr("fill", d => colorScale(d));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function drawSimpleOpacityLegend(elem, options) {
|
function drawSimpleOpacityLegend(elem, options) {
|
||||||
let legendElem = $(elem).find('svg');
|
let legendElem = $(elem).find('svg');
|
||||||
let graphElem = $(elem);
|
let graphElem = $(elem);
|
||||||
|
|||||||
@@ -72,6 +72,9 @@ export class ColorModeDiscrete {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateCardsValuesHasColorInfo() {
|
updateCardsValuesHasColorInfo() {
|
||||||
|
if (!this.panelCtrl.cardsData) {
|
||||||
|
return
|
||||||
|
}
|
||||||
this.panelCtrl.cardsData.noColorDefined = false;
|
this.panelCtrl.cardsData.noColorDefined = false;
|
||||||
let cards = this.panelCtrl.cardsData.cards;
|
let cards = this.panelCtrl.cardsData.cards;
|
||||||
for (let i=0; i<cards.length; i++) {
|
for (let i=0; i<cards.length; i++) {
|
||||||
|
|||||||
+1
-1
@@ -596,7 +596,7 @@ export default function link(scope, elem, attrs, ctrl) {
|
|||||||
timeRange = ctrl.range;
|
timeRange = ctrl.range;
|
||||||
cardsData = ctrl.cardsData;
|
cardsData = ctrl.cardsData;
|
||||||
|
|
||||||
if (!setElementHeight() || !data) {
|
if (!data || !cardsData || !setElementHeight()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -153,12 +153,6 @@ export class StatusHeatmapCtrl extends MetricsPanelCtrl {
|
|||||||
let minSpacing = this.panel.cards.cardSpacing;
|
let minSpacing = this.panel.cards.cardSpacing;
|
||||||
let maxCardsCount = Math.ceil((chartWidth-minCardWidth) / (minCardWidth + minSpacing));
|
let maxCardsCount = Math.ceil((chartWidth-minCardWidth) / (minCardWidth + minSpacing));
|
||||||
|
|
||||||
console.log("CALC INT", {
|
|
||||||
"chartWidth": chartWidth,
|
|
||||||
"panelWidth": panelWidth,
|
|
||||||
"maxCardsCount": maxCardsCount,
|
|
||||||
});
|
|
||||||
|
|
||||||
let intervalMs;
|
let intervalMs;
|
||||||
let rangeMs = this.range.to.valueOf() - this.range.from.valueOf();
|
let rangeMs = this.range.to.valueOf() - this.range.from.valueOf();
|
||||||
|
|
||||||
@@ -208,7 +202,7 @@ export class StatusHeatmapCtrl extends MetricsPanelCtrl {
|
|||||||
|
|
||||||
this.multipleValues = false;
|
this.multipleValues = false;
|
||||||
if (!this.panel.useMax) {
|
if (!this.panel.useMax) {
|
||||||
if (!_.isEmpty(this.cardsData)) {
|
if (this.cardsData) {
|
||||||
this.multipleValues = this.cardsData.multipleValues;
|
this.multipleValues = this.cardsData.multipleValues;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -216,7 +210,9 @@ export class StatusHeatmapCtrl extends MetricsPanelCtrl {
|
|||||||
this.noColorDefined = false;
|
this.noColorDefined = false;
|
||||||
if (this.panel.color.mode === 'discrete') {
|
if (this.panel.color.mode === 'discrete') {
|
||||||
this.discreteHelper.updateCardsValuesHasColorInfo();
|
this.discreteHelper.updateCardsValuesHasColorInfo();
|
||||||
this.noColorDefined = this.cardsData.noColorDefined;
|
if (this.cardsData) {
|
||||||
|
this.noColorDefined = this.cardsData.noColorDefined;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user