console logs and code layout

This commit is contained in:
Peter Holmberg 2018-11-29 14:22:43 +01:00
parent b856ae3957
commit efb71d1026
2 changed files with 10 additions and 14 deletions

View File

@ -33,6 +33,7 @@ export default class Thresholds extends PureComponent<PanelOptionsProps<OptionsP
return threshold;
});
// Setting value to a value between the new threshold.
const value = newThresholds[index].value - (newThresholds[index].value - newThresholds[index - 1].value) / 2;
this.setState(
@ -57,12 +58,12 @@ export default class Thresholds extends PureComponent<PanelOptionsProps<OptionsP
onChangeThresholdValue = (event, threshold) => {
const { thresholds } = this.state;
const newThresholds = thresholds.map(currentThreshold => {
if (currentThreshold === threshold) {
currentThreshold = { ...currentThreshold, value: event.target.value };
const newThresholds = thresholds.map(t => {
if (t === threshold) {
t = { ...t, value: event.target.value };
}
return currentThreshold;
return t;
});
this.setState({
@ -73,12 +74,12 @@ export default class Thresholds extends PureComponent<PanelOptionsProps<OptionsP
onChangeThresholdColor = (threshold, color) => {
const { thresholds } = this.state;
const newThresholds = thresholds.map(currentThreshold => {
if (currentThreshold === threshold) {
currentThreshold = { ...currentThreshold, color: color };
const newThresholds = thresholds.map(t => {
if (t === threshold) {
t = { ...t, color: color };
}
return currentThreshold;
return t;
});
this.setState(
@ -112,11 +113,9 @@ export default class Thresholds extends PureComponent<PanelOptionsProps<OptionsP
if (index === 0) {
return thresholds[0].color;
} else if (index < thresholds.length) {
return thresholds[index].color;
}
return 'rgb(212, 74, 58)';
return index < thresholds.length ? thresholds[index].color : 'rgb(212, 74, 58)';
}
renderNoThresholds() {

View File

@ -41,7 +41,6 @@ export class Gauge extends PureComponent<Props> {
}
componentDidUpdate(prevProps: Props) {
console.log('did update');
this.draw();
}
@ -82,8 +81,6 @@ export class Gauge extends PureComponent<Props> {
};
});
console.log(formattedThresholds);
const options = {
series: {
gauges: {