Skip to content

Commit

Permalink
Add option to only highlight last point in pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
andrjohns committed Oct 15, 2023
1 parent eac0b44 commit 7e022c5
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 27 deletions.
4 changes: 4 additions & 0 deletions capabilities.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@
]
}
},
"flag_series": {
"displayName": "Highlight all in Pattern",
"type" : { "bool" : true }
},
"astronomical": {
"displayName": "Astronomical Points",
"type" : { "bool" : true }
Expand Down
20 changes: 12 additions & 8 deletions src/Classes/viewModelClass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,21 +250,25 @@ export default class viewModelClass {
}
if (this.inputSettings.settings.spc.chart_type !== "run") {
if (this.inputSettings.settings.outliers.astronomical) {
this.outliers.astpoint = checkFlagDirection(astronomical(this.controlLimits.values, this.controlLimits.ll99, this.controlLimits.ul99),
{ process_flag_type, improvement_direction });
this.outliers.astpoint = checkFlagDirection(
astronomical(this.controlLimits.values, this.controlLimits.ll99, this.controlLimits.ul99),
{ process_flag_type, improvement_direction });
}
if (this.inputSettings.settings.outliers.two_in_three) {
this.outliers.two_in_three = checkFlagDirection(twoInThree(this.controlLimits.values, this.controlLimits.ll95, this.controlLimits.ul95),
{ process_flag_type, improvement_direction });
this.outliers.two_in_three = checkFlagDirection(
twoInThree(this.controlLimits.values, this.controlLimits.ll95, this.controlLimits.ul95, this.inputSettings.settings.outliers.flag_series),
{ process_flag_type, improvement_direction });
}
}
if (this.inputSettings.settings.outliers.trend) {
this.outliers.trend = checkFlagDirection(trend(this.controlLimits.values, this.inputSettings.settings.outliers.trend_n),
{ process_flag_type, improvement_direction });
this.outliers.trend = checkFlagDirection(
trend(this.controlLimits.values, this.inputSettings.settings.outliers.trend_n, this.inputSettings.settings.outliers.flag_series),
{ process_flag_type, improvement_direction });
}
if (this.inputSettings.settings.outliers.shift) {
this.outliers.shift = checkFlagDirection(shift(this.controlLimits.values, this.controlLimits.targets, this.inputSettings.settings.outliers.shift_n),
{ process_flag_type, improvement_direction });
this.outliers.shift = checkFlagDirection(
shift(this.controlLimits.values, this.controlLimits.targets, this.inputSettings.settings.outliers.shift_n, this.inputSettings.settings.outliers.flag_series),
{ process_flag_type, improvement_direction });
}
}
}
12 changes: 7 additions & 5 deletions src/Outlier Flagging/shift.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { abs, sum } from "../Functions";

export default function shift(val: number[], targets: number[], n: number): string[] {
export default function shift(val: number[], targets: number[], n: number, flag_series: boolean): string[] {
const lagged_sign: number[] = val.map((d, i) => {
return Math.sign(d - targets[i]);
});
Expand All @@ -14,10 +14,12 @@ export default function shift(val: number[], targets: number[], n: number): stri
return "none";
}
})
for (let i: number = 0; i < shift_detected.length; i++) {
if (shift_detected[i] !== "none") {
for (let j: number = (i - 1); j >= (i - (n - 1)); j--) {
shift_detected[j] = shift_detected[i];
if (flag_series) {
for (let i: number = 0; i < shift_detected.length; i++) {
if (shift_detected[i] !== "none") {
for (let j: number = (i - 1); j >= (i - (n - 1)); j--) {
shift_detected[j] = shift_detected[i];
}
}
}
}
Expand Down
12 changes: 7 additions & 5 deletions src/Outlier Flagging/trend.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { abs, sum } from "../Functions";

export default function trend(val: number[], n: number): string[] {
export default function trend(val: number[], n: number, flag_series: boolean): string[] {
const lagged_sign: number[] = val.map((d, i) => {
return (i == 0) ? i : Math.sign(d - val[i - 1]);
});
Expand All @@ -15,10 +15,12 @@ export default function trend(val: number[], n: number): string[] {
}
})

for (let i: number = 0; i < trend_detected.length; i++) {
if (trend_detected[i] !== "none") {
for (let j: number = (i - 1); j >= (i - (n - 1)); j--) {
trend_detected[j] = trend_detected[i];
if (flag_series) {
for (let i: number = 0; i < trend_detected.length; i++) {
if (trend_detected[i] !== "none") {
for (let j: number = (i - 1); j >= (i - (n - 1)); j--) {
trend_detected[j] = trend_detected[i];
}
}
}
}
Expand Down
12 changes: 7 additions & 5 deletions src/Outlier Flagging/twoInThree.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { abs, sum } from "../Functions";

export default function twoInThree(val: number[], ll95: number[], ul95: number[]): string[] {
export default function twoInThree(val: number[], ll95: number[], ul95: number[], flag_series: boolean): string[] {
const outside95: number[] = val.map((d, i) => {
return d > ul95[i] ? 1 : (d < ll95[i] ? -1 : 0);
});
Expand All @@ -15,10 +15,12 @@ export default function twoInThree(val: number[], ll95: number[], ul95: number[]
}
})

for (let i: number = 0; i < two_in_three_detected.length; i++) {
if (two_in_three_detected[i] !== "none") {
for (let j: number = (i - 1); j >= (i - 2); j--) {
two_in_three_detected[j] = two_in_three_detected[i];
if (flag_series) {
for (let i: number = 0; i < two_in_three_detected.length; i++) {
if (two_in_three_detected[i] !== "none") {
for (let j: number = (i - 1); j >= (i - 2); j--) {
two_in_three_detected[j] = two_in_three_detected[i];
}
}
}
}
Expand Down
9 changes: 5 additions & 4 deletions src/defaultSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const defaultSettings = {
outliers: {
process_flag_type: "both",
improvement_direction: "increase",
flag_series: true,
astronomical: false,
ast_colour_improvement: "#E1C233",
ast_colour_deterioration: "#E1C233",
Expand Down Expand Up @@ -117,10 +118,10 @@ const defaultSettings = {

export const settingsPaneGroupings = {
outliers: {
"Astronomical Points": ["process_flag_type", "improvement_direction", "astronomical", "ast_colour_improvement", "ast_colour_deterioration", "ast_colour_neutral_low", "ast_colour_neutral_high"],
"Shifts": ["process_flag_type", "improvement_direction", "shift", "shift_n", "shift_colour_improvement", "shift_colour_deterioration", "shift_colour_neutral_low", "shift_colour_neutral_high"],
"Trends": ["process_flag_type", "improvement_direction", "trend", "trend_n", "trend_colour_improvement", "trend_colour_deterioration", "trend_colour_neutral_low", "trend_colour_neutral_high"],
"Two-In-Three": ["process_flag_type", "improvement_direction", "two_in_three", "twointhree_colour_improvement", "twointhree_colour_deterioration", "twointhree_colour_neutral_low", "twointhree_colour_neutral_high"]
"Astronomical Points": ["process_flag_type", "improvement_direction", "flag_series", "astronomical", "ast_colour_improvement", "ast_colour_deterioration", "ast_colour_neutral_low", "ast_colour_neutral_high"],
"Shifts": ["process_flag_type", "improvement_direction", "flag_series", "shift", "shift_n", "shift_colour_improvement", "shift_colour_deterioration", "shift_colour_neutral_low", "shift_colour_neutral_high"],
"Trends": ["process_flag_type", "improvement_direction", "flag_series", "trend", "trend_n", "trend_colour_improvement", "trend_colour_deterioration", "trend_colour_neutral_low", "trend_colour_neutral_high"],
"Two-In-Three": ["process_flag_type", "improvement_direction", "flag_series", "two_in_three", "twointhree_colour_improvement", "twointhree_colour_deterioration", "twointhree_colour_neutral_low", "twointhree_colour_neutral_high"]
},
nhs_icons: {
"Variation": ["show_variation_icons", "flag_variation_last", "variation_icons_locations", "variation_icons_scaling"],
Expand Down

0 comments on commit 7e022c5

Please sign in to comment.