mirror of
https://github.com/timberjoegithub/grafana-statusmap.git
synced 2026-07-22 07:49:47 +00:00
fix null not mapped error
This commit is contained in:
@@ -65,6 +65,20 @@ export class ColorModeDiscrete {
|
||||
}
|
||||
|
||||
getMatchedThreshold(value) {
|
||||
if (value == null) {
|
||||
if (this.panel.color.nullPointMode == 'as empty') {
|
||||
// FIXME: make this explicit for user
|
||||
// Right now this color never used because null as empty handles in getCardOpacity method.
|
||||
return {
|
||||
"color": "rgba(0,0,0,0)",
|
||||
"value": "null",
|
||||
"tooltip": "null",
|
||||
}
|
||||
} else {
|
||||
value = 0;
|
||||
}
|
||||
}
|
||||
|
||||
let thresholds = this.panel.color.thresholds;
|
||||
for (let k = 0; k < thresholds.length; k++) {
|
||||
if (value == thresholds[k].value) {
|
||||
|
||||
@@ -333,36 +333,6 @@ export default function link(scope, elem, attrs, ctrl) {
|
||||
return d3.scaleSequential(colorInterpolator).domain([start, end]);
|
||||
}
|
||||
|
||||
// scale input range to discrete colors to draw a legend
|
||||
function getDiscreteColorScale() {
|
||||
let thresholds = panel.color.thresholds;
|
||||
|
||||
let thresholdValues = [];
|
||||
let thresholdColors = [];
|
||||
for (let i = 0; i < thresholds.length; i++) {
|
||||
thresholdColors.push(thresholds[i].color);
|
||||
thresholdValues.push(thresholds[i].value);
|
||||
}
|
||||
|
||||
// TODO sort colors by value and index?
|
||||
|
||||
let thresholdScaler = (d) => {
|
||||
for (let i = 0; i < thresholdValues.length; i++ ) {
|
||||
if (d == thresholdValues[i]) {
|
||||
return thresholdColors[i];
|
||||
}
|
||||
}
|
||||
// Error if value not in thresholds
|
||||
return 'rgba(0,0,0,1)';
|
||||
};
|
||||
|
||||
// scale min-max to 0 - max-thrs-value
|
||||
return function(d) {
|
||||
return thresholdScaler(d);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function setOpacityScale(maxValue) {
|
||||
if (panel.color.colorScale === 'linear') {
|
||||
opacityScale = d3.scaleLinear()
|
||||
|
||||
Reference in New Issue
Block a user