diff --git a/capabilities.json b/capabilities.json index dfbdf65..c3a7385 100644 --- a/capabilities.json +++ b/capabilities.json @@ -112,6 +112,18 @@ "type": { "text": true } + }, + "ll_truncate": { + "displayName": "Truncate Lower Limits at:", + "type": { + "numeric": true + } + }, + "ul_truncate": { + "displayName": "Truncate Upper Limits at:", + "type": { + "numeric": true + } } } }, diff --git a/pbiviz.json b/pbiviz.json index 3562741..d73ed26 100644 --- a/pbiviz.json +++ b/pbiviz.json @@ -4,7 +4,7 @@ "displayName":"SPC Charts", "guid":"PBISPC", "visualClassName":"Visual", - "version":"1.1.2", + "version":"1.1.3", "description":"A PowerBI custom visual for SPC charts", "supportUrl":"https://github.com/AUS-DOH-Safety-and-Quality/PowerBI-SPC", "gitHubUrl":"https://github.com/AUS-DOH-Safety-and-Quality/PowerBI-SPC" diff --git a/src/Classes/axisLimits.ts b/src/Classes/axisLimits.ts index 5d93173..ab08aaa 100644 --- a/src/Classes/axisLimits.ts +++ b/src/Classes/axisLimits.ts @@ -1,5 +1,5 @@ import * as d3 from "d3"; -import controlLimits from "../Type Definitions/controlLimits" +import controlLimits from "./controlLimits" import settingsObject from "./settingsObject"; import dataObject from "./dataObject" import truncate from "../Functions/truncate"; diff --git a/src/Classes/chartObject.ts b/src/Classes/chartObject.ts index dbb98e6..acba7b9 100644 --- a/src/Classes/chartObject.ts +++ b/src/Classes/chartObject.ts @@ -1,8 +1,9 @@ import * as limitFunctions from "../Limit Calculations" import dataObject from "./dataObject"; import settingsObject from "./settingsObject"; -import controlLimits from "../Type Definitions/controlLimits"; +import controlLimits from "./controlLimits"; import { multiply } from "../Function Broadcasting/BinaryFunctions"; +import truncate from "../Functions/truncate" type chartObjectConstructor = { inputData: dataObject; @@ -18,7 +19,7 @@ class chartObject { let calcLimits: controlLimits; let rebaselineLimits: boolean; let split_vals: string[]; - + if (this.inputSettings.spc.denom_split.value !== null) { let split_vals_raw: string[] = this.inputSettings.spc.denom_split.value.split(",") split_vals = split_vals_raw.filter(d => this.inputData.keys.map(d2 => d2.label).includes(d)); @@ -31,7 +32,7 @@ class chartObject { let indexes: number[] = split_vals.map(d => this.inputData.keys.map(d2 => d2.label).indexOf(d)) .concat([this.inputData.keys.length - 1]) .sort((a,b) => a - b); - + let groupedData: dataObject[] = indexes.map((d, idx) => { // Force a deep copy let data = JSON.parse(JSON.stringify(this.inputData)); @@ -46,7 +47,7 @@ class chartObject { } return data; }) - + let calcLimitsGrouped: controlLimits[] = groupedData.map(d => this.limitFunction(d)); calcLimits = calcLimitsGrouped.reduce((all: controlLimits, curr: controlLimits) => { @@ -66,12 +67,16 @@ class chartObject { // Scale limits using provided multiplier let multiplier: number = this.inputData.multiplier; calcLimits.values = multiply(calcLimits.values, multiplier); - calcLimits.ll99 = multiply(calcLimits.ll99, multiplier); - calcLimits.ll95 = multiply(calcLimits.ll95, multiplier); - calcLimits.ul95 = multiply(calcLimits.ul95, multiplier); - calcLimits.ul99 = multiply(calcLimits.ul99, multiplier); + calcLimits.ll99 = truncate(multiply(calcLimits.ll99, multiplier), + this.inputData.limit_truncs); + calcLimits.ll95 = truncate(multiply(calcLimits.ll95, multiplier), + this.inputData.limit_truncs); + calcLimits.ul95 = truncate(multiply(calcLimits.ul95, multiplier), + this.inputData.limit_truncs); + calcLimits.ul99 = truncate(multiply(calcLimits.ul99, multiplier), + this.inputData.limit_truncs); calcLimits.targets = multiply(calcLimits.targets, multiplier); - + console.log("inputData: ", this.inputData); console.log("calcLimits: ", calcLimits) return calcLimits; diff --git a/src/Classes/controlLimits.ts b/src/Classes/controlLimits.ts new file mode 100644 index 0000000..e09212c --- /dev/null +++ b/src/Classes/controlLimits.ts @@ -0,0 +1,48 @@ +import plotKey from "../Type Definitions/plotKey" + +type controlLimitsArgs = { + keys: plotKey[]; + values: number[]; + numerators?: number[]; + denominators?: number[]; + targets: number[]; + ll99: number[]; + ll95: number[]; + ul95: number[]; + ul99: number[]; + count?: number[]; +} + +class controlLimits { + keys: plotKey[]; + values: number[]; + numerators?: number[]; + denominators?: number[]; + targets: number[]; + ll99: number[]; + ll95: number[]; + ul95: number[]; + ul99: number[]; + count?: number[]; + + constructor(args: controlLimitsArgs) { + this.keys = args.keys; + this.values = args.values; + if (args.numerators || !(args.numerators === null || args.numerators === undefined)) { + this.numerators = args.numerators; + } + if (args.denominators || !(args.denominators === null || args.denominators === undefined)) { + this.denominators = args.denominators; + } + this.targets = args.targets; + this.ll99 = args.ll99; + this.ll95 = args.ll95; + this.ul95 = args.ul95; + this.ul99 = args.ul99; + if (args.count || !(args.count === null || args.count === undefined)) { + this.count = args.count; + } + } +} + +export default controlLimits diff --git a/src/Classes/dataObject.ts b/src/Classes/dataObject.ts index 9b53b88..6c575ff 100644 --- a/src/Classes/dataObject.ts +++ b/src/Classes/dataObject.ts @@ -21,6 +21,7 @@ class dataObject { multiplier: number; highlights: powerbi.PrimitiveValue[]; categories: powerbi.DataViewCategoryColumn; + limit_truncs: {lower?: number, upper?: number}; constructor(args: dataObjectConstructor) { if (args.empty) { @@ -74,6 +75,10 @@ class dataObject { this.multiplier = multiplier; this.highlights = numerators_raw.highlights ? extractValues(numerators_raw.highlights, valid_ids) : numerators_raw.highlights; this.categories = args.inputView.categories[0] + this.limit_truncs = { + lower: args.inputSettings.spc.ll_truncate.value, + upper: args.inputSettings.spc.ul_truncate.value + } } } diff --git a/src/Classes/settingsObject.ts b/src/Classes/settingsObject.ts index 12f960a..7504044 100644 --- a/src/Classes/settingsObject.ts +++ b/src/Classes/settingsObject.ts @@ -37,11 +37,15 @@ class spcSettings { chart_type: settingsPair; multiplier: settingsPair; denom_split: settingsPair; + ll_truncate: settingsPair; + ul_truncate: settingsPair; constructor() { this.chart_type = new settingsPair("i"); this.multiplier = new settingsPair(1); this.denom_split = new settingsPair(null); + this.ul_truncate = new settingsPair(null); + this.ll_truncate = new settingsPair(null); } } diff --git a/src/Classes/viewModel.ts b/src/Classes/viewModel.ts index 5ce8ade..3a643d7 100644 --- a/src/Classes/viewModel.ts +++ b/src/Classes/viewModel.ts @@ -6,7 +6,7 @@ import chartObject from "./chartObject" import settingsObject from "./settingsObject"; import dataObject from "./dataObject"; import lineData from "./lineData" -import controlLimits from "../Type Definitions/controlLimits"; +import controlLimits from "./controlLimits"; import plotData from "./plotData" import checkInvalidDataView from "../Functions/checkInvalidDataView" import buildTooltip from "../Functions/buildTooltip" @@ -44,6 +44,8 @@ class viewModelObject { highlighted: this.inputData.highlights ? (this.inputData.highlights[index] ? true : false) : false, tooltip: buildTooltip({date: this.calculatedLimits.keys[i].label, value: this.calculatedLimits.values[i], + numerator: this.calculatedLimits.numerators ? this.calculatedLimits.numerators[i] : null, + denominator: this.calculatedLimits.denominators ? this.calculatedLimits.denominators[i] : null, target: this.calculatedLimits.targets[i], limits: { ll99: this.calculatedLimits.ll99[i], @@ -130,6 +132,7 @@ class viewModelObject { this.calculatedLimits = this.chartBase.getLimits(); console.log(this.calculatedLimits) this.plotPoints = this.getPlotData(); + console.log("Got plot data") this.plotPoints.forEach((point, idx) => { point.identity = args.host .createSelectionIdBuilder() @@ -138,9 +141,11 @@ class viewModelObject { .createSelectionId() }) this.groupedLines = this.getGroupedLines(); + console.log("Grouped lines for plotting") this.axisLimits = new axisLimits({ inputData: this.inputData, inputSettings: this.inputSettings, calculatedLimits: this.calculatedLimits }); + console.log("Made axis limits") this.displayPlot = this.plotPoints.length > 1; this.percentLabels = ["p", "pp"].includes(this.inputData.chart_type) && this.inputData.multiplier == 1 diff --git a/src/Functions/buildTooltip.ts b/src/Functions/buildTooltip.ts index 94809a2..693f119 100644 --- a/src/Functions/buildTooltip.ts +++ b/src/Functions/buildTooltip.ts @@ -30,6 +30,7 @@ let valueNames = { } function buildTooltip(args: tooltipArgs): VisualTooltipDataItem[] { + console.log(args) let tooltip: VisualTooltipDataItem[] = new Array(); tooltip.push({ displayName: "Date", @@ -41,7 +42,15 @@ function buildTooltip(args: tooltipArgs): VisualTooltipDataItem[] { ? (args.value * 100).toFixed(2) + "%" : args.value.toFixed(4) }) - if(args.denominator) { + if(args.numerator || !(args.numerator === null || args.numerator === undefined)) { + console.log("push num") + tooltip.push({ + displayName: "Numerator", + value: (args.numerator).toFixed(2) + }) + } + if(args.denominator || !(args.denominator === null || args.denominator === undefined)) { + console.log("push denom") tooltip.push({ displayName: "Denominator", value: (args.denominator).toFixed(2) diff --git a/src/Limit Calculations/c.ts b/src/Limit Calculations/c.ts index b558d8a..4c1e307 100644 --- a/src/Limit Calculations/c.ts +++ b/src/Limit Calculations/c.ts @@ -1,13 +1,13 @@ import * as d3 from "d3"; import rep from "../Functions/rep"; import dataObject from "../Classes/dataObject" -import controlLimits from "../Type Definitions/controlLimits" +import controlLimits from "../Classes/controlLimits" function cLimits(inputData: dataObject): controlLimits { let cl: number = d3.mean(inputData.numerators); let sigma: number = Math.sqrt(cl); - return { + return new controlLimits({ keys: inputData.keys, values: inputData.numerators, targets: rep(cl, inputData.keys.length), @@ -15,7 +15,7 @@ function cLimits(inputData: dataObject): controlLimits { ll95: rep(Math.max(cl - 2 * sigma, 0), inputData.keys.length), ul95: rep(cl + 2*sigma, inputData.keys.length), ul99: rep(cl + 3*sigma, inputData.keys.length), - }; + }); } export default cLimits; diff --git a/src/Limit Calculations/g.ts b/src/Limit Calculations/g.ts index 7bf4aae..d97bf94 100644 --- a/src/Limit Calculations/g.ts +++ b/src/Limit Calculations/g.ts @@ -2,13 +2,13 @@ import * as d3 from "d3"; import { sqrt } from "../Function Broadcasting/UnaryFunctions"; import rep from "../Functions/rep"; import dataObject from "../Classes/dataObject"; -import controlLimits from "../Type Definitions/controlLimits"; +import controlLimits from "../Classes/controlLimits"; function gLimits(inputData: dataObject): controlLimits { let cl: number = d3.mean(inputData.numerators); let sigma: number = sqrt(cl * (cl + 1)); - return { + return new controlLimits({ keys: inputData.keys, values: inputData.numerators, targets: rep(cl, inputData.keys.length), @@ -16,7 +16,7 @@ function gLimits(inputData: dataObject): controlLimits { ll95: rep(0, inputData.keys.length), ul95: rep(cl + 2*sigma, inputData.keys.length), ul99: rep(cl + 3*sigma, inputData.keys.length) - }; + }); } export default gLimits; diff --git a/src/Limit Calculations/i.ts b/src/Limit Calculations/i.ts index acd3172..01be144 100644 --- a/src/Limit Calculations/i.ts +++ b/src/Limit Calculations/i.ts @@ -4,10 +4,11 @@ import rep from "../Functions/rep"; import { abs } from "../Function Broadcasting/UnaryFunctions" import { divide } from "../Function Broadcasting/BinaryFunctions"; import dataObject from "../Classes/dataObject"; -import controlLimits from "../Type Definitions/controlLimits"; +import controlLimits from "../Classes/controlLimits"; function iLimits(inputData: dataObject): controlLimits { - let ratio: number[] = (inputData.denominators && inputData.denominators.length > 0) + let useRatio: boolean = (inputData.denominators && inputData.denominators.length > 0); + let ratio: number[] = useRatio ? divide(inputData.numerators, inputData.denominators) : inputData.numerators; @@ -19,15 +20,17 @@ function iLimits(inputData: dataObject): controlLimits { let sigma: number = d3.mean(consec_diff_valid) / 1.128; - return { + return new controlLimits({ keys: inputData.keys, values: ratio.map(d => isNaN(d) ? 0 : d), + numerators: useRatio ? inputData.numerators : undefined, + denominators: useRatio ? inputData.denominators : undefined, targets: rep(cl, inputData.keys.length), ll99: rep(cl - 3 * sigma, inputData.keys.length), ll95: rep(cl - 2 * sigma, inputData.keys.length), ul95: rep(cl + 2 * sigma, inputData.keys.length), ul99: rep(cl + 3 * sigma, inputData.keys.length) - }; + }); } export default iLimits; diff --git a/src/Limit Calculations/mr.ts b/src/Limit Calculations/mr.ts index f68551e..ae6dff9 100644 --- a/src/Limit Calculations/mr.ts +++ b/src/Limit Calculations/mr.ts @@ -4,28 +4,28 @@ import rep from "../Functions/rep"; import { abs } from "../Function Broadcasting/UnaryFunctions" import { divide } from "../Function Broadcasting/BinaryFunctions"; import dataObject from "../Classes/dataObject"; -import controlLimits from "../Type Definitions/controlLimits"; +import controlLimits from "../Classes/controlLimits"; function mrLimits(inputData: dataObject): controlLimits { - let ratio: number[]; - if (inputData.denominators == null) { - ratio = inputData.numerators; - } else { - ratio = divide(inputData.numerators, inputData.denominators); - } + let useRatio: boolean = (inputData.denominators && inputData.denominators.length > 0); + let ratio: number[] = useRatio + ? divide(inputData.numerators, inputData.denominators) + : inputData.numerators; let consec_diff: number[] = abs(diff(ratio)); let cl: number = d3.mean(consec_diff); - return { + return new controlLimits({ keys: inputData.keys, values: consec_diff, + numerators: useRatio ? inputData.numerators : null, + denominators: useRatio ? inputData.denominators : null, targets: rep(cl, inputData.keys.length), ll99: rep(0, inputData.keys.length), ll95: rep(0, inputData.keys.length), ul95: rep((3.267 / 3) * 2 * cl, inputData.keys.length), ul99: rep(3.267 * cl, inputData.keys.length) - }; + }); } export default mrLimits; diff --git a/src/Limit Calculations/p.ts b/src/Limit Calculations/p.ts index f83f86a..9dccdd7 100644 --- a/src/Limit Calculations/p.ts +++ b/src/Limit Calculations/p.ts @@ -2,7 +2,7 @@ import * as d3 from "d3"; import rep from "../Functions/rep"; import { sqrt } from "../Function Broadcasting/UnaryFunctions"; import { subtract, add, divide, multiply } from "../Function Broadcasting/BinaryFunctions"; -import controlLimits from "../Type Definitions/controlLimits"; +import controlLimits from "../Classes/controlLimits"; import dataObject from "../Classes/dataObject"; import truncate from "../Functions/truncate" @@ -10,15 +10,17 @@ function pLimits(inputData: dataObject): controlLimits { let cl: number = d3.sum(inputData.numerators) / d3.sum(inputData.denominators); let sigma: number[] = sqrt(divide(cl * (1 - cl), inputData.denominators)); - return { + return new controlLimits({ keys: inputData.keys, values: divide(inputData.numerators, inputData.denominators), + numerators: inputData.numerators, + denominators: inputData.denominators, targets: rep(cl, inputData.keys.length), ll99: truncate(subtract(cl, multiply(3, sigma)), {lower: 0}), ll95: truncate(subtract(cl, multiply(2, sigma)), {lower: 0}), ul95: truncate(add(cl, multiply(2, sigma)), {upper: 1}), ul99: truncate(add(cl, multiply(3, sigma)), {upper: 1}) - } + }); } export default pLimits; diff --git a/src/Limit Calculations/pprime.ts b/src/Limit Calculations/pprime.ts index 945b5e8..4a77026 100644 --- a/src/Limit Calculations/pprime.ts +++ b/src/Limit Calculations/pprime.ts @@ -3,7 +3,7 @@ import rep from "../Functions/rep"; import diff from "../Functions/diff"; import { sqrt, abs } from "../Function Broadcasting/UnaryFunctions"; import { subtract, add, divide, multiply } from "../Function Broadcasting/BinaryFunctions"; -import controlLimits from "../Type Definitions/controlLimits"; +import controlLimits from "../Classes/controlLimits"; import dataObject from "../Classes/dataObject"; import truncate from "../Functions/truncate"; @@ -18,15 +18,17 @@ function pprimeLimits(inputData: dataObject): controlLimits { let consec_diff_valid: number[] = consec_diff.filter(d => d < consec_diff_ulim); let sigma: number[] = multiply(sd, d3.mean(consec_diff_valid) / 1.128); - return { + return new controlLimits({ keys: inputData.keys, values: val, + numerators: inputData.numerators, + denominators: inputData.denominators, targets: rep(cl, inputData.keys.length), ll99: truncate(subtract(cl, multiply(3, sigma)), {lower: 0}), ll95: truncate(subtract(cl, multiply(2, sigma)), {lower: 0}), ul95: truncate(add(cl, multiply(2, sigma)), {upper: 1}), ul99: truncate(add(cl, multiply(3, sigma)), {upper: 1}) - } + }); } export default pprimeLimits; diff --git a/src/Limit Calculations/run.ts b/src/Limit Calculations/run.ts index 9df56b8..27790e1 100644 --- a/src/Limit Calculations/run.ts +++ b/src/Limit Calculations/run.ts @@ -1,26 +1,29 @@ import * as d3 from "d3"; import rep from "../Functions/rep"; import { divide } from "../Function Broadcasting/BinaryFunctions"; -import controlLimits from "../Type Definitions/controlLimits"; +import controlLimits from "../Classes/controlLimits"; import dataObject from "../Classes/dataObject"; function runLimits(inputData: dataObject): controlLimits { + let useRatio: boolean = (inputData.denominators && inputData.denominators.length > 0); + let ratio: number[] = useRatio + ? divide(inputData.numerators, inputData.denominators) + : inputData.numerators; let denominators: number[] = inputData.denominators; let numerators: number[] = inputData.numerators; - let ratio: number[] = (denominators && denominators.length > 0) - ? divide(numerators, denominators) - : numerators let cl: number = d3.median(ratio); - return { + return new controlLimits({ keys: inputData.keys, values: ratio.map(d => isNaN(d) ? 0 : d), + numerators: useRatio ? inputData.numerators : null, + denominators: useRatio ? inputData.denominators : null, targets: rep(cl, inputData.keys.length), ll99: rep(null, inputData.keys.length), ll95: rep(null, inputData.keys.length), ul95: rep(null, inputData.keys.length), ul99: rep(null, inputData.keys.length) - } + }); } export default runLimits; diff --git a/src/Limit Calculations/s.ts b/src/Limit Calculations/s.ts index 46de0ca..77e5f93 100644 --- a/src/Limit Calculations/s.ts +++ b/src/Limit Calculations/s.ts @@ -3,7 +3,7 @@ import { b3, b4 } from "../Functions/Constants"; import rep from "../Functions/rep"; import { sqrt } from "../Function Broadcasting/UnaryFunctions"; import { subtract, pow, multiply, divide } from "../Function Broadcasting/BinaryFunctions"; -import controlLimits from "../Type Definitions/controlLimits"; +import controlLimits from "../Classes/controlLimits"; import dataObject from "../Classes/dataObject"; import plotKey from "../Type Definitions/plotKey"; @@ -42,7 +42,7 @@ function sLimits(inputData: dataObject): controlLimits { let B3: number[] = b3(count_per_group); let B4: number[] = b4(count_per_group); - return { + return new controlLimits({ keys: unique_groups, values: group_sd, targets: rep(cl, unique_groups.length), @@ -50,7 +50,7 @@ function sLimits(inputData: dataObject): controlLimits { ll95: multiply(cl, multiply(divide(B3, 3), 2)), ul95: multiply(cl, multiply(divide(B4, 3), 2)), ul99: multiply(cl, B4) - } + }); } export default sLimits; diff --git a/src/Limit Calculations/t.ts b/src/Limit Calculations/t.ts index 34d6363..aaa218f 100644 --- a/src/Limit Calculations/t.ts +++ b/src/Limit Calculations/t.ts @@ -1,6 +1,6 @@ import iLimits from "./i" import { pow } from "../Function Broadcasting/BinaryFunctions"; -import controlLimits from "../Type Definitions/controlLimits"; +import controlLimits from "../Classes/controlLimits"; import dataObject from "../Classes/dataObject"; import truncate from "../Functions/truncate"; diff --git a/src/Limit Calculations/u.ts b/src/Limit Calculations/u.ts index 2c86b98..06dcc6c 100644 --- a/src/Limit Calculations/u.ts +++ b/src/Limit Calculations/u.ts @@ -2,7 +2,7 @@ import * as d3 from "d3"; import rep from "../Functions/rep"; import { sqrt } from "../Function Broadcasting/UnaryFunctions"; import { subtract, add, divide, multiply } from "../Function Broadcasting/BinaryFunctions"; -import controlLimits from "../Type Definitions/controlLimits"; +import controlLimits from "../Classes/controlLimits"; import dataObject from "../Classes/dataObject"; import truncate from "../Functions/truncate"; @@ -10,15 +10,17 @@ function uLimits(inputData: dataObject): controlLimits { let cl: number = divide(d3.sum(inputData.numerators),d3.sum(inputData.denominators)); let sigma: number[] = sqrt(divide(cl,inputData.denominators)); - return { + return new controlLimits({ keys: inputData.keys, values: divide(inputData.numerators, inputData.denominators), + numerators: inputData.numerators, + denominators: inputData.denominators, targets: rep(cl, inputData.keys.length), ll99: truncate(subtract(cl, multiply(3, sigma)), {lower: 0}), ll95: truncate(subtract(cl, multiply(2, sigma)), {lower: 0}), ul95: add(cl, multiply(2, sigma)), ul99: add(cl, multiply(3, sigma)) - } + }) } export default uLimits; diff --git a/src/Limit Calculations/uprime.ts b/src/Limit Calculations/uprime.ts index 5f8be23..deffe99 100644 --- a/src/Limit Calculations/uprime.ts +++ b/src/Limit Calculations/uprime.ts @@ -3,7 +3,7 @@ import rep from "../Functions/rep"; import diff from "../Functions/diff"; import { abs, sqrt } from "../Function Broadcasting/UnaryFunctions"; import { subtract, add, divide, multiply } from "../Function Broadcasting/BinaryFunctions"; -import controlLimits from "../Type Definitions/controlLimits"; +import controlLimits from "../Classes/controlLimits"; import dataObject from "../Classes/dataObject"; import truncate from "../Functions/truncate"; @@ -18,15 +18,17 @@ function uprimeLimits(inputData: dataObject): controlLimits { let consec_diff_valid: number[] = consec_diff.filter(d => d < consec_diff_ulim); let sigma: number[] = multiply(sd, d3.mean(consec_diff_valid) / 1.128); - return { + return new controlLimits({ keys: inputData.keys, values: val, + numerators: inputData.numerators, + denominators: inputData.denominators, targets: rep(cl, inputData.keys.length), ll99: truncate(subtract(cl, multiply(3,sigma)), {lower: 0}), ll95: truncate(subtract(cl, multiply(2,sigma)), {lower: 0}), ul95: add(cl, multiply(2,sigma)), ul99: add(cl, multiply(3,sigma)) - } + }); } export default uprimeLimits; diff --git a/src/Limit Calculations/xbar.ts b/src/Limit Calculations/xbar.ts index d3162c6..7c28a4d 100644 --- a/src/Limit Calculations/xbar.ts +++ b/src/Limit Calculations/xbar.ts @@ -3,7 +3,7 @@ import { a3 } from "../Functions/Constants"; import rep from "../Functions/rep"; import { sqrt } from "../Function Broadcasting/UnaryFunctions" import { pow, subtract, add, multiply, divide } from "../Function Broadcasting/BinaryFunctions"; -import controlLimits from "../Type Definitions/controlLimits"; +import controlLimits from "../Classes/controlLimits"; import dataObject from "../Classes/dataObject"; import plotKey from "../Type Definitions/plotKey"; @@ -51,7 +51,7 @@ function xbarLimits(inputData: dataObject): controlLimits { // Sample-size dependent constant let A3: number[] = a3(count_per_group); - return { + return new controlLimits({ keys: unique_groups, values: group_means, targets: rep(cl, unique_groups.length), @@ -60,7 +60,7 @@ function xbarLimits(inputData: dataObject): controlLimits { ul95: add(cl, multiply(multiply(divide(A3, 3), 2), sd)), ul99: add(cl, multiply(A3, sd)), count: count_per_group - } + }) } export default xbarLimits; diff --git a/src/Type Definitions/controlLimits.ts b/src/Type Definitions/controlLimits.ts deleted file mode 100644 index 846b6c7..0000000 --- a/src/Type Definitions/controlLimits.ts +++ /dev/null @@ -1,14 +0,0 @@ -import plotKey from "./plotKey" - -type controlLimits = { - keys: plotKey[]; - values: number[]; - targets: number[]; - ll99: number[]; - ll95: number[]; - ul95: number[]; - ul99: number[]; - count?: number[]; -} - -export default controlLimits diff --git a/src/visual.ts b/src/visual.ts index d402a6b..7bf0619 100644 --- a/src/visual.ts +++ b/src/visual.ts @@ -71,18 +71,21 @@ export class Visual implements IVisual { this.svgSelections = new svgSelectionClass({ svgObjects: this.svgObjects, viewModel: this.viewModel}); + console.log("Made svgSelections") this.plotProperties = new plotPropertiesClass({ options: options, viewModel: this.viewModel, inputSettings: this.settings }); + console.log("Made plot properties") console.log(this.plotProperties) this.svg.attr("width", this.plotProperties.width) .attr("height", this.plotProperties.height); + console.log("start tooltip") this.initTooltipTracking(); console.log("finish tooltip") @@ -186,7 +189,7 @@ export class Visual implements IVisual { if (this.viewModel.displayPlot) { xAxis.tickFormat(d => this.viewModel.tickLabels[d].label) } - + console.log("x-axis width: ", this.plotProperties.width) console.log("x-axis height: ", this.plotProperties.height)