Turns CSVs into graphs in a few simple steps; embeds onto other websites!
- Clone this repository to your local environment.
git clone https://github.com/publiclab/simple-data-grapher
- Run
npm install
to install all the necessary packages required. - Open
examples/index.html
in your browser to look at the preview of the library.
- Make the changes you are working on in respective /src files.
- After doing or while doing the changes run
npm run build
for making the changes in thedist/
. - Run
npm run test
to run the tests. - Test your changes on a browser by opening
examples/index.html
. - For finding linting issues run
npm run lint
We are using babel
to transpile code into es5 and browserify
to require
different files and watch
to watch the changes and build the changes.
For testing we are using mocha
.
-
View.js: First reads the input files through the event listeners and sends the file to Csvparser.js, then once the required information is received, it displays a sample of the data. It then takes the selected data by the user, through the
afterSampleData()
method, and goes to the plotting library, and displays the graph. -
Csvparser.js: Receives the file and it's format type and:
- Parses the CSV
- Determines headers
- Determines a matrix for the complete data
- Extracts sample data to be displayed to the user for selection
- Creates a transpose of the data
-
PlotlyjsPlotter.js (default) or ChartjsPlotter.js: Assembles the received data according to its format and plots the graph on the canvas element.
-
Add Graph: It is checked at
showSampleDataXandY()
, where the number of currently plotted graphs is incremented and it is sent as a flag, where the newly plotted graph has to be appended in the chart area, and not clear the canvas. -
Create Spreadsheet: Uses the transpose created by Csvparser.js and creates a (excel or xlsx) spreadsheet using
SheetJS
and downloads it. -
CODAP Export: CODAP is used here to view the CSV data in a proper tabular form. From there, the user can view a summary of their data, view a more readable form of it and use other tools that CODAP's Plugin API offers. The user can also export their data as a CSV directly to their Google Drive.
I created an adapter function
which can easily switch between the two charting libraries, as one can be advantageous over the other in different situations.
- Plotlyjs is more extensively used than Chartjs
- Plotlyjs provides options like:
- Zooming
- Panning
- Autoscaling
- Downloading the graph as an image
- Box and Lasso select
- Edit graph in Plotlyjs editor
- Chartjs:
- Better comparison
- Better color scheme and design
- More informative tooltips
The basic flow remains the same as in the standalone library.
-
Save the data: The user can save their uploaded CSV and use it later for plotting.
-
Using previously uploaded data for plotting: Users can use their previously uploaded files for plotting in simple-data-grapher.
-
Associate a file title and description with the uploaded data.
-
Per-User Data Page: Lists down all the files a user has saved, their title & description. The user can delete as well as download the files.
The user can publish their plotted charts as a Research Note on Public Lab and discuss their findings.