Published
Edited
Dec 31, 2021
Importers
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
reduceScorecardsToFOWs = (scorecardArray, inningFilterFn) => {
const fowArray = scorecardArray.reduce((accumulator, card, index, array) => {
const desc = card.description.split(',');
const result = card.result.toLowerCase().indexOf("india won") !== -1 ? "India won" : card.result;
const test = isNaN(desc[0].trim()[0]) ? 1 : parseInt(desc[0].trim()[0]);
const series_name = desc[desc.length - 1].trim();
let reduceResult = Array.from(accumulator)
for (let idx = 0; idx < card.innings.length; ++idx) {
const inning = card.innings[idx];
const inningDesc = inning.description;
// if (inningDesc.toLowerCase().indexOf("india") === -1) {
if (inningFilterFn(inning)) {
const inningCount = Math.floor(idx/2) + 1;
const inningData = {fow: inning.fow, series_name: `${series_name}`, innings: inningCount, test: test, result: result};
reduceResult.push(inningData);
}
}
return reduceResult;
}, []);
return fowArray
}
Insert cell
import {lineSeries, getColorFromMap, colorSchemes} from "@c0f6a5e2dc48f148/englands-fall-of-wickets-in-2021-test-cricket"
Insert cell
require("d3-scale-chromatic@3")
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