qesuite 1.0.45 → 1.0.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +81 -75
- package/dist/index.mjs +81 -75
- package/index.ts +86 -77
- package/package.json +1 -1
- package/versions/1_0_46.md +1 -0
- package/versions/1_0_47.md +1 -0
package/dist/index.js
CHANGED
|
@@ -3217,110 +3217,112 @@ function MarkOutOfControl(data, UCL, LCL, CL, std, display = new CanvasDrawSetti
|
|
|
3217
3217
|
if (std === void 0) {
|
|
3218
3218
|
std = (CL - LCL) / 3;
|
|
3219
3219
|
}
|
|
3220
|
-
let Test2 = 0;
|
|
3221
|
-
let Test3 = 0;
|
|
3220
|
+
let Test2 = [0, 0, 0];
|
|
3221
|
+
let Test3 = [0, 0, 0, 0, 0, 0];
|
|
3222
3222
|
let Test4 = 0;
|
|
3223
|
-
let Test5 =
|
|
3224
|
-
let Test6 =
|
|
3223
|
+
let Test5 = 0;
|
|
3224
|
+
let Test6 = 0;
|
|
3225
3225
|
let Test7 = 0;
|
|
3226
3226
|
let Test8 = 0;
|
|
3227
3227
|
data.values.forEach((v, i) => {
|
|
3228
3228
|
if (controlTests.includes(1) && (v.y > UCL || v.y < LCL)) {
|
|
3229
3229
|
v.display = display;
|
|
3230
3230
|
}
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
Test2 = 0;
|
|
3238
|
-
}
|
|
3239
|
-
if (i !== 0) {
|
|
3240
|
-
if (controlTests.includes(3) && (v.y > data.values[i - 1].y && Test3 >= 0 || v.y < data.values[i - 1].y && Test3 <= 0)) {
|
|
3241
|
-
Test3 += v.y < data.values[i - 1].y ? -1 : 1;
|
|
3242
|
-
if (Test3 >= 5 || Test3 <= -6) {
|
|
3243
|
-
v.display = new CanvasDrawSettings("yellow", "red", 1, 1);
|
|
3244
|
-
;
|
|
3245
|
-
}
|
|
3246
|
-
} else {
|
|
3247
|
-
Test3 = 0;
|
|
3248
|
-
}
|
|
3249
|
-
if (controlTests.includes(4) && v.y < data.values[i - 1].y) {
|
|
3250
|
-
if (Test4 >= 0) {
|
|
3251
|
-
Test4 = -1 * (Test4 + 1);
|
|
3252
|
-
} else {
|
|
3253
|
-
Test4 = 0;
|
|
3254
|
-
}
|
|
3255
|
-
if (Math.abs(Test4) >= 13) {
|
|
3256
|
-
v.display = new CanvasDrawSettings("purple", "red", 1, 1);
|
|
3257
|
-
;
|
|
3258
|
-
}
|
|
3259
|
-
}
|
|
3260
|
-
if (controlTests.includes(4) && v.y > data.values[i - 1].y) {
|
|
3261
|
-
if (Test4 <= 0) {
|
|
3262
|
-
Test4 = -1 * (Test4 - 1);
|
|
3263
|
-
} else {
|
|
3264
|
-
Test4 = 0;
|
|
3265
|
-
}
|
|
3266
|
-
if (Math.abs(Test4) >= 13) {
|
|
3267
|
-
v.display = new CanvasDrawSettings("purple", "red", 1, 1);
|
|
3268
|
-
;
|
|
3269
|
-
}
|
|
3231
|
+
Test2[0] = Test2[1];
|
|
3232
|
+
Test2[1] = Test2[2];
|
|
3233
|
+
if (controlTests.includes(2) && v.y > 2 * std + CL) {
|
|
3234
|
+
Test2[2] = 1;
|
|
3235
|
+
if (Test2[0] === 1 || Test2[1] === 1) {
|
|
3236
|
+
v.display = new CanvasDrawSettings("white", "red", 1, 1);
|
|
3270
3237
|
}
|
|
3271
3238
|
}
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
Test5[2] = 1;
|
|
3276
|
-
if (Test5[0] === 1 || Test5[1] === 1) {
|
|
3239
|
+
if (controlTests.includes(2) && v.y < CL - 2 * std) {
|
|
3240
|
+
Test2[2] = -1;
|
|
3241
|
+
if (Test2[0] === -1 || Test2[1] === -1) {
|
|
3277
3242
|
v.display = new CanvasDrawSettings("white", "red", 1, 1);
|
|
3278
|
-
;
|
|
3279
3243
|
}
|
|
3280
3244
|
}
|
|
3281
|
-
if (
|
|
3282
|
-
|
|
3283
|
-
if (Test5[0] === -1 || Test5[1] === -1) {
|
|
3284
|
-
v.display = display;
|
|
3285
|
-
}
|
|
3245
|
+
if (v.y > CL - 2 * std && v.y < 2 * std + CL) {
|
|
3246
|
+
Test2[2] = 0;
|
|
3286
3247
|
}
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
if (controlTests.includes(
|
|
3293
|
-
|
|
3294
|
-
let plus =
|
|
3248
|
+
Test3[0] = Test3[1];
|
|
3249
|
+
Test3[1] = Test3[2];
|
|
3250
|
+
Test3[2] = Test3[3];
|
|
3251
|
+
Test3[3] = Test3[4];
|
|
3252
|
+
Test3[4] = Test3[5];
|
|
3253
|
+
if (controlTests.includes(3) && v.y > std + CL) {
|
|
3254
|
+
Test3[5] = 1;
|
|
3255
|
+
let plus = Test3.filter((t) => t === 1);
|
|
3295
3256
|
if (plus.length >= 4) {
|
|
3296
3257
|
v.display = new CanvasDrawSettings("grey", "red", 1, 1);
|
|
3297
3258
|
}
|
|
3298
|
-
} else if (controlTests.includes(
|
|
3299
|
-
|
|
3300
|
-
let plus =
|
|
3259
|
+
} else if (controlTests.includes(3) && v.y < CL - std) {
|
|
3260
|
+
Test3[5] = -1;
|
|
3261
|
+
let plus = Test3.filter((t) => t === -1);
|
|
3301
3262
|
if (plus.length >= 4) {
|
|
3302
3263
|
v.display = display;
|
|
3303
3264
|
}
|
|
3304
3265
|
} else {
|
|
3305
|
-
|
|
3266
|
+
Test3[5] = 0;
|
|
3306
3267
|
}
|
|
3307
|
-
if (controlTests.includes(
|
|
3308
|
-
|
|
3309
|
-
if (
|
|
3268
|
+
if (controlTests.includes(4) && v.y >= CL - std && v.y <= CL + std) {
|
|
3269
|
+
Test4 += 1;
|
|
3270
|
+
if (Test4 >= 15) {
|
|
3310
3271
|
v.display = new CanvasDrawSettings("pink", "red", 1, 1);
|
|
3311
3272
|
;
|
|
3312
3273
|
}
|
|
3313
3274
|
} else {
|
|
3314
|
-
|
|
3275
|
+
Test4 = 0;
|
|
3315
3276
|
}
|
|
3316
|
-
if (controlTests.includes(
|
|
3317
|
-
|
|
3318
|
-
if (
|
|
3277
|
+
if (controlTests.includes(5) && (v.y < CL - std || v.y > CL + std)) {
|
|
3278
|
+
Test5 += 1;
|
|
3279
|
+
if (Test5 >= 8) {
|
|
3319
3280
|
v.display = new CanvasDrawSettings("brown", "red", 1, 1);
|
|
3320
3281
|
;
|
|
3321
3282
|
}
|
|
3322
3283
|
} else {
|
|
3323
|
-
|
|
3284
|
+
Test5 = 0;
|
|
3285
|
+
}
|
|
3286
|
+
if (controlTests.includes(6) && (v.y > CL && Test6 >= 0 || v.y < CL && Test6 <= 0)) {
|
|
3287
|
+
Test6 += v.y < CL ? -1 : 1;
|
|
3288
|
+
if (Test6 >= 9 || Test6 <= -8) {
|
|
3289
|
+
v.display = new CanvasDrawSettings("orange", "red", 1, 1);
|
|
3290
|
+
}
|
|
3291
|
+
} else {
|
|
3292
|
+
Test6 = 0;
|
|
3293
|
+
}
|
|
3294
|
+
if (i !== 0) {
|
|
3295
|
+
if (controlTests.includes(7) && (v.y > data.values[i - 1].y && Test7 >= 0 || v.y < data.values[i - 1].y && Test7 <= 0)) {
|
|
3296
|
+
Test7 += v.y < data.values[i - 1].y ? -1 : 1;
|
|
3297
|
+
if (Test7 >= 5 || Test7 <= -6) {
|
|
3298
|
+
v.display = new CanvasDrawSettings("yellow", "red", 1, 1);
|
|
3299
|
+
;
|
|
3300
|
+
}
|
|
3301
|
+
} else {
|
|
3302
|
+
Test7 = 0;
|
|
3303
|
+
}
|
|
3304
|
+
if (controlTests.includes(8) && v.y < data.values[i - 1].y) {
|
|
3305
|
+
if (Test8 >= 0) {
|
|
3306
|
+
Test8 = -1 * (Test8 + 1);
|
|
3307
|
+
} else {
|
|
3308
|
+
Test8 = 0;
|
|
3309
|
+
}
|
|
3310
|
+
if (Math.abs(Test8) >= 13) {
|
|
3311
|
+
v.display = new CanvasDrawSettings("purple", "red", 1, 1);
|
|
3312
|
+
;
|
|
3313
|
+
}
|
|
3314
|
+
}
|
|
3315
|
+
if (controlTests.includes(8) && v.y > data.values[i - 1].y) {
|
|
3316
|
+
if (Test8 <= 0) {
|
|
3317
|
+
Test8 = -1 * (Test8 - 1);
|
|
3318
|
+
} else {
|
|
3319
|
+
Test8 = 0;
|
|
3320
|
+
}
|
|
3321
|
+
if (Math.abs(Test8) >= 13) {
|
|
3322
|
+
v.display = new CanvasDrawSettings("purple", "red", 1, 1);
|
|
3323
|
+
;
|
|
3324
|
+
}
|
|
3325
|
+
}
|
|
3324
3326
|
}
|
|
3325
3327
|
});
|
|
3326
3328
|
}
|
|
@@ -3751,7 +3753,7 @@ function CreateControlChart(data, chartTitle, UCL, LCL, controlTests) {
|
|
|
3751
3753
|
LCL = centerline - 3 * std;
|
|
3752
3754
|
}
|
|
3753
3755
|
let dataSet = new DataSet(data.map((d, i) => {
|
|
3754
|
-
return new Point(i, d);
|
|
3756
|
+
return new Point(i + 1, d);
|
|
3755
3757
|
}));
|
|
3756
3758
|
dataSet.line.type = "straight";
|
|
3757
3759
|
let customGridlines = [
|
|
@@ -3761,6 +3763,10 @@ function CreateControlChart(data, chartTitle, UCL, LCL, controlTests) {
|
|
|
3761
3763
|
];
|
|
3762
3764
|
let chartSettings = new ChartSettings();
|
|
3763
3765
|
chartSettings.axis.y.customGridlines = customGridlines;
|
|
3766
|
+
chartSettings.axis.x.min = 0;
|
|
3767
|
+
chartSettings.axis.x.max = data.length + 1;
|
|
3768
|
+
chartSettings.axis.x.step = Math.round(Math.log10(data.length)) * 5;
|
|
3769
|
+
chartSettings.axis.x.tickOnly = true;
|
|
3764
3770
|
MarkOutOfControl(dataSet, UCL, LCL, centerline, std, void 0, controlTests);
|
|
3765
3771
|
let graph = CreateScatterPlot([dataSet], chartTitle, chartSettings);
|
|
3766
3772
|
return graph;
|
package/dist/index.mjs
CHANGED
|
@@ -3130,110 +3130,112 @@ function MarkOutOfControl(data, UCL, LCL, CL, std, display = new CanvasDrawSetti
|
|
|
3130
3130
|
if (std === void 0) {
|
|
3131
3131
|
std = (CL - LCL) / 3;
|
|
3132
3132
|
}
|
|
3133
|
-
let Test2 = 0;
|
|
3134
|
-
let Test3 = 0;
|
|
3133
|
+
let Test2 = [0, 0, 0];
|
|
3134
|
+
let Test3 = [0, 0, 0, 0, 0, 0];
|
|
3135
3135
|
let Test4 = 0;
|
|
3136
|
-
let Test5 =
|
|
3137
|
-
let Test6 =
|
|
3136
|
+
let Test5 = 0;
|
|
3137
|
+
let Test6 = 0;
|
|
3138
3138
|
let Test7 = 0;
|
|
3139
3139
|
let Test8 = 0;
|
|
3140
3140
|
data.values.forEach((v, i) => {
|
|
3141
3141
|
if (controlTests.includes(1) && (v.y > UCL || v.y < LCL)) {
|
|
3142
3142
|
v.display = display;
|
|
3143
3143
|
}
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
Test2 = 0;
|
|
3151
|
-
}
|
|
3152
|
-
if (i !== 0) {
|
|
3153
|
-
if (controlTests.includes(3) && (v.y > data.values[i - 1].y && Test3 >= 0 || v.y < data.values[i - 1].y && Test3 <= 0)) {
|
|
3154
|
-
Test3 += v.y < data.values[i - 1].y ? -1 : 1;
|
|
3155
|
-
if (Test3 >= 5 || Test3 <= -6) {
|
|
3156
|
-
v.display = new CanvasDrawSettings("yellow", "red", 1, 1);
|
|
3157
|
-
;
|
|
3158
|
-
}
|
|
3159
|
-
} else {
|
|
3160
|
-
Test3 = 0;
|
|
3161
|
-
}
|
|
3162
|
-
if (controlTests.includes(4) && v.y < data.values[i - 1].y) {
|
|
3163
|
-
if (Test4 >= 0) {
|
|
3164
|
-
Test4 = -1 * (Test4 + 1);
|
|
3165
|
-
} else {
|
|
3166
|
-
Test4 = 0;
|
|
3167
|
-
}
|
|
3168
|
-
if (Math.abs(Test4) >= 13) {
|
|
3169
|
-
v.display = new CanvasDrawSettings("purple", "red", 1, 1);
|
|
3170
|
-
;
|
|
3171
|
-
}
|
|
3172
|
-
}
|
|
3173
|
-
if (controlTests.includes(4) && v.y > data.values[i - 1].y) {
|
|
3174
|
-
if (Test4 <= 0) {
|
|
3175
|
-
Test4 = -1 * (Test4 - 1);
|
|
3176
|
-
} else {
|
|
3177
|
-
Test4 = 0;
|
|
3178
|
-
}
|
|
3179
|
-
if (Math.abs(Test4) >= 13) {
|
|
3180
|
-
v.display = new CanvasDrawSettings("purple", "red", 1, 1);
|
|
3181
|
-
;
|
|
3182
|
-
}
|
|
3144
|
+
Test2[0] = Test2[1];
|
|
3145
|
+
Test2[1] = Test2[2];
|
|
3146
|
+
if (controlTests.includes(2) && v.y > 2 * std + CL) {
|
|
3147
|
+
Test2[2] = 1;
|
|
3148
|
+
if (Test2[0] === 1 || Test2[1] === 1) {
|
|
3149
|
+
v.display = new CanvasDrawSettings("white", "red", 1, 1);
|
|
3183
3150
|
}
|
|
3184
3151
|
}
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
Test5[2] = 1;
|
|
3189
|
-
if (Test5[0] === 1 || Test5[1] === 1) {
|
|
3152
|
+
if (controlTests.includes(2) && v.y < CL - 2 * std) {
|
|
3153
|
+
Test2[2] = -1;
|
|
3154
|
+
if (Test2[0] === -1 || Test2[1] === -1) {
|
|
3190
3155
|
v.display = new CanvasDrawSettings("white", "red", 1, 1);
|
|
3191
|
-
;
|
|
3192
3156
|
}
|
|
3193
3157
|
}
|
|
3194
|
-
if (
|
|
3195
|
-
|
|
3196
|
-
if (Test5[0] === -1 || Test5[1] === -1) {
|
|
3197
|
-
v.display = display;
|
|
3198
|
-
}
|
|
3158
|
+
if (v.y > CL - 2 * std && v.y < 2 * std + CL) {
|
|
3159
|
+
Test2[2] = 0;
|
|
3199
3160
|
}
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
if (controlTests.includes(
|
|
3206
|
-
|
|
3207
|
-
let plus =
|
|
3161
|
+
Test3[0] = Test3[1];
|
|
3162
|
+
Test3[1] = Test3[2];
|
|
3163
|
+
Test3[2] = Test3[3];
|
|
3164
|
+
Test3[3] = Test3[4];
|
|
3165
|
+
Test3[4] = Test3[5];
|
|
3166
|
+
if (controlTests.includes(3) && v.y > std + CL) {
|
|
3167
|
+
Test3[5] = 1;
|
|
3168
|
+
let plus = Test3.filter((t) => t === 1);
|
|
3208
3169
|
if (plus.length >= 4) {
|
|
3209
3170
|
v.display = new CanvasDrawSettings("grey", "red", 1, 1);
|
|
3210
3171
|
}
|
|
3211
|
-
} else if (controlTests.includes(
|
|
3212
|
-
|
|
3213
|
-
let plus =
|
|
3172
|
+
} else if (controlTests.includes(3) && v.y < CL - std) {
|
|
3173
|
+
Test3[5] = -1;
|
|
3174
|
+
let plus = Test3.filter((t) => t === -1);
|
|
3214
3175
|
if (plus.length >= 4) {
|
|
3215
3176
|
v.display = display;
|
|
3216
3177
|
}
|
|
3217
3178
|
} else {
|
|
3218
|
-
|
|
3179
|
+
Test3[5] = 0;
|
|
3219
3180
|
}
|
|
3220
|
-
if (controlTests.includes(
|
|
3221
|
-
|
|
3222
|
-
if (
|
|
3181
|
+
if (controlTests.includes(4) && v.y >= CL - std && v.y <= CL + std) {
|
|
3182
|
+
Test4 += 1;
|
|
3183
|
+
if (Test4 >= 15) {
|
|
3223
3184
|
v.display = new CanvasDrawSettings("pink", "red", 1, 1);
|
|
3224
3185
|
;
|
|
3225
3186
|
}
|
|
3226
3187
|
} else {
|
|
3227
|
-
|
|
3188
|
+
Test4 = 0;
|
|
3228
3189
|
}
|
|
3229
|
-
if (controlTests.includes(
|
|
3230
|
-
|
|
3231
|
-
if (
|
|
3190
|
+
if (controlTests.includes(5) && (v.y < CL - std || v.y > CL + std)) {
|
|
3191
|
+
Test5 += 1;
|
|
3192
|
+
if (Test5 >= 8) {
|
|
3232
3193
|
v.display = new CanvasDrawSettings("brown", "red", 1, 1);
|
|
3233
3194
|
;
|
|
3234
3195
|
}
|
|
3235
3196
|
} else {
|
|
3236
|
-
|
|
3197
|
+
Test5 = 0;
|
|
3198
|
+
}
|
|
3199
|
+
if (controlTests.includes(6) && (v.y > CL && Test6 >= 0 || v.y < CL && Test6 <= 0)) {
|
|
3200
|
+
Test6 += v.y < CL ? -1 : 1;
|
|
3201
|
+
if (Test6 >= 9 || Test6 <= -8) {
|
|
3202
|
+
v.display = new CanvasDrawSettings("orange", "red", 1, 1);
|
|
3203
|
+
}
|
|
3204
|
+
} else {
|
|
3205
|
+
Test6 = 0;
|
|
3206
|
+
}
|
|
3207
|
+
if (i !== 0) {
|
|
3208
|
+
if (controlTests.includes(7) && (v.y > data.values[i - 1].y && Test7 >= 0 || v.y < data.values[i - 1].y && Test7 <= 0)) {
|
|
3209
|
+
Test7 += v.y < data.values[i - 1].y ? -1 : 1;
|
|
3210
|
+
if (Test7 >= 5 || Test7 <= -6) {
|
|
3211
|
+
v.display = new CanvasDrawSettings("yellow", "red", 1, 1);
|
|
3212
|
+
;
|
|
3213
|
+
}
|
|
3214
|
+
} else {
|
|
3215
|
+
Test7 = 0;
|
|
3216
|
+
}
|
|
3217
|
+
if (controlTests.includes(8) && v.y < data.values[i - 1].y) {
|
|
3218
|
+
if (Test8 >= 0) {
|
|
3219
|
+
Test8 = -1 * (Test8 + 1);
|
|
3220
|
+
} else {
|
|
3221
|
+
Test8 = 0;
|
|
3222
|
+
}
|
|
3223
|
+
if (Math.abs(Test8) >= 13) {
|
|
3224
|
+
v.display = new CanvasDrawSettings("purple", "red", 1, 1);
|
|
3225
|
+
;
|
|
3226
|
+
}
|
|
3227
|
+
}
|
|
3228
|
+
if (controlTests.includes(8) && v.y > data.values[i - 1].y) {
|
|
3229
|
+
if (Test8 <= 0) {
|
|
3230
|
+
Test8 = -1 * (Test8 - 1);
|
|
3231
|
+
} else {
|
|
3232
|
+
Test8 = 0;
|
|
3233
|
+
}
|
|
3234
|
+
if (Math.abs(Test8) >= 13) {
|
|
3235
|
+
v.display = new CanvasDrawSettings("purple", "red", 1, 1);
|
|
3236
|
+
;
|
|
3237
|
+
}
|
|
3238
|
+
}
|
|
3237
3239
|
}
|
|
3238
3240
|
});
|
|
3239
3241
|
}
|
|
@@ -3664,7 +3666,7 @@ function CreateControlChart(data, chartTitle, UCL, LCL, controlTests) {
|
|
|
3664
3666
|
LCL = centerline - 3 * std;
|
|
3665
3667
|
}
|
|
3666
3668
|
let dataSet = new DataSet(data.map((d, i) => {
|
|
3667
|
-
return new Point(i, d);
|
|
3669
|
+
return new Point(i + 1, d);
|
|
3668
3670
|
}));
|
|
3669
3671
|
dataSet.line.type = "straight";
|
|
3670
3672
|
let customGridlines = [
|
|
@@ -3674,6 +3676,10 @@ function CreateControlChart(data, chartTitle, UCL, LCL, controlTests) {
|
|
|
3674
3676
|
];
|
|
3675
3677
|
let chartSettings = new ChartSettings();
|
|
3676
3678
|
chartSettings.axis.y.customGridlines = customGridlines;
|
|
3679
|
+
chartSettings.axis.x.min = 0;
|
|
3680
|
+
chartSettings.axis.x.max = data.length + 1;
|
|
3681
|
+
chartSettings.axis.x.step = Math.round(Math.log10(data.length)) * 5;
|
|
3682
|
+
chartSettings.axis.x.tickOnly = true;
|
|
3677
3683
|
MarkOutOfControl(dataSet, UCL, LCL, centerline, std, void 0, controlTests);
|
|
3678
3684
|
let graph = CreateScatterPlot([dataSet], chartTitle, chartSettings);
|
|
3679
3685
|
return graph;
|
package/index.ts
CHANGED
|
@@ -3597,11 +3597,11 @@ export function CreateScatterPlot(data: DataSet[], title?: string, chartSettings
|
|
|
3597
3597
|
function MarkOutOfControl(data: DataSet, UCL: number, LCL: number, CL?: any, std?: any, display = new CanvasDrawSettings("red", "red", 1, 1), controlTests: any = [1]) {
|
|
3598
3598
|
if(CL === undefined){CL = Mean(data.values.map(v => {return v.y}))}
|
|
3599
3599
|
if(std === undefined){std = (CL - LCL)/3}
|
|
3600
|
-
let Test2 = 0;
|
|
3601
|
-
let Test3 = 0;
|
|
3600
|
+
let Test2 = [0,0,0];
|
|
3601
|
+
let Test3 = [0, 0, 0, 0, 0, 0];
|
|
3602
3602
|
let Test4 = 0;
|
|
3603
|
-
let Test5 =
|
|
3604
|
-
let Test6 =
|
|
3603
|
+
let Test5 = 0;
|
|
3604
|
+
let Test6 = 0;
|
|
3605
3605
|
let Test7 = 0;
|
|
3606
3606
|
let Test8 = 0;
|
|
3607
3607
|
data.values.forEach((v, i) => {
|
|
@@ -3609,100 +3609,105 @@ function MarkOutOfControl(data: DataSet, UCL: number, LCL: number, CL?: any, std
|
|
|
3609
3609
|
if (controlTests.includes(1) && (v.y > UCL || v.y < LCL)) {
|
|
3610
3610
|
v.display = display;
|
|
3611
3611
|
}
|
|
3612
|
-
// Test2: Nine points in a row on same side of center line
|
|
3613
|
-
if(controlTests.includes(2) && ((v.y > CL && Test2 >= 0) || (v.y < CL && Test2 <= 0))){
|
|
3614
|
-
Test2 += v.y < CL ? -1 : 1;
|
|
3615
|
-
if(Test2 >= 8 || Test2 <= -8){
|
|
3616
|
-
v.display = new CanvasDrawSettings("orange", "red", 1, 1);
|
|
3617
|
-
}
|
|
3618
|
-
}else{
|
|
3619
|
-
Test2 = 0;
|
|
3620
|
-
}
|
|
3621
3612
|
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
}else{
|
|
3630
|
-
Test3 = 0;
|
|
3631
|
-
}
|
|
3632
|
-
|
|
3633
|
-
//Test4: Fourteen points in a row, alternating up and down
|
|
3634
|
-
if(controlTests.includes(4) && v.y < data.values[i-1].y){
|
|
3635
|
-
if(Test4 >= 0){
|
|
3636
|
-
Test4 = -1*(Test4 + 1);
|
|
3637
|
-
}else{Test4 = 0}
|
|
3638
|
-
if(Math.abs(Test4) >= 13){
|
|
3639
|
-
v.display = new CanvasDrawSettings("purple", "red", 1, 1);;
|
|
3640
|
-
}
|
|
3641
|
-
}
|
|
3642
|
-
if(controlTests.includes(4) && v.y > data.values[i-1].y){
|
|
3643
|
-
if(Test4 <= 0){
|
|
3644
|
-
Test4 = -1*(Test4 - 1);
|
|
3645
|
-
}else{Test4 = 0}
|
|
3646
|
-
if(Math.abs(Test4) >= 13){
|
|
3647
|
-
v.display = new CanvasDrawSettings("purple", "red", 1, 1);;
|
|
3648
|
-
}
|
|
3613
|
+
// Test2: Two out of three points more than 2σ from the center line (same side)
|
|
3614
|
+
Test2[0] = Test2[1];
|
|
3615
|
+
Test2[1] = Test2[2];
|
|
3616
|
+
if (controlTests.includes(2) && v.y > 2*std+CL) {
|
|
3617
|
+
Test2[2] = 1;
|
|
3618
|
+
if(Test2[0] === 1 || Test2[1] === 1){
|
|
3619
|
+
v.display = new CanvasDrawSettings("white", "red", 1, 1);
|
|
3649
3620
|
}
|
|
3650
3621
|
}
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
if (controlTests.includes(5) && v.y > 2*std+CL) {
|
|
3656
|
-
Test5[2] = 1;
|
|
3657
|
-
if(Test5[0] === 1 || Test5[1] === 1){
|
|
3658
|
-
v.display = new CanvasDrawSettings("white", "red", 1, 1);;
|
|
3622
|
+
if (controlTests.includes(2) && v.y < CL-2*std) {
|
|
3623
|
+
Test2[2] = -1;
|
|
3624
|
+
if(Test2[0] === -1 || Test2[1] === -1){
|
|
3625
|
+
v.display = new CanvasDrawSettings("white", "red", 1, 1);
|
|
3659
3626
|
}
|
|
3660
3627
|
}
|
|
3661
|
-
if
|
|
3662
|
-
|
|
3663
|
-
if(Test5[0] === -1 || Test5[1] === -1){
|
|
3664
|
-
v.display = display;
|
|
3665
|
-
}
|
|
3628
|
+
if(v.y > CL-2*std && v.y < 2*std+CL){
|
|
3629
|
+
Test2[2] = 0;
|
|
3666
3630
|
}
|
|
3667
3631
|
|
|
3668
|
-
//
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
if (controlTests.includes(
|
|
3675
|
-
|
|
3676
|
-
let plus =
|
|
3632
|
+
// Test3: Four out of five points more than 1σ from center line (same side)
|
|
3633
|
+
Test3[0] = Test3[1];
|
|
3634
|
+
Test3[1] = Test3[2];
|
|
3635
|
+
Test3[2] = Test3[3];
|
|
3636
|
+
Test3[3] = Test3[4];
|
|
3637
|
+
Test3[4] = Test3[5];
|
|
3638
|
+
if (controlTests.includes(3) && v.y > std+CL) {
|
|
3639
|
+
Test3[5] = 1;
|
|
3640
|
+
let plus = Test3.filter(t => t === 1);
|
|
3677
3641
|
if(plus.length >= 4){
|
|
3678
3642
|
v.display = new CanvasDrawSettings("grey", "red", 1, 1);
|
|
3679
3643
|
}
|
|
3680
|
-
}else if (controlTests.includes(
|
|
3681
|
-
|
|
3682
|
-
let plus =
|
|
3644
|
+
}else if (controlTests.includes(3) && v.y < CL-std) {
|
|
3645
|
+
Test3[5] = -1;
|
|
3646
|
+
let plus = Test3.filter(t => t === -1);
|
|
3683
3647
|
if(plus.length >= 4){
|
|
3684
3648
|
v.display = display
|
|
3685
3649
|
}
|
|
3686
|
-
}else{
|
|
3650
|
+
}else{Test3[5] = 0}
|
|
3687
3651
|
|
|
3688
|
-
//
|
|
3689
|
-
if(controlTests.includes(
|
|
3690
|
-
|
|
3691
|
-
if(
|
|
3652
|
+
// Test4: Fifteen points in a row within 1σ of center line (either side)
|
|
3653
|
+
if(controlTests.includes(4) && v.y >= CL - std && v.y <= CL + std){
|
|
3654
|
+
Test4 += 1;
|
|
3655
|
+
if(Test4 >= 15){
|
|
3692
3656
|
v.display = new CanvasDrawSettings("pink", "red", 1, 1);;
|
|
3693
3657
|
}
|
|
3694
3658
|
}else{
|
|
3695
|
-
|
|
3659
|
+
Test4 = 0
|
|
3696
3660
|
}
|
|
3697
3661
|
|
|
3698
|
-
//
|
|
3699
|
-
if(controlTests.includes(
|
|
3700
|
-
|
|
3701
|
-
if(
|
|
3662
|
+
// Test5: 8 points in a row more than 1σ of center line (either side)
|
|
3663
|
+
if(controlTests.includes(5) && (v.y < CL - std || v.y > CL + std)){
|
|
3664
|
+
Test5 += 1;
|
|
3665
|
+
if(Test5 >= 8){
|
|
3702
3666
|
v.display = new CanvasDrawSettings("brown", "red", 1, 1);;
|
|
3703
3667
|
}
|
|
3704
3668
|
}else{
|
|
3705
|
-
|
|
3669
|
+
Test5 = 0
|
|
3670
|
+
}
|
|
3671
|
+
|
|
3672
|
+
|
|
3673
|
+
// Test6: Nine points in a row on same side of center line
|
|
3674
|
+
if(controlTests.includes(6) && ((v.y > CL && Test6 >= 0) || (v.y < CL && Test6 <= 0))){
|
|
3675
|
+
Test6 += v.y < CL ? -1 : 1;
|
|
3676
|
+
if(Test6 >= 9 || Test6 <= -8){
|
|
3677
|
+
v.display = new CanvasDrawSettings("orange", "red", 1, 1);
|
|
3678
|
+
}
|
|
3679
|
+
}else{
|
|
3680
|
+
Test6 = 0;
|
|
3681
|
+
}
|
|
3682
|
+
|
|
3683
|
+
if(i !== 0){
|
|
3684
|
+
// Test7: Six points in a row increasing or decreasing
|
|
3685
|
+
if(controlTests.includes(7) && ((v.y > data.values[i-1].y && Test7 >= 0) || (v.y < data.values[i-1].y && Test7 <= 0))){
|
|
3686
|
+
Test7 += v.y < data.values[i-1].y ? -1 : 1;
|
|
3687
|
+
if(Test7 >= 5 || Test7 <= -6){
|
|
3688
|
+
v.display = new CanvasDrawSettings("yellow", "red", 1, 1);;
|
|
3689
|
+
}
|
|
3690
|
+
}else{
|
|
3691
|
+
Test7 = 0;
|
|
3692
|
+
}
|
|
3693
|
+
|
|
3694
|
+
//Test8: Fourteen points in a row, alternating up and down
|
|
3695
|
+
if(controlTests.includes(8) && v.y < data.values[i-1].y){
|
|
3696
|
+
if(Test8 >= 0){
|
|
3697
|
+
Test8 = -1*(Test8 + 1);
|
|
3698
|
+
}else{Test8 = 0}
|
|
3699
|
+
if(Math.abs(Test8) >= 13){
|
|
3700
|
+
v.display = new CanvasDrawSettings("purple", "red", 1, 1);;
|
|
3701
|
+
}
|
|
3702
|
+
}
|
|
3703
|
+
if(controlTests.includes(8) && v.y > data.values[i-1].y){
|
|
3704
|
+
if(Test8 <= 0){
|
|
3705
|
+
Test8 = -1*(Test8 - 1);
|
|
3706
|
+
}else{Test8 = 0}
|
|
3707
|
+
if(Math.abs(Test8) >= 13){
|
|
3708
|
+
v.display = new CanvasDrawSettings("purple", "red", 1, 1);;
|
|
3709
|
+
}
|
|
3710
|
+
}
|
|
3706
3711
|
}
|
|
3707
3712
|
|
|
3708
3713
|
});
|
|
@@ -4274,7 +4279,7 @@ export function CreateControlChart(data: number[], chartTitle?: string, UCL?: nu
|
|
|
4274
4279
|
if(LCL === undefined){
|
|
4275
4280
|
LCL = centerline - 3 * std;
|
|
4276
4281
|
}
|
|
4277
|
-
let dataSet = new DataSet(data.map((d,i) => {return new Point(i,d)}));
|
|
4282
|
+
let dataSet = new DataSet(data.map((d,i) => {return new Point(i+1,d)}));
|
|
4278
4283
|
dataSet.line.type = "straight";
|
|
4279
4284
|
let customGridlines = [
|
|
4280
4285
|
new CustomGridline(centerline, `x\u0304 = ${Math.round(centerline * 1e3) / 1e3}`, new CanvasDrawSettings("", "green"), void 0, true),
|
|
@@ -4283,6 +4288,10 @@ export function CreateControlChart(data: number[], chartTitle?: string, UCL?: nu
|
|
|
4283
4288
|
];
|
|
4284
4289
|
let chartSettings = new ChartSettings();
|
|
4285
4290
|
chartSettings.axis.y.customGridlines = customGridlines;
|
|
4291
|
+
chartSettings.axis.x.min = 0;
|
|
4292
|
+
chartSettings.axis.x.max = data.length + 1;
|
|
4293
|
+
chartSettings.axis.x.step = Math.round(Math.log10(data.length))*5;
|
|
4294
|
+
chartSettings.axis.x.tickOnly = true;
|
|
4286
4295
|
|
|
4287
4296
|
MarkOutOfControl(dataSet, UCL, LCL, centerline, std,undefined,controlTests);
|
|
4288
4297
|
|
package/package.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
-bug fix in MarkOutOfControl incorrect counting
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
- Make X axis integers on control charts to show the index of measurements
|