-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from code4policy/ayush
Added funding patterns page
- Loading branch information
Showing
12 changed files
with
5,324 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Metric,year,Val | ||
7a,2018,25372539100 | ||
7a,2019,23175811000 | ||
7a,2020,22549825700 | ||
7a,2021,36536756800 | ||
7a,2022,25693805700 | ||
7a,2023,27515666000 | ||
504,2018,4753644000 | ||
504,2019,4958542000 | ||
504,2020,27515666000 | ||
504,2021,8218105540 | ||
504,2022,9207996290 | ||
504,2023,6419378000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Metric,year,Avg | ||
7a,2018,420395.3193 | ||
7a,2019,446487.1983 | ||
7a,2020,533118.0127 | ||
7a,2021,704581.0861 | ||
7a,2022,538902.7581 | ||
7a,2023,479684.5647 | ||
504,2018,809268.6415 | ||
504,2019,813009.0179 | ||
504,2020,3865102.683 | ||
504,2021,849328.8074 | ||
504,2022,995028.7757 | ||
504,2023,1083622.215 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Metric,year,Count | ||
7a,2018,60354 | ||
7a,2019,51907 | ||
7a,2020,42298 | ||
7a,2021,51856 | ||
7a,2022,47678 | ||
7a,2023,57362 | ||
504,2018,5874 | ||
504,2019,6099 | ||
504,2020,7119 | ||
504,2021,9676 | ||
504,2022,9254 | ||
504,2023,5924 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Grouped Bar Chart with D3.js</title> | ||
<script src="https://d3js.org/d3.v6.min.js"></script> | ||
</head> | ||
<body> | ||
<svg id="values" width="960" height="500"></svg> | ||
<h2>Average Ticket Size of Approved Loans</h2> | ||
<svg id="avg" width="960" height="500"></svg> | ||
<h2>Count of Approved Loans</h2> | ||
<svg id="count" width="960" height="550"></svg> | ||
</body> | ||
<script src="script.js"></script> | ||
<script src="script_count.js"></script> | ||
<script src="script_avg.js"></script> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// Set the dimensions and margins of the chart | ||
(function () { | ||
|
||
const margin = {top: 60, right: 60, bottom: 70, left: 80}, | ||
width = 960 - margin.left - margin.right, | ||
height = 500 - margin.top - margin.bottom; | ||
|
||
// Append the svg object to the body of the page | ||
const svg = d3.select("#values") | ||
.attr("width", width + margin.left + margin.right) | ||
.attr("height", height + margin.top + margin.bottom) | ||
.append("g") | ||
.attr("transform", `translate(${margin.left},${margin.top})`); | ||
|
||
svg.append("text") | ||
.attr("x", width / 2) | ||
.attr("y", 0 - (margin.top / 2)) | ||
.attr("text-anchor", "middle") | ||
.style("font-size", "16px") | ||
.style("text-decoration", "underline") | ||
.text("Approved Loan Values"); | ||
|
||
|
||
// Read the data from the CSV file | ||
d3.csv("SBA_Approved_Loan_Values.csv").then(function(data) { | ||
// Extract unique metrics and years | ||
const metrics = [...new Set(data.map(d => d.Metric))]; | ||
|
||
const years = [...new Set(data.map(d => d.year))]; | ||
|
||
// Create a group for each metric | ||
const x0 = d3.scaleBand() | ||
.domain(metrics) | ||
.rangeRound([0, width]) | ||
.paddingInner(0.1); | ||
svg.append("g") | ||
.attr("transform", `translate(0,${height})`) | ||
.call(d3.axisBottom(x0)); | ||
|
||
|
||
// Scale for each year within the metric | ||
const x1 = d3.scaleBand() | ||
.domain(years) | ||
.rangeRound([0, x0.bandwidth()]) | ||
.padding(0.05); | ||
|
||
// Add Y axis | ||
const y = d3.scaleLinear() | ||
.domain([0, d3.max(data, d => +d['Val'])]) | ||
.nice() | ||
.range([height, 0]); | ||
svg.append("g") | ||
.call(d3.axisLeft(y)); | ||
|
||
// Color palette for each year | ||
const color = d3.scaleOrdinal() | ||
.domain(years) | ||
.range(d3.schemeCategory10); | ||
|
||
// Group the data by metric | ||
const groupedData = metrics.map(metric => { | ||
return { | ||
metric: metric, | ||
values: data.filter(d => d.Metric === metric) | ||
}; | ||
}); | ||
|
||
// Add groups for each metric and draw bars | ||
const metricGroups = svg.selectAll(".metric-group") | ||
.data(groupedData) | ||
.enter().append("g") | ||
.attr("class", "metric-group") | ||
.attr("transform", d => `translate(${x0(d.metric)}, 0)`); | ||
|
||
metricGroups.selectAll("rect") | ||
.data(d => years.map(year => { | ||
return { year: year, value: d.values.find(v => v.year === year)?.['Val'] || 0 }; | ||
})) | ||
.enter().append("rect") | ||
.attr("x", d => x1(d.year)) | ||
.attr("y", d => y(d.value)) | ||
.attr("width", x1.bandwidth()) | ||
.attr("height", d => height - y(d.value)) | ||
.attr("fill", d => color(d.year)); | ||
}) | ||
}) | ||
(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
(function () { | ||
|
||
// Set the dimensions and margins of the chart | ||
const margin = {top: 70, right: 60, bottom: 90, left: 80}, | ||
width = 960 - margin.left - margin.right, | ||
height = 500 - margin.top - margin.bottom; | ||
|
||
// Append the svg object to the body of the page | ||
const svg = d3.select("#avg") | ||
.attr("width", width + margin.left + margin.right) | ||
.attr("height", height + margin.top + margin.bottom) | ||
.append("g") | ||
.attr("transform", `translate(100,20)`); | ||
|
||
// Read the data from the CSV file | ||
d3.csv("SBA_Avg_Tkt_Size.csv").then(function(data) { | ||
// Extract unique metrics and years | ||
const metrics = [...new Set(data.map(d => d.Metric))]; | ||
|
||
const years = [...new Set(data.map(d => d.year))]; | ||
|
||
// Create a group for each metric | ||
const x0 = d3.scaleBand() | ||
.domain(metrics) | ||
.rangeRound([0, width]) | ||
.paddingInner(0.1); | ||
svg.append("g") | ||
.attr("transform", `translate(0,${height})`) | ||
.call(d3.axisBottom(x0)); | ||
|
||
|
||
// Scale for each year within the metric | ||
const x1 = d3.scaleBand() | ||
.domain(years) | ||
.rangeRound([0, x0.bandwidth()]) | ||
.padding(0.05); | ||
|
||
// Add Y axis | ||
const y = d3.scaleLinear() | ||
.domain([0, d3.max(data, d => +d['Avg'])]) | ||
.nice() | ||
.range([height, 0]); | ||
svg.append("g") | ||
.call(d3.axisLeft(y)); | ||
|
||
// Color palette for each year | ||
const color = d3.scaleOrdinal() | ||
.domain(years) | ||
.range(d3.schemeCategory10); | ||
|
||
// Group the data by metric | ||
const groupedData = metrics.map(metric => { | ||
return { | ||
metric: metric, | ||
values: data.filter(d => d.Metric === metric) | ||
}; | ||
}); | ||
|
||
// Add groups for each metric and draw bars | ||
const metricGroups = svg.selectAll(".metric-group") | ||
.data(groupedData) | ||
.enter().append("g") | ||
.attr("class", "metric-group") | ||
.attr("transform", d => `translate(${x0(d.metric)}, 0)`); | ||
|
||
metricGroups.selectAll("rect") | ||
.data(d => years.map(year => { | ||
return { year: year, value: d.values.find(v => v.year === year)?.['Avg'] || 0 }; | ||
})) | ||
.enter().append("rect") | ||
.attr("x", d => x1(d.year)) | ||
.attr("y", d => y(d.value)) | ||
.attr("width", x1.bandwidth()) | ||
.attr("height", d => height - y(d.value)) | ||
.attr("fill", d => color(d.year)); | ||
}) | ||
}) | ||
(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
(function () { | ||
|
||
// Set the dimensions and margins of the chart | ||
const margin = {top: 70, right: 60, bottom: 90, left: 80}, | ||
width = 960 - margin.left - margin.right, | ||
height = 500 - margin.top - margin.bottom; | ||
|
||
// Append the svg object to the body of the page | ||
const svg = d3.select("#count") | ||
.attr("width", width + margin.left + margin.right) | ||
.attr("height", height + margin.top + margin.bottom) | ||
.append("g") | ||
.attr("transform", `translate(100,20)`); | ||
|
||
svg.append("text") | ||
.attr("x", width / 2) | ||
.attr("y", 0 - (margin.top / 2)) | ||
.attr("text-anchor", "middle") | ||
.style("font-size", "16px") | ||
.style("text-decoration", "underline") | ||
.text("Avg Ticket Sizes"); | ||
|
||
|
||
// Read the data from the CSV file | ||
d3.csv("SBA_Count_Approved_Loans.csv").then(function(data) { | ||
// Extract unique metrics and years | ||
const metrics = [...new Set(data.map(d => d.Metric))]; | ||
|
||
const years = [...new Set(data.map(d => d.year))]; | ||
|
||
// Create a group for each metric | ||
const x0 = d3.scaleBand() | ||
.domain(metrics) | ||
.rangeRound([0, width]) | ||
.paddingInner(0.1); | ||
svg.append("g") | ||
.attr("transform", `translate(0,${height})`) | ||
.call(d3.axisBottom(x0)); | ||
|
||
|
||
// Scale for each year within the metric | ||
const x1 = d3.scaleBand() | ||
.domain(years) | ||
.rangeRound([0, x0.bandwidth()]) | ||
.padding(0.05); | ||
|
||
// Add Y axis | ||
const y = d3.scaleLinear() | ||
.domain([0, d3.max(data, d => +d['Count'])]) | ||
.nice() | ||
.range([height, 0]); | ||
svg.append("g") | ||
.call(d3.axisLeft(y)); | ||
|
||
// Color palette for each year | ||
const color = d3.scaleOrdinal() | ||
.domain(years) | ||
.range(d3.schemeCategory10); | ||
|
||
// Group the data by metric | ||
const groupedData = metrics.map(metric => { | ||
return { | ||
metric: metric, | ||
values: data.filter(d => d.Metric === metric) | ||
}; | ||
}); | ||
|
||
// Add groups for each metric and draw bars | ||
const metricGroups = svg.selectAll(".metric-group") | ||
.data(groupedData) | ||
.enter().append("g") | ||
.attr("class", "metric-group") | ||
.attr("transform", d => `translate(${x0(d.metric)}, 0)`); | ||
|
||
metricGroups.selectAll("rect") | ||
.data(d => years.map(year => { | ||
return { year: year, value: d.values.find(v => v.year === year)?.['Count'] || 0 }; | ||
})) | ||
.enter().append("rect") | ||
.attr("x", d => x1(d.year)) | ||
.attr("y", d => y(d.value)) | ||
.attr("width", x1.bandwidth()) | ||
.attr("height", d => height - y(d.value)) | ||
.attr("fill", d => color(d.year)); | ||
}) | ||
}) | ||
(); |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters