Commit 157333b9 authored by gposysaev's avatar gposysaev
Browse files

Add changes

parent abea50d5
......@@ -309,17 +309,46 @@ export class IndicatorGrad extends Widget implements SingleData {
i = 0;
}
}
private unique(arr: any[] = []) {
let result: any[] = [];
private max(obj: number[] = []) {
var a = obj[0];
for (let i = 0; i < obj.length; i++) {
a = obj[i];
if (!isNaN(a)) break;
}
for (var i = 1; i < obj.length; i++) {
if (
obj[i] > a &&
!isNaN(obj[i]) &&
obj[i] != null &&
obj[i] != Infinity
) {
a = obj[i];
}
}
return a;
}
private min(obj: number[] = []) {
var a = obj[0];
for (let i = 0; i < obj.length; i++) {
a = obj[i];
if (!isNaN(a)) break;
}
for (let str of arr) {
if (!result.includes(str)) {
result.push(str);
for (var i = 1; i < obj.length; i++) {
if (
obj[i] < a &&
!isNaN(obj[i]) &&
obj[i] != null &&
obj[i] != Infinity
) {
a = obj[i];
}
}
return result;
return a;
}
private getDiffParams(
planB: number[] = [],
planA: number[] = [],
......@@ -328,30 +357,49 @@ export class IndicatorGrad extends Widget implements SingleData {
): string {
let value: number[] = [];
for (let i = 0; i < planB.length; i++) {
value.push(
this.viewSettings.typeValue == EValueType.ChangeDole
? (planA[i] / planB[i]) * 100 -
(planA1[i] / planB1[i]) * 100
: this.viewSettings.typeValue == EValueType.CalculatedValue
? ((planA[i] / planB[i] - planA1[i] / planB1[i]) /
(planA1[i] / planB1[i])) *
100
: this.viewSettings.typeValue == EValueType.PlanFact
? (planA[i] / planB[i]) * 100
: this.viewSettings.typeValue == EValueType.Change
? planA[i] - planB[i]
: this.viewSettings.typeValue == EValueType.ChangeInPercents
? ((planA[i] - planB[i]) / planB[i]) * 100
: this.viewSettings.typeValue ==
EValueType.DifferenceSegment
? planA[i] / planB[i] - planA1[i] / planB1[i]
: planA[i] / planB[i],
);
if (
this.dataSettings.columnsByBlock[EBlockKey.IndicatorB1].length >
0 &&
this.dataSettings.columnsByBlock[EBlockKey.IndicatorA1].length >
0
)
value.push(
this.viewSettings.typeValue == EValueType.ChangeDole
? (planA[i] / planB[i]) * 100 -
(planA1[i] / planB1[i]) * 100
: this.viewSettings.typeValue ==
EValueType.CalculatedValue
? ((planA[i] / planB[i] - planA1[i] / planB1[i]) /
(planA1[i] / planB1[i])) *
100
: this.viewSettings.typeValue == EValueType.PlanFact
? (planA[i] / planB[i]) * 100
: this.viewSettings.typeValue == EValueType.Change
? planA[i] - planB[i]
: this.viewSettings.typeValue ==
EValueType.ChangeInPercents
? ((planA[i] - planB[i]) / planB[i]) * 100
: this.viewSettings.typeValue ==
EValueType.DifferenceSegment
? planA[i] / planB[i] - planA1[i] / planB1[i]
: planA[i] / planB[i],
);
else
value.push(
this.viewSettings.typeValue == EValueType.PlanFact
? (planA[i] / planB[i]) * 100
: this.viewSettings.typeValue == EValueType.Change
? planA[i] - planB[i]
: this.viewSettings.typeValue ==
EValueType.ChangeInPercents
? ((planA[i] - planB[i]) / planB[i]) * 100
: planA[i] / planB[i],
);
}
let minVal = Math.min(...value);
let minVal = this.min(value);
let minIterator = value.findIndex((i) => i == minVal);
let maxVal = Math.max(...value);
let maxVal = this.max(value);
let maxIterator = value.findIndex((i) => i == maxVal);
const val =
this.viewSettings[EViewOption.MinMax] == EMinMax.Max
......@@ -410,7 +458,7 @@ export class IndicatorGrad extends Widget implements SingleData {
}
}
}
this.uniqueDimension = this.unique(this.dimension);
if (
this.dataSettings.columnsByBlock[EBlockKey.IndicatorB1].length >
0 &&
......@@ -427,9 +475,9 @@ export class IndicatorGrad extends Widget implements SingleData {
)
return this.getDiffParams(this.indB, this.indA);
else {
let minVal = Math.min(...this.indA);
let minVal = this.min(this.indA);
let minIterator = this.indA.findIndex((i) => i == minVal);
let maxVal = Math.max(...this.indA);
let maxVal = this.max(this.indA);
let maxIterator = this.indA.findIndex((i) => i == maxVal);
const val =
this.viewSettings[EViewOption.MinMax] == EMinMax.Max
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment