Skip to content
This repository has been archived by the owner on Jun 18, 2024. It is now read-only.

fix spectrum color null as zero #205

Closed
wants to merge 1 commit into from

Conversation

badhop
Copy link
Contributor

@badhop badhop commented May 31, 2021

Overview

Fix 'display as zero' mode for nulls when spectrum color is used.

What this PR does / why we need it

Without this fix nulls are displayed as black in 'as zero' mode.

Снимок экрана 2021-06-03 в 10 56 17

Special notes for your reviewer

Does this PR introduce a user-facing change?


Copy link

@nabokihms nabokihms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Comment on lines +581 to +588
if(bucket.value !== null) {
return this.colorScale(bucket.value);
} else {
if(this.panel.nullPointMode == 'as zero') {
return this.colorScale(0);
}
}
} else if (this.panel.color.mode === 'discrete') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello! Thank you for your contribution!
I've run a plugin with the suggested change and it not work. Check for null is not working, because bucket.value may be "undefined". I've changed your code a bit and it works. Can you apply this suggestion?

Suggested change
if(bucket.value !== null) {
return this.colorScale(bucket.value);
} else {
if(this.panel.nullPointMode == 'as zero') {
return this.colorScale(0);
}
}
} else if (this.panel.color.mode === 'discrete') {
if (!bucket.value && this.panel.nullPointMode === 'as zero') {
// bucket.value === 0 falls here, but it is fine.
return this.colorScale(0);
}
return this.colorScale(bucket.value);
} else if (this.panel.color.mode === 'discrete') {

@diafour diafour added this to the 0.5.0 milestone Jun 4, 2021
@diafour diafour mentioned this pull request Jul 19, 2021
@diafour
Copy link
Collaborator

diafour commented Jul 19, 2021

Thank you @badhop , I've pushed your commit as a part of #209 .

@diafour diafour closed this Jul 19, 2021
@diafour diafour modified the milestones: 0.5.0, 0.4.2 Nov 19, 2021
albertoperdomo2 pushed a commit to albertoperdomo2/grafana-statusmap that referenced this pull request Dec 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants