From 6c7093b6ff608b99378c150783e0912a6251d7b9 Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 17 Nov 2020 12:41:01 +0000 Subject: [PATCH 1/4] proof of concept for cost table --- mint/Impact.vue | 6 +++--- mint/ImpactTable.vue | 31 +++++++++++++++++++++---------- mint/fakeAPIData.ts | 36 +++++++++++++++++++++++++----------- mint/index.ts | 1 + mint/longFormatDataSeries.ts | 1 - 5 files changed, 50 insertions(+), 25 deletions(-) diff --git a/mint/Impact.vue b/mint/Impact.vue index 313046a..d196058 100644 --- a/mint/Impact.vue +++ b/mint/Impact.vue @@ -28,7 +28,7 @@ :layout="cases.layout">
- +
@@ -36,7 +36,7 @@ import Vue from "vue"; import ImpactTable from "./ImpactTable.vue"; - import {casesAvertedGraph, columns, prevGraph, settings, wideData} from "./fakeAPIData"; + import {casesAvertedGraph, prevGraph, settings, tableConfig, wideData} from "./fakeAPIData"; import PlotlyGraph from "./PlotlyGraph.vue"; export default Vue.extend({ @@ -44,7 +44,7 @@ data() { return { settings: settings, - columns: columns, + tableConfig: tableConfig, wideData: wideData, longData: [] as any[], prevalence: prevGraph, diff --git a/mint/ImpactTable.vue b/mint/ImpactTable.vue index 15cd234..79200ed 100644 --- a/mint/ImpactTable.vue +++ b/mint/ImpactTable.vue @@ -2,13 +2,13 @@ - + - @@ -17,19 +17,30 @@ \ No newline at end of file + diff --git a/mint/fakeAPIData.ts b/mint/fakeAPIData.ts index ccd5dcb..a5634ae 100644 --- a/mint/fakeAPIData.ts +++ b/mint/fakeAPIData.ts @@ -1,4 +1,6 @@ // this is the table data that would be returned after the baseline inputs are set +import {Dictionary} from "vuex"; + export const wideData = [ { "intervention": "none", @@ -203,17 +205,28 @@ export const wideData = [ } ]; -export const columns = - { - "intervention": "Intervention", - "net_use": "Net use", - "prev_year_1": "Prevalence Under 5 yrs: Yr 1 post intervention", - "prev_year_2": "Prevalence Under 5 yrs: Yr 2 post intervention", - "prev_year_3": "Prevalence Under 5 yrs: Yr 3 post intervention", - "cases_averted": "Cases averted across 3 yrs since intervention", - "cases_averted_high": "Upper bound for cases averted", - "cases_averted_low": "Lower bound for cases averted" - }; +export const tableConfig: ColumnDefinition[] = + [ + {displayName: "Intervention", valueCol: "intervention"}, + {displayName: "Net use", valueCol: "net_use"}, + {displayName: "Prevalence Under 5 yrs: Yr 1 post intervention", valueCol: "prev_year_1"}, + { + displayName: "Total costs", + valueCol: "intervention", + valueFormula: { + "none": "({population} / {procure_people_per_net}) * {price_net_standard}", + "ITN": "({population} / {procure_people_per_net}) * {price_net_standard} + ({price_delivery} * {population} * (({procure_buffer} + 100)/ 100))", + "IRS": "({population} / {procure_people_per_net}) * {price_net_standard} + 3 * ({price_irs_per_person} * {population})", + "IRS + ITN": "({population} / {procure_people_per_net}) * {price_net_standard} + ({price_delivery} * {population} * (({procure_buffer} + 100) / 100)) + 3 * ({price_irs_per_person} * {population})" + } + } + ]; + +export interface ColumnDefinition { + displayName: string + valueCol: string + valueFormula?: Dictionary +} export interface SeriesDefinition { x?: any[] @@ -222,6 +235,7 @@ export interface SeriesDefinition { id?: string, name?: string, type?: string + [propName: string]: any; } diff --git a/mint/index.ts b/mint/index.ts index e1f8e65..0bfd502 100644 --- a/mint/index.ts +++ b/mint/index.ts @@ -14,3 +14,4 @@ new Vue({ Cost } }); + diff --git a/mint/longFormatDataSeries.ts b/mint/longFormatDataSeries.ts index e1dce5d..a5502b3 100644 --- a/mint/longFormatDataSeries.ts +++ b/mint/longFormatDataSeries.ts @@ -3,7 +3,6 @@ import {LongFormatSeriesMetadata, SeriesDefinition, SeriesMetadata, WideFormatSe import {FilteringProps, useFiltering} from "./filteredData"; import {Dictionary} from "vuex"; import {useTransformation} from "./tranformedData"; -import {def} from "@vue/composition-api/dist/utils"; interface Props extends FilteringProps { series: SeriesDefinition[] From 2dba11c4d69934dbea539a6b75b4b081a8ae5cb1 Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 17 Nov 2020 12:42:34 +0000 Subject: [PATCH 2/4] rename table --- mint/{ImpactTable.vue => DynamicTable.vue} | 0 mint/Impact.vue | 6 +++--- 2 files changed, 3 insertions(+), 3 deletions(-) rename mint/{ImpactTable.vue => DynamicTable.vue} (100%) diff --git a/mint/ImpactTable.vue b/mint/DynamicTable.vue similarity index 100% rename from mint/ImpactTable.vue rename to mint/DynamicTable.vue diff --git a/mint/Impact.vue b/mint/Impact.vue index d196058..864cac3 100644 --- a/mint/Impact.vue +++ b/mint/Impact.vue @@ -28,19 +28,19 @@ :layout="cases.layout">
- +
{{columns[key]}}{{col.displayName}}
- {{cell}} + + {{evaluateCell(col, row)}}