Skip to content

Commit 0bc3b8d

Browse files
committedNov 18, 2020
Added a warning if the number of nodes is too large, and also removed page
numbers from the sources.
1 parent 641974c commit 0bc3b8d

9 files changed

+168
-37
lines changed
 

‎python/load_data.ipynb

+61-14
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": null,
5+
"execution_count": 1,
66
"metadata": {},
77
"outputs": [],
88
"source": [
@@ -18,7 +18,7 @@
1818
},
1919
{
2020
"cell_type": "code",
21-
"execution_count": null,
21+
"execution_count": 2,
2222
"metadata": {},
2323
"outputs": [],
2424
"source": [
@@ -34,7 +34,7 @@
3434
},
3535
{
3636
"cell_type": "code",
37-
"execution_count": null,
37+
"execution_count": 3,
3838
"metadata": {},
3939
"outputs": [],
4040
"source": [
@@ -50,7 +50,7 @@
5050
},
5151
{
5252
"cell_type": "code",
53-
"execution_count": null,
53+
"execution_count": 4,
5454
"metadata": {},
5555
"outputs": [],
5656
"source": [
@@ -66,7 +66,7 @@
6666
},
6767
{
6868
"cell_type": "code",
69-
"execution_count": null,
69+
"execution_count": 5,
7070
"metadata": {
7171
"scrolled": false
7272
},
@@ -79,9 +79,19 @@
7979
},
8080
{
8181
"cell_type": "code",
82-
"execution_count": null,
83-
"metadata": {},
84-
"outputs": [],
82+
"execution_count": 6,
83+
"metadata": {},
84+
"outputs": [
85+
{
86+
"name": "stdout",
87+
"output_type": "stream",
88+
"text": [
89+
"Is W. E. Acraman the same person as William Edward Acraman? (y/n) y\n",
90+
"Is Mr. Levy the same person as Levy? (y/n) y\n",
91+
"Is Mr. Warr the same person as Warr? (y/n) y\n"
92+
]
93+
}
94+
],
8595
"source": [
8696
"social.load_graph(project=\"Great Britain\", \n",
8797
" nodes_filepath=\"input/gb_nodes.xlsx\", \n",
@@ -90,9 +100,19 @@
90100
},
91101
{
92102
"cell_type": "code",
93-
"execution_count": null,
94-
"metadata": {},
95-
"outputs": [],
103+
"execution_count": 7,
104+
"metadata": {},
105+
"outputs": [
106+
{
107+
"name": "stdout",
108+
"output_type": "stream",
109+
"text": [
110+
"Is W. Barber the same person as William Barber? (y/n) n\n",
111+
"Is Alexander S. Ross the same person as Alexander M. Ross? (y/n) n\n",
112+
"Is Mr. Lucas the same person as Miss. Lucas? (y/n) n\n"
113+
]
114+
}
115+
],
96116
"source": [
97117
"social.load_graph(project=\"Great Eastern\", \n",
98118
" nodes_filepath=\"input/ge_nodes.xlsx\", \n",
@@ -108,9 +128,36 @@
108128
},
109129
{
110130
"cell_type": "code",
111-
"execution_count": null,
112-
"metadata": {},
113-
"outputs": [],
131+
"execution_count": 8,
132+
"metadata": {},
133+
"outputs": [
134+
{
135+
"name": "stdout",
136+
"output_type": "stream",
137+
"text": [
138+
"\n",
139+
"No match for Birch, C. Bagster. Nearest matches are:\n",
140+
"1: Person(C. Birch Bagster)\n",
141+
"Is this the right person (y/n)?y\n",
142+
"\n",
143+
"No match for Fox Henderson & Co.. Nearest matches are:\n",
144+
"1: Business(Fox, Henderson & Co)\n",
145+
"Is this the right person (y/n)?y\n",
146+
"There is already a biography for Person(George Gibbs)\n",
147+
"\n",
148+
"No match for J. Abbotts & Co.. Nearest matches are:\n",
149+
"1: Business(J. Abbots & Co.)\n",
150+
"Is this the right person (y/n)?y\n",
151+
"There is nothing called J. S. Russell & Sons for which to give a biography!\n",
152+
"There is already a biography for Person(Reverend Septimus Jones)\n",
153+
"There is nothing called Nasmyth, James for which to give a biography!\n",
154+
"\n",
155+
"No match for Woods Bros.. Nearest matches are:\n",
156+
"1: Business(Woods Bros)\n",
157+
"Is this the right person (y/n)?y\n"
158+
]
159+
}
160+
],
114161
"source": [
115162
"social.load_biographies(\"input/datakey.xlsx\", sheet_name=\"Node Bio's\")"
116163
]

‎src/SocialApp.js

+23-16
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import BioOverlay from "./components/BioOverlay";
1414
import ShipOverlay from "./components/ShipOverlay";
1515
import SlidingPanel from "./components/SlidingPanel";
1616
import MainMenu from "./components/MainMenu";
17+
import WarningOverlay from "./components/WarningOverlay";
1718

1819
import HBox from "./components/HBox";
1920
import VBox from "./components/VBox";
@@ -51,22 +52,6 @@ class SocialApp extends React.Component {
5152
social = new Social();
5253
}
5354

54-
let j = social.getPeople().find("Joshua Field");
55-
console.log(j);
56-
57-
let c = social.getConnections().getConnectionsInvolving(j);
58-
console.log(c);
59-
60-
c.forEach((value) => {
61-
Object.keys(value.getAffiliationSources()).forEach((k) => {
62-
console.log(social.get(k).getName());
63-
})
64-
Object.keys(value.getCorrespondanceSources()).forEach((k) => {
65-
console.log(social.get(k).getName());
66-
})
67-
});
68-
69-
7055
this.updateSize = this.updateSize.bind(this);
7156

7257
this.state = {
@@ -91,6 +76,7 @@ class SocialApp extends React.Component {
9176
menuVisible: false,
9277
height: 0,
9378
width: 0,
79+
warningVisible: true,
9480
};
9581

9682

@@ -555,6 +541,10 @@ class SocialApp extends React.Component {
555541
});
556542
}
557543

544+
slotCloseWarning() {
545+
this.setState({ warningVisible: false });
546+
}
547+
558548
slotShowMenu() {
559549
this.setState({ menuVisible: true });
560550
}
@@ -813,6 +803,22 @@ class SocialApp extends React.Component {
813803
</SlidingPanel>
814804
);
815805

806+
// make sure that we don't have too many nodes...
807+
let nnodes = this.state.social.getGraph().nodes.length;
808+
809+
let warning_popover = null;
810+
811+
if (this.state.warningVisible && nnodes > 50) {
812+
warning_popover = (
813+
<Overlay useBackground={false} toggleOverlay={() => { this.slotCloseWarning() }}>
814+
<WarningOverlay close={() => { this.slotCloseWarning() }}>
815+
As you can see, this is a busy network. Using filters will allow you
816+
to examine the network more closely.
817+
</WarningOverlay>
818+
</Overlay>
819+
);
820+
}
821+
816822
return (
817823
<div>
818824
{mainmenu}
@@ -836,6 +842,7 @@ class SocialApp extends React.Component {
836842
</VBox>
837843
</div>
838844
{overlay}
845+
{warning_popover}
839846
</div>
840847
);
841848
}

‎src/SocialApp.module.css

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@
2121

2222
.fullscreen {
2323
height: 100%;
24-
}
24+
}
25+

‎src/components/BioOverlay.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ function BioOverlay(props) {
7777
source_parts.push(
7878
<li key={source.getID()}
7979
className={styles.source_item}>
80-
<span className={styles.source_name}>{source.getName()}</span>&nbsp;
80+
<span className={styles.source_name}>{source.getName(true)}</span>&nbsp;
8181
{source.getDescription()}
8282
</li>
8383
);

‎src/components/Overlay.module.css

+6
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@
1212
.overlayNoBackground {
1313
position: fixed;
1414
background: transparent;
15+
z-index: 10;
16+
width: 99%;
17+
height: 99%;
18+
left: 0.5%;
19+
top: 0.5%;
20+
border-radius: 10px;
1521
}
1622

1723
.container {

‎src/components/WarningOverlay.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import PropTypes from "prop-types";
2+
import React from "react";
3+
4+
import styles from "./WarningOverlay.module.css";
5+
6+
function WarningOverlay(props) {
7+
return (
8+
<div className={styles.container} onClick={props.close}>
9+
<div className={styles.content}>
10+
{props.children}
11+
</div>
12+
</div>
13+
);
14+
}
15+
16+
WarningOverlay.propTypes = {
17+
close: PropTypes.func.isRequired,
18+
children: PropTypes.any.isRequired,
19+
};
20+
21+
export default WarningOverlay;
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
.container {
2+
position: absolute;
3+
width: 98%;
4+
left: 1%;
5+
bottom: 50px;
6+
opacity: 1;
7+
background-color: transparent;
8+
z-index: 11;
9+
display: flex;
10+
flex-direction: column;
11+
overflow: hidden;
12+
box-sizing: border-box;
13+
padding: 5px;
14+
border-radius: 10px;
15+
}
16+
17+
.content {
18+
box-sizing: border-box;
19+
padding: 20px;
20+
align-content: stretch;
21+
overflow-y: auto;
22+
overflow-x: hidden;
23+
background-color: #E63309;
24+
color: white;
25+
margin-left: auto;
26+
margin-right: auto;
27+
margin-top: 2px;
28+
margin-bottom: 2px;
29+
max-width: 300px;
30+
border-radius: 10px;
31+
text-align: center;
32+
}

‎src/components/d3/ForceGraph.d3.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -276,13 +276,15 @@ class ForceGraphD3 extends React.Component {
276276
)
277277
// Here size is the weight given to that entity
278278
.attr("r", (d) => {
279+
d.radius = Math.min(30, 5 + (0.5 * (d.size * d.size)));
280+
279281
if (d.size < 1.5) {
280-
d.radius = 3;
282+
//d.radius = 3;
281283
}
282284
else if (d.size < 2.0) {
283-
d.radius = 6 + d.size;
285+
//d.radius = 6 + d.size;
284286
} else {
285-
d.radius = 12 + 2 * d.size;
287+
//d.radius = 12 + 2 * d.size;
286288
}
287289
return d.radius;
288290
})

‎src/model/Source.js

+17-2
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,23 @@ class Source {
9797
return `Source(${this.getName()})`;
9898
}
9999

100-
getName() {
101-
return this.state.name;
100+
getName(remove_page_numbers = false) {
101+
if (remove_page_numbers) {
102+
let name = this.state.name;
103+
104+
if (name.includes("-")) {
105+
name = name.split("-")[0];
106+
}
107+
108+
if (name.includes(",")) {
109+
name = name.split(",")[0];
110+
}
111+
112+
return name;
113+
}
114+
else {
115+
return this.state.name;
116+
}
102117
}
103118

104119
getDescription() {

0 commit comments

Comments
 (0)