Ronny Alvarado, environmental geologist and full stack software engineer.
GitHub: https://github.com/RonnySAlvarado
LinkedIn: https://www.linkedin.com/in/ronnysalvarado/
https://websocket-data-charts-renderer.netlify.com/
- React / React Hooks
- React Router
- Styled-Components
- Recharts
- React Toastify
- React Loader Spinner
- Socket-io Client
- React Testing Library
In order to begin running this application, there are a few steps that must be taken.
Assuming you have this repository cloned and on your local machine, you must install the project dependencies at the root of the project as well as within the client folder. You may install them with the following:
yarn install
or
npm install
Once dependencies have been installed, you will have to run the React client. Proceed to cd into the client folder and then run the following:
yarn start
or
npm run start
Once the React client is finished loading, enjoy the content! See below for instructions on how to use the app.
If you decide you want to test the server locally, you may also go to the root of the project and run the following:
yarn start
or
npm run start
Upon entering the site, the contents of the page will fade in (5 seconds) and will render a button that will allow you to access the /dashboard page. This page will consist of the application itself.
Upon clicking the button, a socket.io connection will be established and listening for emits and a Loader component will render and will render until the first data point comes in from our backend. Once that data point comes in, the Loader component will unmount and our graphs components will mount.
This graph will show an X-axis that consists of a timestamp and the Y-axis will consist the incoming data value coming in. The incoming data values come in at random intervals with random numbers (constraints on these are located within the backend). The user of the application will then be able to the graph being updated based on when a new piece of data value comes in.
The user may also set a threshold so they can get notified of when the incoming data value is greater than the threshold that has been set. The input field will render a warning if a user types in non-number characters as well as numbers that are above or below -100 and 100. An error will also show if they try to submit a threshold with a non-number value. When the threshold is exceed, a ToastContainer component will render to the screen and will display our message and value and will unmount after 3 seconds.
The user may also choose to update the threshold if they choose and the threshold line will update.
The user may also choose to remove the threshold completely if they want to remove a threshold.
This graph will show an X-axis that consists of a range of numbers in increments of 10 beginning from -100 to 100. The Y-axis is the total count each time an incoming data value is within that specific range.
- Please don’t fork/branch or create pull-request from the repository.
- Clone it and email your solution back to us when you’re done.You have a server which returns random numbers via WebSocket (socket.io) connection.
You should implement the next:
- A line chart:
- x-axis: time of a received number (look at
timestamppayload field) - y-axis: number values
- x-axis: time of a received number (look at
- A bar chart:
- x-axis: range categories (e.g.
-10 - 0,0 - 10,10 - 20etc) - y-axis: the amount of numbers in each category
- x-axis: range categories (e.g.
- (Optional) An input called "Alert threshold":
- a user should be able to enter a number
- if the random number received from the server is greater than the threshold - show an alert toast / snackbar with the number as the payload
- Design: we appreciate your own design decisions =)
Charts should be updated in real time. Please, consider code style best practices.
- React
- Use socket.io-client to connect to the server
- That’s all
P.S. Feel free to use any module bundler, charts package, UI-kit etc you want. BUT please, leave some notes about the project setup.
- Install NodeJS
- In the project root folder run
yarn/npm install - Add
.envfile with the specified PORT (3000by default) env variable (look at.env.samplefile) - Run
yarn start/npm start - Now you can connect to the server via socket.io-client:
- listen for
dataevent - the payload format is
{ value: <float>, timestamp: <integer> }
- listen for