Last fixes for 0.0.1

- fix prometheus request error
- remove console.log
- bring back drawSimpleColorLegend
This commit is contained in:
Ivan Mikheykin
2018-09-18 13:31:52 +03:00
parent 2614ebccd7
commit 3e12ede595
4 changed files with 33 additions and 9 deletions
+25
View File
@@ -287,6 +287,31 @@ function drawDiscreteLegendValues(elem, colorOptions, legendWidth) {
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) {
let legendElem = $(elem).find('svg');
let graphElem = $(elem);
+3
View File
@@ -72,6 +72,9 @@ export class ColorModeDiscrete {
}
updateCardsValuesHasColorInfo() {
if (!this.panelCtrl.cardsData) {
return
}
this.panelCtrl.cardsData.noColorDefined = false;
let cards = this.panelCtrl.cardsData.cards;
for (let i=0; i<cards.length; i++) {
+1 -1
View File
@@ -596,7 +596,7 @@ export default function link(scope, elem, attrs, ctrl) {
timeRange = ctrl.range;
cardsData = ctrl.cardsData;
if (!setElementHeight() || !data) {
if (!data || !cardsData || !setElementHeight()) {
return;
}
+3 -7
View File
@@ -153,12 +153,6 @@ export class StatusHeatmapCtrl extends MetricsPanelCtrl {
let minSpacing = this.panel.cards.cardSpacing;
let maxCardsCount = Math.ceil((chartWidth-minCardWidth) / (minCardWidth + minSpacing));
console.log("CALC INT", {
"chartWidth": chartWidth,
"panelWidth": panelWidth,
"maxCardsCount": maxCardsCount,
});
let intervalMs;
let rangeMs = this.range.to.valueOf() - this.range.from.valueOf();
@@ -208,7 +202,7 @@ export class StatusHeatmapCtrl extends MetricsPanelCtrl {
this.multipleValues = false;
if (!this.panel.useMax) {
if (!_.isEmpty(this.cardsData)) {
if (this.cardsData) {
this.multipleValues = this.cardsData.multipleValues;
}
}
@@ -216,8 +210,10 @@ export class StatusHeatmapCtrl extends MetricsPanelCtrl {
this.noColorDefined = false;
if (this.panel.color.mode === 'discrete') {
this.discreteHelper.updateCardsValuesHasColorInfo();
if (this.cardsData) {
this.noColorDefined = this.cardsData.noColorDefined;
}
}
};
onCardColorChange = (newColor) => {