Public
Edited
Sep 29, 2022
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
input_data = tpx_table.sheet(0,{headers: true})
Insert cell
tpx_table = FileAttachment("tpx_table.xlsx").xlsx()
Insert cell
Insert cell
Insert cell
getLabelPart = (label, partIndex) => label.split(": ")[partIndex]
Insert cell
substractObjects = (r1, r2) => {
return Object.keys(r1).reduce((a, k) => {
a[k] = typeof r1[k] == "string"? r1[k]: (typeof r1[k] != "undefined") && (typeof r2[k] != "undefined")? r1[k] - r2[k]: NaN;
return a;
}, {});
}
Insert cell
Insert cell
input_data_mapped = input_data.map(o => {
return {
touchpoint: getLabelPart(o["Touchpoint Experience"],2),
...o,
quadrant: getLabelPart(o["Touchpoint Experience"],1),
period: getLabelPart(o["Touchpoint Experience"],0)
}
})
Insert cell
Insert cell
input_data_indexed = d3.index(input_data_mapped, o => o.period, o => o.quadrant, o => o.touchpoint)
Insert cell
Insert cell
quadrantsFilterOptions = Array.from ( new Set( input_data_mapped.map(o => o.quadrant) ) )
Insert cell
periods = Array.from ( new Set ( input_data_mapped.map(o => o.period) ) )
Insert cell
periodsFilterOptions = [periods[0], `${periods[0]} vs ${periods[1]}`]
Insert cell
Insert cell
touchpoints = Array.from ( new Set ( input_data_mapped.map(o => o.touchpoint) ) )
Insert cell
forTable = period == periods[0]? touchpoints.map( o => input_data_indexed.get(period).get(quadrant).get(o) ) : touchpoints.map( o => substractObjects( input_data_indexed.get(periods[0]).get(quadrant).get(o), input_data_indexed.get(periods[1]).get(quadrant).get(o) ) )
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more