User-(a)nalysis charts user data generated from Random User Generator.
Usernalysis is an ASP.Net MVC application developed primarily using C# and javascript. It is built with Visual Studio 2017 Community. To run the app, open the Usernalysis.sln
solution file in the project root using Visual Studio and Debug/Start from the IDE.
An instance of Usernalysis is available on Heroku: https://usernalysis.herokuapp.com/
Submit users data to the app either through file upload or pasting the users data into the provided text input field. Users data must be formatted in JSON.
The set of users must be defined in the results
property.
Sample data extracts from Random User Generator can be found here:
- 100 US-Based Users with all properties
- 5,000 US-Based Users with all properties
- 50,000 US-Based Users with only gender, name, location, and dob properies
{
"results": [
{
"gender": "male",
"name": {
"title": "mr",
"first": "rolf",
"last": "hegdal"
},
"location": {
"street": "123 fake street",
"city": "new york",
"state": "new york",
"postcode": "10001"
},
"dob": {
"date": "1975-11-12T06:34:44Z",
"age": 42
}
},{
"gender": "female",
"name": {
"title": "ms",
"first": "jean",
"last": "berry"
},
"location": {
"street": "456 rodeo drive",
"city": "beverly hills",
"state": "california",
"postcode": "90210"
},
"dob": {
"date": "2005-11-12T06:34:44Z",
"age": 13
}
}
]
}
Once submitted, the web app will render charts with the following analyses
- Percentage female versus male
- Percentage of first names and last names that start with A‐M versus N‐Z
- Percentage of people in each state, up to the top 10 most populous states
- Percentage of females in each state, up to the top 10 most populous states
- Percentage of males in each state, up to the top 10 most populous states
- Percentage of people in the following age ranges: 0‐20, 21‐40, 41‐60, 61‐80, 81‐100, 100+
- Top 10 states with the highest average age
Charts related to states contain choropleth maps as an alternative illustration of the data. A switch on the upper-left hand corner of these charts controls the toggle between chart and map.
Since the map is restricted to the United States, it's best to send data with US-based users. For example, users generated by this request:
https://randomuser.me/api/?results=100&nat=us
Raw analysis data is available on the following REST API endpoint:
/api/useranalysis
The endpoint accepts POST
requests with the JSON-formatted user data in the body of the request or as an uploaded file.
The API can output the analysis in 3 formats:
- plaintext (default)
- json
- xml
Clients can specify the desired format with the request header or the format
querystring parameter.
Set the value for Accept
to:
text/plain
for plaintextapplication/json
for jsonapplication/xml
for xml
Request header format specification takes precedence over the querystring parameter.
Set the value for format
to:
text
for plaintextjson
for jsonxml
for xml
Example:
https://usernalysis.herokuapp.com/api/useranalysis?format=xml
$.ajax({
url: 'https://usernalysis.herokuapp.com/api/useranalysis',
dataType: 'json',
type: 'POST',
contentType: 'application/json',
data: <YOUR USER JSON>,
success: function(response) {
console.log(response);
}
});
Spacing, indenting, and formatting for this web app relies heavily on Visual Studio's default macros for respective front-end (html, css, js) and back-end (C#) files.
Front-end naming and additional coding styles follow conventions outlined by w3schools. Back-end C# code follows microsoft.