├── Procfile
├── src
├── PublicLab.Grapher.js
├── sample.js
├── SimpleDataGrapher.js
├── PlotlyjsPlotter.js
├── ChartjsPlotter.js
├── CsvParser.js
└── View.js
├── .gitignore
├── dist
└── transpiled_code
│ ├── PublicLab.Grapher.js
│ ├── sample.js
│ ├── SimpleDataGrapher.js
│ ├── PlotlyjsPlotter.js
│ ├── ChartjsPlotter.js
│ ├── CsvParser.js
│ └── parsing.js
├── .babelrc
├── .github
├── ISSUE_TEMPLATE
│ ├── custom-issue---.md
│ ├── feature-request---.md
│ ├── bug-report----.md
│ └── first-timers-only---------.md
├── PULL_REQUEST_TEMPLATE.md
└── config.yml
├── .eslintrc.js
├── .travis.yml
├── CONTRIBUTING.md
├── CODE_OF_CONDUCT.md
├── package.json
├── examples
├── index.html
├── upload_file.html
└── upload_file.css
├── index.html
├── README.md
├── spec
└── js
│ ├── ui_tests.js
│ └── unit_tests.js
├── src-old
└── parsing.js
└── LICENSE
/Procfile:
--------------------------------------------------------------------------------
1 | web: npm start
--------------------------------------------------------------------------------
/src/PublicLab.Grapher.js:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | .idea/*
3 | node_modules/
4 |
--------------------------------------------------------------------------------
/dist/transpiled_code/PublicLab.Grapher.js:
--------------------------------------------------------------------------------
1 | "use strict";
--------------------------------------------------------------------------------
/src/sample.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | sampleTest: function () {
3 | return "Mocha Testing";
4 | }
5 | };
--------------------------------------------------------------------------------
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": ["@babel/preset-env"],
3 | "plugins": [
4 | "@babel/plugin-proposal-class-properties"
5 | ]
6 | }
--------------------------------------------------------------------------------
/dist/transpiled_code/sample.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | module.exports = {
4 | sampleTest: function sampleTest() {
5 | return "Mocha Testing";
6 | }
7 | };
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/custom-issue---.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: "Custom issue \U0001F528"
3 | about: Tell us about an issue you're facing
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | Description
11 |
--------------------------------------------------------------------------------
/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | "env": {
3 | "browser": true,
4 | "es6": true
5 | },
6 | "extends": "eslint:recommended",
7 | "globals": {
8 | "Atomics": "readonly",
9 | "SharedArrayBuffer": "readonly"
10 | },
11 | "parserOptions": {
12 | "ecmaVersion": 2018,
13 | "sourceType": "module"
14 | },
15 | "rules": {
16 | }
17 | };
--------------------------------------------------------------------------------
/src/SimpleDataGrapher.js:
--------------------------------------------------------------------------------
1 | import {
2 | View
3 | } from "./View";
4 |
5 | class SimpleDataGrapher {
6 | 'use strict';
7 | static elementIdSimpleDataGraphInstanceMap = {};
8 | elementId = null;
9 | view = null;
10 | constructor(elementId) {
11 | this.elementId = elementId;
12 | SimpleDataGrapher.elementIdSimpleDataGraphInstanceMap[this.elementId] = this;
13 | this.view = new View(elementId);
14 | }
15 | };
16 |
17 | export {
18 | SimpleDataGrapher
19 | };
20 |
21 | window.SimpleDataGrapher = SimpleDataGrapher;
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | node_js:
3 | - node
4 |
5 | addons:
6 | apt:
7 | packages:
8 | # This is required to run new chrome on old trusty
9 | - libnss3
10 |
11 | before_install:
12 | # install forever to run daemon
13 | - npm install -g forever
14 | # Enable user namespace cloning
15 | - "sysctl kernel.unprivileged_userns_clone=1"
16 | # Launch XVFB
17 | - "export DISPLAY=:99.0"
18 | - "sh -e /etc/init.d/xvfb start"
19 | dist: trusty
20 | sudo: required
21 |
22 | script:
23 | - forever start ./node_modules/http-server/bin/http-server -p 8000
24 | - npm test
25 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | Fixes #0000 (<=== Add issue number here)
2 |
3 | Make sure these boxes are checked before your pull request (PR) is ready to be reviewed and merged. Thanks!
4 |
5 | * [ ] PR is descriptively titled 📑 and links the original issue above 🔗
6 | * [ ] code is in uniquely-named feature branch and has no merge conflicts 📁
7 | * [ ] screenshots/GIFs are attached 📎 in case of UI updation
8 | * [ ] ask `@publiclab/reviewers` or the user who published the issue for help, in a comment below
9 |
10 | > We're happy to help you get this ready -- don't be afraid to ask for help!
11 |
12 | Please be sure you've reviewed our contribution guidelines at https://publiclab.org/contributing-to-public-lab-software
13 |
14 | Thanks!
15 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature-request---.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: "Feature request \U0001F4A1"
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: enhancement
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is.
12 |
13 | **Describe the feature/solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Propose ideas to implement this feature**
20 | A clear and concise description of what you've thought to implement the suggested feature/solution.
21 | Kindly provide any links/screenshots/code snippets for the proposed solution.
22 |
23 | **Additional context**
24 | Add any other context or screenshots about the feature request here.
25 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug-report----.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: "Bug report \U0001F41B"
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: bug
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is (Kindly provide a screenshot if possible)
12 |
13 | **Expected behavior**
14 | A clear and concise description of what you expected to happen.
15 |
16 |
17 | **To Reproduce**
18 | Steps to reproduce the behavior
19 | Example:
20 | 1. Go to '...'
21 | 2. Click on '....'
22 | 3. Scroll down to '....'
23 | 4. See error
24 |
25 |
26 | ** Link to code **
27 | Link(s) to the file(s) where the code causing/solving the bug can be found.
28 |
29 |
30 | **Additional context/Possible solution**
31 | Add any other context about the problem here or propose a solution.
32 |
33 |
39 |
--------------------------------------------------------------------------------
/dist/transpiled_code/SimpleDataGrapher.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | Object.defineProperty(exports, "__esModule", {
4 | value: true
5 | });
6 | exports.SimpleDataGrapher = void 0;
7 |
8 | var _View = require("./View");
9 |
10 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
11 |
12 | function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
13 |
14 | var SimpleDataGrapher = function SimpleDataGrapher(elementId) {
15 | _classCallCheck(this, SimpleDataGrapher);
16 |
17 | _defineProperty(this, 'use strict', void 0);
18 |
19 | _defineProperty(this, "elementId", null);
20 |
21 | _defineProperty(this, "view", null);
22 |
23 | this.elementId = elementId;
24 | SimpleDataGrapher.elementIdSimpleDataGraphInstanceMap[this.elementId] = this;
25 | this.view = new _View.View(elementId);
26 | };
27 |
28 | exports.SimpleDataGrapher = SimpleDataGrapher;
29 |
30 | _defineProperty(SimpleDataGrapher, "elementIdSimpleDataGraphInstanceMap", {});
31 |
32 | ;
33 | window.SimpleDataGrapher = SimpleDataGrapher;
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | Contributing to SIMPLE-DATA-GRAPHER
2 | ==========================
3 |
4 | We welcome community contributions to SIMPLE-DATA-GRAPHER! To install SIMPLE-DATA-GRAPHER locally, follow the instructions in the [README.md file](https://github.com/publiclab/simple-data-grapher#installation).
5 |
6 | We especially welcome contributions from people from groups underrepresented in free and open source software!
7 |
8 | Our community aspires to be a respectful place. Please read and abide by our [Code of Conduct](https://publiclab.org/conduct).
9 |
10 | ## First Timers Welcome!
11 |
12 | New to open source/free software? See our WELCOME PAGE, including a selection of issues we've made especially for first-timers. We're here to help, so just ask if one looks interesting:
13 |
14 | https://code.publiclab.org/#r=all
15 |
16 | Thank you so much!
17 |
18 | Learn more about contributing to Public Lab code projects on these pages:
19 |
20 | * https://publiclab.org/developers
21 | * https://publiclab.org/contributing-to-public-lab-software
22 | * https://publiclab.org/soc
23 | * https://publiclab.org/wiki/developers
24 | * https://publiclab.org/wiki/gsoc-ideas
25 |
26 | ## Bug reports & troubleshooting
27 |
28 | If you are submitting a bug/issue , please go to https://github.com/publiclab/simple-data-grapher/issues/new.
29 |
30 | Here you can find different categories of issues you might want to raise like a First-Timers-Only, a bug, a feature or an issue in general.
31 |
32 | Welcome to Public Lab!
33 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Public Lab Code of Conduct
2 |
3 | _Public Lab, PO Box 426113, Cambridge, MA 02142_
4 |
5 | We are coming together with an intent to care for ourselves and one another. We want to nurture a compassionate democratic culture where responsibility is shared. We -- visitors, community members, community moderators, staff, organizers, sponsors, and all others -- hold ourselves accountable to the same values regardless of position or experience. For this to work for everybody, individual decisions will not be allowed to run counter to the welfare of other people. This community aspires to be a respectful place both during online and in-person interactions so that all people are able to fully participate with their dignity intact. This document is a piece of the culture we're creating.
6 |
7 | This code of conduct applies to all spaces managed by the Public Lab community and non-profit, both online and in person. It was written by the Conduct Committee (formed in 2015 during Public Lab’s annual conference "The Barnraising") and facilitated by staff to provide a clear set of practical guidelines for multi-day events such as Barnraisings, events led by organizers and community members, and online venues such as the website, comment threads on software platforms, chatrooms, our mailing lists, the issue tracker, and any other forums created by Public Lab which the community uses for communication.
8 |
9 | To read the full Code of Conduct and learn how to contact the Conduct Committee or the Moderators group, see:
10 |
11 | https://publiclab.org/conduct
12 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "simple-data-grapher",
3 | "version": "2.0.0",
4 | "description": "Turns CSVs into graphs in a few simple steps; various import and export options",
5 | "main": "src/PublicLab.Grapher.js",
6 | "scripts": {
7 | "build": "watch 'babel src -d dist/transpiled_code & browserify dist/transpiled_code/SimpleDataGrapher.js -o dist/PublicLab.Grapher.js' src",
8 | "heroku-postbuild": "babel src -d dist/transpiled_code & browserify dist/transpiled_code/SimpleDataGrapher.js -o dist/PublicLab.Grapher.js",
9 | "test": "./node_modules/mocha/bin/mocha --require @babel/register --require @babel/polyfill --require jsdom-global/register spec/js/ --timeout 30000",
10 | "lint": "eslint ./src ./dist ./spec --fix",
11 | "start": "http-server -c-1 -p ${PORT:=8000}",
12 | "dev_start": "http-server -c-1 -p 8000"
13 | },
14 | "repository": {
15 | "type": "git",
16 | "url": "git+https://github.com/publiclab/simple-data-grapher.git"
17 | },
18 | "keywords": [
19 | "Data-Grapher",
20 | "Grapher",
21 | "CSV",
22 | "Graph"
23 | ],
24 | "author": "Public Lab",
25 | "license": "GPL-3.0",
26 | "bugs": {
27 | "url": "https://github.com/publiclab/simple-data-grapher/issues"
28 | },
29 | "homepage": "https://github.com/publiclab/simple-data-grapher#readme",
30 | "dependencies": {
31 | "chai": "^4.2.0",
32 | "chartjs": "^0.3.24",
33 | "express": "^4.17.1",
34 | "file-system": "^2.2.2",
35 | "googleapis": "^39.2.0",
36 | "http-server": "^0.11.1",
37 | "iframe-phone": "^1.2.0",
38 | "jquery": "^3.4.1",
39 | "mocha": "^6.1.4",
40 | "papaparse": "^4.6.3",
41 | "puppeteer": "^1.19.0",
42 | "readline": "^1.3.0"
43 | },
44 | "devDependencies": {
45 | "@babel/cli": "^7.4.4",
46 | "@babel/core": "^7.4.5",
47 | "@babel/plugin-proposal-class-properties": "^7.4.4",
48 | "@babel/polyfill": "^7.4.4",
49 | "@babel/preset-env": "^7.4.5",
50 | "@babel/register": "^7.4.4",
51 | "babelify": "^10.0.0",
52 | "browserify": "^16.2.3",
53 | "jsdom": "15.1.1",
54 | "jsdom-global": "3.0.2",
55 | "eslint": "^5.16.0",
56 | "watch": "^1.0.2"
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/first-timers-only---------.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: "First-Timers-Only \U0001F469\U0001F3FB\U0001F9D1\U0001F3FB"
3 | about: Issues to welcome new-comers to the community
4 | title: ''
5 | labels: first-timers-only, good first issue
6 | assignees: ''
7 |
8 | ---
9 |
10 | Hi, this is a [first-timers-only issue](https://publiclab.github.io/community-toolbox/#r=all). This means we've worked to make it more legible to folks who either **haven't contributed to our codebase before, or even folks who haven't contributed to open source before**.
11 |
12 | If that's you, we're interested in helping you take the first step and can answer questions and help you out as you do. Note that we're especially interested in contributions from people from groups underrepresented in free and open source software!
13 |
14 | We know that the process of creating a pull request is the biggest barrier for new contributors. This issue is for you 💝
15 |
16 | If you have contributed before, **consider leaving this one for someone new**, and looking through our general [help wanted](https://github.com/publiclab/plots2/labels/help-wanted) issues. Thanks!
17 |
18 | ### 🤔 What you will need to know.
19 |
20 | Nothing. This issue is meant to welcome you to Open Source :) We are happy to walk you through the process.
21 |
22 | ### Problem
23 |
24 |
25 | ### 📋Solution
26 |
27 | - [ ] 🙋 **Claim this issue**: Comment below. If someone else has claimed it, ask if they've opened a pull request already and if they're stuck -- maybe you can help them solve a problem or move it along!
28 |
29 | - [ ] 📝 **Update**
30 |
31 | - [ ] 💾 **Commit** your changes
32 |
33 | - [ ] 🔀 **Start a Pull Request**. There are two ways how you can start a pull request:
34 |
35 | 1. If you are familiar with the terminal or would like to learn it, [here is a great tutorial](https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github) on how to send a pull request using the terminal.
36 |
37 | 2. You can also [edit files directly in your browser](https://help.github.com/articles/editing-files-in-your-repository/) and open a pull request from there.
38 |
39 | - [ ] 🏁 **Done** Ask in comments for a review :)
40 |
41 |
42 | ### 🤔❓ Questions?
43 |
44 | Leave a comment below!
45 |
46 | ### Is someone else already working on this?
47 |
48 | We encourage you to link to this issue by mentioning the issue # in your pull request, so we can see if someone's already started on it. **If someone seem stuck, offer them some help!** Otherwise, [take a look at some other issues you can help with](https://publiclab.github.io/community-toolbox/#r=all). Thanks!
49 |
--------------------------------------------------------------------------------
/examples/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
44 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/src/PlotlyjsPlotter.js:
--------------------------------------------------------------------------------
1 | class PlotlyjsPlotter {
2 | 'use strict';
3 | dataHash = {};
4 | elementId = null;
5 | graphCounting = 0;
6 | canvasContainerId = null;
7 | graphType = null;
8 | length = 0;
9 | flag = false;
10 |
11 | determineType2() {
12 | if (this.graphType == "Horizontal" || this.graphType == "Vertical") {
13 | return "bar";
14 | } else if (this.graphType == "Pie" || this.graphType == "Doughnut" || this.graphType == "Radar") {
15 | return "pie";
16 | } else if (this.graphType == "Basic" || this.graphType == "Stepped" || this.graphType == "Point") {
17 | return "scatter";
18 | }
19 | }
20 | layoutMaker() {
21 | var layout = {};
22 | if (this.graphType == "Horizontal" || this.graphType == "Vertical") {
23 | layout["barmode"] = "group";
24 | }
25 | return layout;
26 | }
27 | traceMaker() {
28 | var trace = {};
29 | trace["type"] = this.determineType2();
30 | if (this.graphType == "Horizontal") {
31 | trace["orientation"] = "h";
32 | } else if (this.graphType == "Doughnut") {
33 | trace["hole"] = 0.5;
34 | } else if (this.graphType == "Basic") {
35 | trace["mode"] = "lines";
36 | } else if (this.graphType == "Point") {
37 | trace["mode"] = "markers";
38 | } else if (this.graphType == "Stepped") {
39 | trace["mode"] = "lines+markers";
40 | trace["line"] = {
41 | "shape": 'hv'
42 | };
43 | }
44 | return trace;
45 | }
46 | keyDeterminer() {
47 | var keys = ["x", "y"];
48 | if (this.graphType == "Pie" || this.graphType == "Doughnut") {
49 | keys[1] = "values";
50 | keys[0] = "labels";
51 | } else if (this.graphType == "Horizontal") {
52 | keys[0] = "y";
53 | keys[1] = "x";
54 | }
55 | return keys;
56 | }
57 | plotGraph2() {
58 | if (this.flag) {
59 | document.getElementById(this.canvasContainerId).innerHTML = "";
60 | }
61 | var layout = this.layoutMaker();
62 | var data = [];
63 | var keySet = this.keyDeterminer();
64 | for (var i = 0; i < this.length; i++) {
65 | var new_trace = this.traceMaker();
66 | new_trace[keySet[0]] = this.dataHash['x_axis_labels'];
67 | new_trace[keySet[1]] = this.dataHash['y_axis_values' + i];
68 | new_trace["name"] = this.dataHash['labels'][1][i];
69 | data.push(new_trace);
70 | }
71 | var div = document.createElement('div');
72 | div.id = this.elementId + '_chart_container_' + this.graphCounting;
73 | document.getElementById(this.canvasContainerId).appendChild(div);
74 | Plotly.newPlot(div.id, data, layout);
75 |
76 | }
77 | constructor(hash, length, type, flag, canvasContainerId, elementId, graphCounting) {
78 | this.dataHash = hash;
79 | this.length = length;
80 | this.graphType = type;
81 | this.flag = flag;
82 | this.canvasContainerId = canvasContainerId;
83 | this.elementId = elementId;
84 | this.graphCounting = graphCounting;
85 | this.plotGraph2();
86 | }
87 | }
88 | module.exports = PlotlyjsPlotter;
--------------------------------------------------------------------------------
/.github/config.yml:
--------------------------------------------------------------------------------
1 | # Configuration for welcome - https://github.com/behaviorbot/welcome
2 |
3 | # Configuration for new-issue-welcome - https://github.com/behaviorbot/new-issue-welcome
4 |
5 | # Comment to be posted to on first time issues
6 | newIssueWelcomeComment: |
7 | Thanks for opening your first issue! This space is [protected by our Code of Conduct](https://publiclab.org/conduct) - and we're here to help.
8 | Please follow the issue template to help us help you 👍🎉😄
9 | If you have screenshots [or a gif](https://publiclab.org/gifs/) to share demonstrating the issue, that's really helpful! 📸
10 | Do join our [Gitter channel](https://gitter.im/publiclab/publiclab) for some brainstorming discussions.
11 | # Configuration for new-pr-welcome - https://github.com/behaviorbot/new-pr-welcome
12 |
13 | # Comment to be posted to on PRs from first time contributors in your repository
14 | newPRWelcomeComment: |
15 | Thanks for opening this pull request! This space is [protected by our Code of Conduct](https://publiclab.org/conduct) - and we're here to help.
16 | `Dangerbot` will test out your code and reply in a bit with some pointers and requests.
17 | You can create issues [here](https://github.com/publiclab/simple-data-grapher/issues/new/choose) for any installation help
18 | There may be some errors, **but don't worry!** We'll work through them with you! 👍🎉😄
19 | It would be great if you can tell us your Twitter handle so we can thank you properly?
20 |
21 | # Configuration for first-pr-merge - https://github.com/behaviorbot/first-pr-merge
22 |
23 | # Comment to be posted to on pull requests merged by a first time user
24 | firstPRMergeComment: |
25 | Congrats on merging your first pull request! 🙌🎉⚡️
26 | Your code will likely be published to PublicLab.org in the next few days, but first it will be published to https://stable.publiclab.org/ (it will take some minutes for this to load, and until then you may see logs from the build process). Please test out your work on this testing server and report back with a comment that all has gone well!
27 | Do join our weekly check-in to share your this week goal and the awesome work you did 😃. Please find the link **pinned in the issue section** 📝
28 | Now that you've completed this, you can help someone else take their first step!
29 | Reach out to someone else working on theirs on [Public Lab's code welcome page](https://code.publiclab.org#r=all). Thanks!
30 |
31 | Help others take their first step
32 |
Now that you've merged your first pull request, you're the perfect person to help someone else out with this challenging first step. 🙌
Try looking at this list of `first-timers-only` issues, and see if someone else is waiting for feedback, or even stuck! 😕
35 |
People often get stuck at the same steps, so you might be able to help someone get unstuck, or help lead them to some documentation that'd help. Reach out and be encouraging and friendly! 😄 🎉
37 |
38 | # It is recommend to include as many gifs and emojis as possible
39 |
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
48 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # simple-data-grapher
2 | [](https://publiclab.org/conduct) [](https://travis-ci.com/publiclab/simple-data-grapher)
3 |
4 | Turns CSVs into graphs in a few simple steps; embeds onto other websites!
5 |
6 | ## Quick Setup :
7 |
8 | ### Installation Instructions:
9 | 1. Clone this repository to your local environment.
10 | `git clone https://github.com/publiclab/simple-data-grapher`
11 | 2. Run `npm install` to install all the necessary packages required.
12 | 3. Open `examples/index.html` in your browser to look at the preview of the library.
13 |
14 | ### Instructions for a developer:
15 | 1. Make the changes you are working on in respective /src files.
16 | 2. After doing or while doing the changes run `npm run build` for making the changes in the `dist/`.
17 | 3. Run `npm run test` to run the tests.
18 | 4. Test your changes on a browser by opening `examples/index.html`.
19 | 5. For finding linting issues run `npm run lint`
20 |
21 | 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.
22 | For testing we are using `mocha`.
23 | ### Flow: Basic Flow of the Library
24 |
25 | 
26 |
27 | - **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.
28 |
29 | - **Csvparser.js:** Receives the file and it's format type and:
30 |
31 | - Parses the CSV
32 | - Determines headers
33 | - Determines a matrix for the complete data
34 | - Extracts sample data to be displayed to the user for selection
35 | - Creates a transpose of the data
36 |
37 | - **PlotlyjsPlotter.js (default) or ChartjsPlotter.js:** Assembles the received data according to its format and plots the graph on the canvas element.
38 |
39 | ### Peripheral Features in Stand-alone
40 |
41 | - **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.
42 |
43 | - **Create Spreadsheet:** Uses the transpose created by Csvparser.js and creates a (excel or xlsx) spreadsheet using `SheetJS` and downloads it.
44 |
45 | - **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.
46 |
47 | ### Plotlyjs v/s Chartjs
48 |
49 | 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.
50 |
51 | - Plotlyjs is more extensively used than Chartjs
52 | - Plotlyjs provides options like:
53 | - Zooming
54 | - Panning
55 | - Autoscaling
56 | - Downloading the graph as an image
57 | - Box and Lasso select
58 | - Edit graph in Plotlyjs editor
59 | - Chartjs:
60 | - Better comparison
61 | - Better color scheme and design
62 | - More informative tooltips
63 |
64 | ### Flow in plots2
65 |
66 | The basic flow remains the same as in the standalone library.
67 |
68 | #### Features introduced on integration
69 |
70 | - **Save the data:** The user can save their uploaded CSV and use it later for plotting.
71 |
72 | - **Using previously uploaded data for plotting:** Users can use their previously uploaded files for plotting in simple-data-grapher.
73 |
74 | - Associate a file title and description with the uploaded data.
75 |
76 | - **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.
77 |
78 | ### Publish as a Research Note
79 |
80 | The user can publish their plotted charts as a Research Note on Public Lab and discuss their findings.
81 |
82 | #### Flow
83 |
84 | 
85 |
86 |
--------------------------------------------------------------------------------
/examples/upload_file.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Simple Data Grapher
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
Choose a csv file or drag & drop it here
38 |
39 |
40 |
41 |
42 |
OR
43 |
44 |
45 |
46 |
OR
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
--------------------------------------------------------------------------------
/dist/transpiled_code/PlotlyjsPlotter.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4 |
5 | function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
6 |
7 | function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
8 |
9 | function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
10 |
11 | var PlotlyjsPlotter =
12 | /*#__PURE__*/
13 | function () {
14 | _createClass(PlotlyjsPlotter, [{
15 | key: "determineType2",
16 | value: function determineType2() {
17 | if (this.graphType == "Horizontal" || this.graphType == "Vertical") {
18 | return "bar";
19 | } else if (this.graphType == "Pie" || this.graphType == "Doughnut" || this.graphType == "Radar") {
20 | return "pie";
21 | } else if (this.graphType == "Basic" || this.graphType == "Stepped" || this.graphType == "Point") {
22 | return "scatter";
23 | }
24 | }
25 | }, {
26 | key: "layoutMaker",
27 | value: function layoutMaker() {
28 | var layout = {};
29 |
30 | if (this.graphType == "Horizontal" || this.graphType == "Vertical") {
31 | layout["barmode"] = "group";
32 | }
33 |
34 | return layout;
35 | }
36 | }, {
37 | key: "traceMaker",
38 | value: function traceMaker() {
39 | var trace = {};
40 | trace["type"] = this.determineType2();
41 |
42 | if (this.graphType == "Horizontal") {
43 | trace["orientation"] = "h";
44 | } else if (this.graphType == "Doughnut") {
45 | trace["hole"] = 0.5;
46 | } else if (this.graphType == "Basic") {
47 | trace["mode"] = "lines";
48 | } else if (this.graphType == "Point") {
49 | trace["mode"] = "markers";
50 | } else if (this.graphType == "Stepped") {
51 | trace["mode"] = "lines+markers";
52 | trace["line"] = {
53 | "shape": 'hv'
54 | };
55 | }
56 |
57 | return trace;
58 | }
59 | }, {
60 | key: "keyDeterminer",
61 | value: function keyDeterminer() {
62 | var keys = ["x", "y"];
63 |
64 | if (this.graphType == "Pie" || this.graphType == "Doughnut") {
65 | keys[1] = "values";
66 | keys[0] = "labels";
67 | } else if (this.graphType == "Horizontal") {
68 | keys[0] = "y";
69 | keys[1] = "x";
70 | }
71 |
72 | return keys;
73 | }
74 | }, {
75 | key: "plotGraph2",
76 | value: function plotGraph2() {
77 | if (this.flag) {
78 | document.getElementById(this.canvasContainerId).innerHTML = "";
79 | }
80 |
81 | var layout = this.layoutMaker();
82 | var data = [];
83 | var keySet = this.keyDeterminer();
84 |
85 | for (var i = 0; i < this.length; i++) {
86 | var new_trace = this.traceMaker();
87 | new_trace[keySet[0]] = this.dataHash['x_axis_labels'];
88 | new_trace[keySet[1]] = this.dataHash['y_axis_values' + i];
89 | new_trace["name"] = this.dataHash['labels'][1][i];
90 | data.push(new_trace);
91 | }
92 |
93 | var div = document.createElement('div');
94 | div.id = this.elementId + '_chart_container_' + this.graphCounting;
95 | document.getElementById(this.canvasContainerId).appendChild(div);
96 | Plotly.newPlot(div.id, data, layout);
97 | }
98 | }]);
99 |
100 | function PlotlyjsPlotter(hash, length, type, flag, canvasContainerId, elementId, graphCounting) {
101 | _classCallCheck(this, PlotlyjsPlotter);
102 |
103 | _defineProperty(this, 'use strict', void 0);
104 |
105 | _defineProperty(this, "dataHash", {});
106 |
107 | _defineProperty(this, "elementId", null);
108 |
109 | _defineProperty(this, "graphCounting", 0);
110 |
111 | _defineProperty(this, "canvasContainerId", null);
112 |
113 | _defineProperty(this, "graphType", null);
114 |
115 | _defineProperty(this, "length", 0);
116 |
117 | _defineProperty(this, "flag", false);
118 |
119 | this.dataHash = hash;
120 | this.length = length;
121 | this.graphType = type;
122 | this.flag = flag;
123 | this.canvasContainerId = canvasContainerId;
124 | this.elementId = elementId;
125 | this.graphCounting = graphCounting;
126 | this.plotGraph2();
127 | }
128 |
129 | return PlotlyjsPlotter;
130 | }();
131 |
132 | module.exports = PlotlyjsPlotter;
--------------------------------------------------------------------------------
/src/ChartjsPlotter.js:
--------------------------------------------------------------------------------
1 | class ChartjsPlotter {
2 | 'use strict';
3 | dataHash = {};
4 | elementId = null;
5 | graphCounting = 0;
6 | canvasContainerId = null;
7 | graphType = null;
8 | length = 0;
9 | flag = false;
10 |
11 | determineType() {
12 | if (this.graphType == "Basic" || this.graphType == "Stepped" || this.graphType == "Point") {
13 | return 'line';
14 | } else if (this.graphType == "Horizontal") {
15 | return 'horizontalBar';
16 | } else if (this.graphType == "Vertical") {
17 |
18 | return 'bar';
19 | } else {
20 | return this.graphType.toLowerCase();
21 | }
22 | }
23 |
24 | colorGenerator(i, tb, count) {
25 | var colors = ['rgba(255, 77, 210, 0.5)', 'rgba(0, 204, 255, 0.5)', 'rgba(128, 0, 255, 0.5)', 'rgba(255, 77, 77, 0.5)', 'rgba(0, 179, 0, 0.5)', 'rgba(255, 255, 0, 0.5)', 'rgba(255, 0, 102, 0.5)', 'rgba(0, 115, 230, 0.5)'];
26 | var bordercolors = ['rgb(255, 0, 191)', 'rgb(0, 184, 230)', 'rgb(115, 0, 230)', 'rgb(255, 51, 51)', 'rgb(0, 153, 0)', 'rgb(230, 230, 0)', 'rgb(230, 0, 92)', 'rgb(0, 102, 204)'];
27 | var length = 8;
28 | if (this.graphType == "Pie" || this.graphType == "Doughnut") {
29 | var colorSet = [];
30 | var borderColorSet = [];
31 | for (var j = 0; j < count; j++) {
32 | colorSet.push(colors[j % length]);
33 | borderColorSet.push(bordercolors[j % length]);
34 | }
35 | if (tb == "bg") {
36 | return colorSet;
37 | } else {
38 | return borderColorSet;
39 | }
40 | } else {
41 | if (tb == "bg") {
42 | return colors[i % length];
43 | } else {
44 | return bordercolors[i % length];
45 | }
46 | }
47 | }
48 |
49 | determineData(i) {
50 | var h = {};
51 | if (this.graphType == "Basic") {
52 | h['fill'] = false;
53 | } else if (this.graphType == "Stepped") {
54 | h['steppedLine'] = true;
55 | h['fill'] = false;
56 | } else if (this.graphType == "Point") {
57 | h['showLine'] = false;
58 | h['pointRadius'] = 10;
59 | }
60 | h['backgroundColor'] = this.colorGenerator(i, "bg", this.dataHash['y_axis_values' + i].length);
61 | h['borderColor'] = this.colorGenerator(i, "bo", this.dataHash['y_axis_values' + i].length);
62 | h['borderWidth'] = 1;
63 | h['label'] = this.dataHash['labels'][1][i];
64 | h['data'] = this.dataHash['y_axis_values' + i];
65 | return h;
66 | }
67 |
68 | determineConfig() {
69 | var config = {};
70 | config['type'] = this.determineType();
71 | var data = {};
72 | data['labels'] = this.dataHash['x_axis_labels'];
73 | var datasets = [];
74 | for (var i = 0; i < this.length; i++) {
75 | var h = this.determineData(i);
76 | datasets.push(h);
77 | }
78 | var options = {
79 | 'responsive': true,
80 | 'maintainAspectRatio': true,
81 | 'chartArea': {
82 | backgroundColor: 'rgb(204, 102, 255)'
83 | }
84 | };
85 | options['scales'] = this.scales();
86 | config['options'] = options;
87 | data['datasets'] = datasets;
88 | config['data'] = data;
89 | return config;
90 | }
91 |
92 | scales() {
93 | var scales = {
94 | xAxes: [{
95 | display: true,
96 | scaleLabel: {
97 | display: true,
98 | labelString: this.dataHash['labels'][0]
99 | }
100 | }],
101 | yAxes: [{
102 | display: true,
103 | scaleLabel: {
104 | display: true,
105 | labelString: 'Value'
106 | }
107 | }]
108 | }
109 | return scales;
110 | }
111 | saveAsImageFunction(canvId) {
112 | var newDate = new Date();
113 | var timestamp = newDate.getTime();
114 | var temp = canvId;
115 | temp = "#" + temp;
116 | $(temp).get(0).toBlob(function (blob) {
117 | saveAs(blob, "chart" + timestamp);
118 | });
119 |
120 | }
121 | createSaveAsImageButton(canvasDiv, canvasId) {
122 | var saveImageButton = document.createElement("BUTTON");
123 | saveImageButton.classList.add("btn");
124 | saveImageButton.classList.add("btn-primary");
125 | saveImageButton.innerHTML = "Save as Image";
126 | saveImageButton.id = canvasId + "image";
127 | canvasDiv.appendChild(saveImageButton);
128 | let self = this;
129 | document.getElementById(saveImageButton.id).onclick = (e) => {
130 | self.saveAsImageFunction(canvasId);
131 | }
132 | }
133 | plotGraph() {
134 | if (this.flag) {
135 | document.getElementById(this.canvasContainerId).innerHTML = "";
136 | }
137 | var div = document.createElement('div');
138 | div.classList.add(this.elementId + '_chart_container_' + this.graphCounting);
139 | var canv = document.createElement('canvas');
140 | canv.id = this.elementId + '_canvas_' + this.graphCounting;
141 | div.appendChild(canv);
142 | document.getElementById(this.canvasContainerId).appendChild(div);
143 | var ctx = canv.getContext('2d');
144 | var configuration = this.determineConfig();
145 | new Chart(ctx, configuration);
146 | this.createSaveAsImageButton(div, canv.id);
147 | // $('.'+this.carousalClass).carousel(2);
148 | }
149 | constructor(hash, length, type, flag, canvasContainerId, elementId, graphCounting) {
150 | this.dataHash = hash;
151 | this.length = length;
152 | this.graphType = type;
153 | this.flag = flag;
154 | this.canvasContainerId = canvasContainerId;
155 | this.elementId = elementId;
156 | this.graphCounting = graphCounting;
157 | this.plotGraph();
158 | }
159 | }
160 | module.exports = ChartjsPlotter;
--------------------------------------------------------------------------------
/spec/js/ui_tests.js:
--------------------------------------------------------------------------------
1 | const assert = require('chai').assert;
2 | const puppeteer = require('puppeteer');
3 | const _ = require('lodash');
4 | const globalVariables = _.pick(global, ['browser', 'expect']);
5 | const opts = {
6 | headless: false,
7 | };
8 | before (async function () {
9 | global.browser = await puppeteer.launch(opts);
10 | });
11 | after (function(){
12 | browser.close();
13 | global.browser = globalVariables.browser;
14 | })
15 | describe("sample test", function(){
16 | it("should run the browser", async function(){
17 | console.log(await browser.version());
18 | assert.equal(true,true);
19 | });
20 | });
21 | describe("heading tests", function(){
22 | let page;
23 | before (async function () {
24 | page = await browser.newPage();
25 | await page.goto('http://localhost:8000');
26 | });
27 | after (async function () {
28 | await page.close();
29 | });
30 | it ("should test main heading", async function(){
31 | const headingValue = await page.$eval('.main_heading', el => el.innerHTML);
32 | assert.equal(headingValue,"Simple Data Grapher");
33 | });
34 | it ("should test sub heading", async function(){
35 | const headingValue = await page.$eval('.sub_heading', el => el.innerHTML);
36 | assert.equal(headingValue,"A JavaScript library that turns uploaded CSV files into customizable graphs within a few simple steps. Can be embedded on other websites!");
37 | });
38 | it ("should test indicator-1 heading", async function(){
39 | const headingValue = await page.$eval('.item-1', el => el.innerHTML);
40 | assert.equal(headingValue,"Upload CSV Data");
41 | });
42 | it ("should test indicator-2 heading", async function(){
43 | const headingValue = await page.$eval('.item-2', el => el.innerHTML);
44 | console.log(headingValue);
45 | assert.equal(headingValue,"Select Columns & Graph Type");
46 | });
47 | it ("should test indicator-3 heading", async function(){
48 | const headingValue = await page.$eval('.item-3', el => el.innerHTML);
49 | assert.equal(headingValue,"Plotted Graph & Export Options");
50 | });
51 | });
52 | describe("csv string file upload test", function(){
53 | let page;
54 | before (async function () {
55 | page = await browser.newPage();
56 | await page.goto('http://localhost:8000');
57 | const fileInput=await page.$('.csv_string');
58 | await fileInput.type("A,2,3\nB,5,6\nC,8,9");
59 | await page.mouse.click(10,10);
60 | const uploadButton=await page.$('.uploadButton');
61 | await uploadButton.click();
62 | });
63 | after (async function () {
64 | await page.close();
65 | });
66 | it("should test toggle button: on", async function(){
67 | let xyToggleValue=await page.$('.xytoggle');
68 | let val=await (await xyToggleValue.getProperty('checked')).jsonValue();
69 | assert.equal(val,true);
70 | });
71 | it("should test toggle button: off", async function(){
72 | const xyToggle=await page.$('.toggle');
73 | await xyToggle.click();
74 | let xyToggleValue=await page.$('.xytoggle');
75 | let val=await (await xyToggleValue.getProperty('checked')).jsonValue();
76 | assert.equal(val,false);
77 | });
78 | it("should select Y-Axis columns", async function(){
79 | const col1=await page.$('#first_y_axis_input_columns1');
80 | await col1.click();
81 | const col2=await page.$('#first_y_axis_input_columns2');
82 | await col2.click();
83 | const val1=await (await col1.getProperty('checked')).jsonValue();
84 | const val2=await (await col2.getProperty('checked')).jsonValue();
85 | assert.equal(val1&&val2,true);
86 |
87 | });
88 | it("should select X-Axis column", async function(){
89 | const xyToggle=await page.$('.toggle');
90 | await xyToggle.click();
91 | const col1=await page.$('#first_x_axis_input_columns0');
92 | await col1.click();
93 | const val1=await (await col1.getProperty('checked')).jsonValue();
94 | assert.equal(val1,true);
95 | });
96 | it("should check plotting the graph", async function(){
97 | const plot_graphButton=await page.$(".plotGraph");
98 | await plot_graphButton.click();
99 | assert.notEqual(plot_graphButton, undefined);
100 | });
101 | it('should check if graph exists', async function() {
102 | const graph_container = await page.$('#first_chart_container_0');
103 | assert.notEqual(graph_container, undefined);
104 | });
105 | });
106 | describe('footer tests', function() {
107 | let page;
108 | before(async function() {
109 | page = await browser.newPage();
110 | await page.goto('http://localhost:8000');
111 | });
112 | after(async function() {
113 | await page.close();
114 | });
115 | it('should test footer headings', async function() {
116 | const [
117 | firstHeading,
118 | secondHeading
119 | ] = await page.$$eval('.footer-content h3', elements =>
120 | elements.map(el => el.textContent)
121 | );
122 |
123 | assert.equal(firstHeading, 'Need help?');
124 | assert.equal(secondHeading, 'Improve this tool');
125 | });
126 | it('should test footer paragraphs', async function() {
127 | const [
128 | firstParagraph,
129 | secondParagraph
130 | ] = await page.$$eval('.footer-content p', elements =>
131 | elements.map(el => el.textContent)
132 | );
133 |
134 | assert.equal(
135 | firstParagraph,
136 | 'Post a link to this and ask for help from other community members on PublicLab.org'
137 | );
138 | assert.equal(
139 | secondParagraph,
140 | 'This is an open source toolkit which you can help add to and improve on GitHub'
141 | );
142 | });
143 | it('should test footer buttons', async function() {
144 | const [
145 | firstButton,
146 | secondButton
147 | ] = await page.$$eval('.footer-content button', elements =>
148 | elements.map(el => el.textContent.trim())
149 | );
150 |
151 | assert.equal(firstButton, 'Ask a question >>');
152 | assert.equal(secondButton, 'View the code');
153 | });
154 | });
155 |
--------------------------------------------------------------------------------
/examples/upload_file.css:
--------------------------------------------------------------------------------
1 | .main_container{
2 | margin:0 auto;
3 | width: 50%;
4 | margin-top: 100px;
5 | margin-left: 0;
6 | margin-right: 0;
7 | height: 700px;
8 | display: flex;
9 | flex-direction: column;
10 | justify-content: space-around;
11 | align-items: center;
12 | }
13 | .main_grid_container{
14 | display: grid;
15 | grid-template-columns: auto auto;
16 | justify-content:space-around;
17 | align-items: center;
18 | height: 600px;
19 | grid-column-gap: 50px;
20 | text-align: center;
21 | }
22 | .parent_main_container{
23 | display: flex;
24 | align-items: center;
25 | justify-content: center;
26 | }
27 | .grid-item{
28 | height: 200px;
29 | display: flex;
30 | flex-direction: column;
31 | justify-content: space-evenly;
32 | }
33 | .sub_heading_import{
34 | font-family: 'Ubuntu Condensed';
35 | color: #1e3d7b;
36 | font-size: 20px;
37 | ;
38 | }
39 | .graph{
40 | height: 700px;
41 | }
42 | .table_container{
43 | height: 1000px;
44 | }
45 |
46 | .btn-file {
47 | position: relative;
48 | overflow: hidden;
49 | border-color: #0059b3;
50 | border-style: dashed;
51 | border-width: 2px;
52 | height: 150px;
53 | }
54 | .btn-file input[type=file] {
55 | position: absolute;
56 | top: 0;
57 | right: 0;
58 | min-width: 100%;
59 | min-height: 100%;
60 | font-size: 100px;
61 | text-align: center;
62 | filter: alpha(opacity=0);
63 | opacity: 0;
64 | outline: none;
65 | background: white;
66 | cursor: inherit;
67 | display: block;
68 | }
69 | .drag_drop_heading{
70 | margin-top: 50px;
71 | }
72 | .text_field{
73 | width: 350px;
74 | border-radius: 5px;
75 | height: 40px;
76 | padding-left: 5px;
77 |
78 | }
79 | ::placeholder{
80 | font-size: 12px;
81 | }
82 | .or {
83 | width:45%;
84 | text-align:center;
85 | border-bottom: 1px solid #cccccc;
86 | line-height:0.1em;
87 | margin:10px 0 20px;
88 | }
89 | .or span {
90 | background:#fff;
91 | padding:0 10px;
92 | font-size: 12px;
93 | color: #595959;
94 | }
95 | .input_box{
96 | width: 350px;
97 | }
98 | .carousel-indicators{
99 | top: 30px;
100 | justify-content:space-around;
101 | margin:0;
102 | display: flex;
103 | height: 20px;
104 | }
105 | .tables{
106 | margin-top: 100px;
107 | text-align: center;
108 | /* height: 1200px;
109 | display: flex;
110 | flex-direction: column;
111 | justify-content: space-around; */
112 |
113 | }
114 | .graph{
115 | margin-top: 100px;
116 | }
117 | #canvas_container{
118 | width: 50%;
119 | margin: 0 auto;
120 | }
121 | ol.carousel-indicators li.active {
122 | background: #004080;
123 | }
124 | ol.carousel-indicators li{
125 | width: 150px;
126 | height: 6px;
127 | cursor: pointer;
128 | background: #cccccc;
129 | }
130 | .toggle-handle{
131 | background: #f2f2f2;
132 | width: 100px;
133 | }
134 | .toggle-on{
135 | text-align: left;
136 | margin-left: 15px;
137 | }
138 | .toggle-off{
139 | text-align: right;
140 | margin-right: 15px;
141 | }
142 | .hidden {
143 | display:none;
144 | }
145 | .table_container{
146 | display: flex;
147 | flex-direction: column;
148 | justify-content: space-around;
149 | align-items: center;
150 | }
151 | .button_container{
152 | display: flex;
153 | flex-direction: column;
154 | justify-content: space-around;
155 | height: 100px;
156 | align-items: center;
157 | margin-bottom: 30px;
158 | }
159 | .table{
160 | font-family: 'Ubuntu Condensed';
161 | overflow: auto;
162 | width: 500px;
163 | }
164 | .feature_buttons{
165 | display: flex;
166 | flex-direction: row;
167 | justify-content: space-around;
168 | align-items: center;
169 | }
170 | .headings{
171 | display: flex;
172 | flex-direction: row;
173 | justify-content: space-around;
174 | align-items: center;
175 | list-style: none;
176 | /* margin-bottom: -160px; */
177 | }
178 | .check-inputs{
179 | margin-left: 10px;
180 |
181 | }
182 | .badge{
183 | padding: 10px;
184 | }
185 | .csv_string{
186 | height: 100px;
187 | width: 350px;
188 | }
189 | .main_heading{
190 | font-family: 'Ubuntu Condensed';
191 | text-align: center;
192 | color: #001a66;
193 | font-size: 40px;
194 | }
195 | .sub_heading{
196 | font-family: 'Ubuntu Condensed';
197 | text-align: center;
198 | color: #525357;
199 | font-size: 18px;
200 | padding-top: 5px;
201 | }
202 | .main_heading_container{
203 | margin-top: 40px;
204 | }
205 | .headings li{
206 | font-family: 'Ubuntu Condensed';
207 | font-size: 20px;
208 | }
209 | .heading_container{
210 | margin-top:80px;
211 | }
212 | .item-1{
213 | margin-left: 20px;
214 | }
215 | .item-2{
216 | margin-left: 70px;
217 | }
218 | .des{
219 | display: none;
220 | }
221 | .shadow{
222 | transition: box-shadow 0.3s;
223 | }
224 |
225 | .shadow:hover{
226 | box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
227 | }
228 | #import_description{
229 | visibility: hidden;
230 | width: 130px;
231 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
232 | font-style: italic;
233 | color: #053574;
234 | }
235 | #import_description_dummy{
236 | visibility: hidden;
237 | width: 130px;
238 | }
239 | .grid-container {
240 | display: grid;
241 | grid-template-columns: 150px 150px 150px;
242 | grid-gap: 30px;
243 | }
244 | .radio {
245 | background-color: rgba(255, 255, 255, 0.8);
246 | border: 1px solid #cccccc;
247 | font-size: 15px;
248 | text-align: center;
249 | cursor: pointer;
250 | display: flex;
251 | flex-direction: column;
252 | align-items: center;
253 | font-family: 'Ubuntu Condensed';
254 | color: #404040;
255 | height: 150px;
256 | }
257 | .radio:hover{
258 | box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
259 | }
260 | .hmm{
261 | background-color: #cccccc;
262 | text-align: center;
263 | width: 100%;
264 |
265 | }
266 | #menu_holder{
267 | display: flex;
268 | justify-content: space-evenly;
269 | align-items: center;
270 | width: 900px;
271 | }
272 | .d{
273 | visibility: hidden;
274 | width: 90px;
275 | }
276 | #graph_description{
277 | visibility: hidden;
278 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
279 | font-style: italic;
280 | color: #053574;
281 | width: 90px;
282 | }
283 | .parent_canvas_container{
284 | display: flex;
285 | justify-content: space-around;
286 | align-content: center;
287 | flex-direction: column;
288 |
289 | }
290 | .canvas_container{
291 | display: flex;
292 | justify-content: center;
293 | flex-direction: column;
294 |
295 | }
296 | .popover_headings{
297 | font-family: 'Ubuntu Condensed';
298 | }
299 | footer {
300 | width: 100%;
301 | padding: 80px 50px 80px 50px;
302 | display: grid;
303 | grid-template-columns: 50% 50%;
304 | text-align: center;
305 | }
306 | .footer-content p {
307 | display: inline-block;
308 | width: 70%;
309 | }
310 | .footer-content btn {
311 | display: block;
312 | }
313 | .footer-buttondiv {
314 | padding-top: 20px;
315 | }
--------------------------------------------------------------------------------
/dist/transpiled_code/ChartjsPlotter.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4 |
5 | function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
6 |
7 | function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
8 |
9 | function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
10 |
11 | var ChartjsPlotter =
12 | /*#__PURE__*/
13 | function () {
14 | _createClass(ChartjsPlotter, [{
15 | key: "determineType",
16 | value: function determineType() {
17 | if (this.graphType == "Basic" || this.graphType == "Stepped" || this.graphType == "Point") {
18 | return 'line';
19 | } else if (this.graphType == "Horizontal") {
20 | return 'horizontalBar';
21 | } else if (this.graphType == "Vertical") {
22 | return 'bar';
23 | } else {
24 | return this.graphType.toLowerCase();
25 | }
26 | }
27 | }, {
28 | key: "colorGenerator",
29 | value: function colorGenerator(i, tb, count) {
30 | var colors = ['rgba(255, 77, 210, 0.5)', 'rgba(0, 204, 255, 0.5)', 'rgba(128, 0, 255, 0.5)', 'rgba(255, 77, 77, 0.5)', 'rgba(0, 179, 0, 0.5)', 'rgba(255, 255, 0, 0.5)', 'rgba(255, 0, 102, 0.5)', 'rgba(0, 115, 230, 0.5)'];
31 | var bordercolors = ['rgb(255, 0, 191)', 'rgb(0, 184, 230)', 'rgb(115, 0, 230)', 'rgb(255, 51, 51)', 'rgb(0, 153, 0)', 'rgb(230, 230, 0)', 'rgb(230, 0, 92)', 'rgb(0, 102, 204)'];
32 | var length = 8;
33 |
34 | if (this.graphType == "Pie" || this.graphType == "Doughnut") {
35 | var colorSet = [];
36 | var borderColorSet = [];
37 |
38 | for (var j = 0; j < count; j++) {
39 | colorSet.push(colors[j % length]);
40 | borderColorSet.push(bordercolors[j % length]);
41 | }
42 |
43 | if (tb == "bg") {
44 | return colorSet;
45 | } else {
46 | return borderColorSet;
47 | }
48 | } else {
49 | if (tb == "bg") {
50 | return colors[i % length];
51 | } else {
52 | return bordercolors[i % length];
53 | }
54 | }
55 | }
56 | }, {
57 | key: "determineData",
58 | value: function determineData(i) {
59 | var h = {};
60 |
61 | if (this.graphType == "Basic") {
62 | h['fill'] = false;
63 | } else if (this.graphType == "Stepped") {
64 | h['steppedLine'] = true;
65 | h['fill'] = false;
66 | } else if (this.graphType == "Point") {
67 | h['showLine'] = false;
68 | h['pointRadius'] = 10;
69 | }
70 |
71 | h['backgroundColor'] = this.colorGenerator(i, "bg", this.dataHash['y_axis_values' + i].length);
72 | h['borderColor'] = this.colorGenerator(i, "bo", this.dataHash['y_axis_values' + i].length);
73 | h['borderWidth'] = 1;
74 | h['label'] = this.dataHash['labels'][1][i];
75 | h['data'] = this.dataHash['y_axis_values' + i];
76 | return h;
77 | }
78 | }, {
79 | key: "determineConfig",
80 | value: function determineConfig() {
81 | var config = {};
82 | config['type'] = this.determineType();
83 | var data = {};
84 | data['labels'] = this.dataHash['x_axis_labels'];
85 | var datasets = [];
86 |
87 | for (var i = 0; i < this.length; i++) {
88 | var h = this.determineData(i);
89 | datasets.push(h);
90 | }
91 |
92 | var options = {
93 | 'responsive': true,
94 | 'maintainAspectRatio': true,
95 | 'chartArea': {
96 | backgroundColor: 'rgb(204, 102, 255)'
97 | }
98 | };
99 | options['scales'] = this.scales();
100 | config['options'] = options;
101 | data['datasets'] = datasets;
102 | config['data'] = data;
103 | return config;
104 | }
105 | }, {
106 | key: "scales",
107 | value: function scales() {
108 | var scales = {
109 | xAxes: [{
110 | display: true,
111 | scaleLabel: {
112 | display: true,
113 | labelString: this.dataHash['labels'][0]
114 | }
115 | }],
116 | yAxes: [{
117 | display: true,
118 | scaleLabel: {
119 | display: true,
120 | labelString: 'Value'
121 | }
122 | }]
123 | };
124 | return scales;
125 | }
126 | }, {
127 | key: "saveAsImageFunction",
128 | value: function saveAsImageFunction(canvId) {
129 | var newDate = new Date();
130 | var timestamp = newDate.getTime();
131 | var temp = canvId;
132 | temp = "#" + temp;
133 | $(temp).get(0).toBlob(function (blob) {
134 | saveAs(blob, "chart" + timestamp);
135 | });
136 | }
137 | }, {
138 | key: "createSaveAsImageButton",
139 | value: function createSaveAsImageButton(canvasDiv, canvasId) {
140 | var saveImageButton = document.createElement("BUTTON");
141 | saveImageButton.classList.add("btn");
142 | saveImageButton.classList.add("btn-primary");
143 | saveImageButton.innerHTML = "Save as Image";
144 | saveImageButton.id = canvasId + "image";
145 | canvasDiv.appendChild(saveImageButton);
146 | var self = this;
147 |
148 | document.getElementById(saveImageButton.id).onclick = function (e) {
149 | self.saveAsImageFunction(canvasId);
150 | };
151 | }
152 | }, {
153 | key: "plotGraph",
154 | value: function plotGraph() {
155 | if (this.flag) {
156 | document.getElementById(this.canvasContainerId).innerHTML = "";
157 | }
158 |
159 | var div = document.createElement('div');
160 | div.classList.add(this.elementId + '_chart_container_' + this.graphCounting);
161 | var canv = document.createElement('canvas');
162 | canv.id = this.elementId + '_canvas_' + this.graphCounting;
163 | div.appendChild(canv);
164 | document.getElementById(this.canvasContainerId).appendChild(div);
165 | var ctx = canv.getContext('2d');
166 | var configuration = this.determineConfig();
167 | new Chart(ctx, configuration);
168 | this.createSaveAsImageButton(div, canv.id); // $('.'+this.carousalClass).carousel(2);
169 | }
170 | }]);
171 |
172 | function ChartjsPlotter(hash, length, type, flag, canvasContainerId, elementId, graphCounting) {
173 | _classCallCheck(this, ChartjsPlotter);
174 |
175 | _defineProperty(this, 'use strict', void 0);
176 |
177 | _defineProperty(this, "dataHash", {});
178 |
179 | _defineProperty(this, "elementId", null);
180 |
181 | _defineProperty(this, "graphCounting", 0);
182 |
183 | _defineProperty(this, "canvasContainerId", null);
184 |
185 | _defineProperty(this, "graphType", null);
186 |
187 | _defineProperty(this, "length", 0);
188 |
189 | _defineProperty(this, "flag", false);
190 |
191 | this.dataHash = hash;
192 | this.length = length;
193 | this.graphType = type;
194 | this.flag = flag;
195 | this.canvasContainerId = canvasContainerId;
196 | this.elementId = elementId;
197 | this.graphCounting = graphCounting;
198 | this.plotGraph();
199 | }
200 |
201 | return ChartjsPlotter;
202 | }();
203 |
204 | module.exports = ChartjsPlotter;
--------------------------------------------------------------------------------
/spec/js/unit_tests.js:
--------------------------------------------------------------------------------
1 | const assert = require('chai').assert;
2 | const sampleTest = require('../../src/sample').sampleTest;
3 | const CsvParserTest = require('../../src/CsvParser');
4 |
5 | describe("Sample Test", function(){
6 | it('Should return Mocha Testing', function () {
7 | var result = sampleTest();
8 | assert.equal(result, "Mocha Testing");
9 | });
10 | });
11 |
12 | describe("CSV string test",function(){
13 | var CsvParserTestObj;
14 | beforeEach(function(){
15 | CsvParserTestObj=new CsvParserTest("A,2,3\nB,5,6\nC,8,9\nD,11,12\nE,14,15\nF,17,18","testid","csvstring");
16 | })
17 | it('Should Return csvMatrix', function () {
18 | var produced=JSON.stringify(CsvParserTestObj.csvMatrix);
19 | var expected=JSON.stringify([ [ "A", 2, 3 ],[ "B", 5, 6 ],[ "C", 8, 9 ],[ "D", 11, 12 ],[ "E", 14, 15 ],[ "F", 17, 18 ] ]);
20 | assert.equal(produced,expected);
21 | });
22 |
23 | it('Should Return csvHeaders when there are no headers',function(){
24 | var produced=JSON.stringify(CsvParserTestObj.csvHeaders);
25 | var expected=JSON.stringify(["Column1","Column2","Column3"]);
26 | assert.equal(produced,expected);
27 | });
28 |
29 | it('Should Return completeCsvMatrix', function(){
30 | var produced=JSON.stringify(CsvParserTestObj.completeCsvMatrix);
31 | var expected=JSON.stringify([["A","B","C","D","E","F"],[2,5,8,11,14,17],[3,6,9,12,15,18]]);
32 | assert.equal(produced,expected);
33 | });
34 | it('Should Return completeCsvMatrixTranspose', function(){
35 | var produced=JSON.stringify(CsvParserTestObj.completeCsvMatrixTranspose);
36 | var expected=JSON.stringify([["Column1","Column2","Column3"],[ "A", 2, 3 ],[ "B", 5, 6 ],[ "C", 8, 9 ],[ "D", 11, 12 ],[ "E", 14, 15 ],[ "F", 17, 18 ]]);
37 | assert.equal(produced,expected);
38 | });
39 |
40 | it('Should Return csvSampleData', function(){
41 | var produced=JSON.stringify(CsvParserTestObj.csvSampleData);
42 | var expected=JSON.stringify([["A","B","C","D","E"],[2,5,8,11,14],[3,6,9,12,15]]);
43 | assert.equal(produced,expected);
44 | });
45 |
46 | it('Should Return csvValidForYAxis',function(){
47 | var produced=JSON.stringify(CsvParserTestObj.csvValidForYAxis);
48 | var expected=JSON.stringify(["Column2","Column3"]);
49 | assert.equal(produced,expected);
50 | });
51 |
52 | });
53 |
54 |
55 |
56 | describe("CSV googleSheet test",function(){
57 | //googleSheetFileObj contains the data.feed.entry returned after fetching the data
58 | var googleSheetFileObj=[
59 |
60 | {
61 | "id": {
62 | "$t": "https://spreadsheets.google.com/feeds/list/1vfvBKa2e0E1cG310-SnvoYLM_b08g4AucKpYoDQEcOU/od6/public/values/cokwr"
63 | },
64 | "updated": {
65 | "$t": "2019-06-23T10:24:45.578Z"
66 | },
67 | "category": [
68 | {
69 | "scheme": "http://schemas.google.com/spreadsheets/2006",
70 | "term": "http://schemas.google.com/spreadsheets/2006#list"
71 | }
72 | ],
73 | "title": {
74 | "type": "text",
75 | "$t": "1"
76 | },
77 | "content": {
78 | "type": "text",
79 | "$t": "test2: A, test3: 3, test4: D"
80 | },
81 | "link": [
82 | {
83 | "rel": "self",
84 | "type": "application/atom+xml",
85 | "href": "https://spreadsheets.google.com/feeds/list/1vfvBKa2e0E1cG310-SnvoYLM_b08g4AucKpYoDQEcOU/od6/public/values/cokwr"
86 | }
87 | ],
88 | "gsx$test1": {
89 | "$t": "1"
90 | },
91 | "gsx$test2": {
92 | "$t": "A"
93 | },
94 | "gsx$test3": {
95 | "$t": "3"
96 | },
97 | "gsx$test4": {
98 | "$t": "D"
99 | }
100 | },
101 | {
102 | "id": {
103 | "$t": "https://spreadsheets.google.com/feeds/list/1vfvBKa2e0E1cG310-SnvoYLM_b08g4AucKpYoDQEcOU/od6/public/values/cpzh4"
104 | },
105 | "updated": {
106 | "$t": "2019-06-23T10:24:45.578Z"
107 | },
108 | "category": [
109 | {
110 | "scheme": "http://schemas.google.com/spreadsheets/2006",
111 | "term": "http://schemas.google.com/spreadsheets/2006#list"
112 | }
113 | ],
114 | "title": {
115 | "type": "text",
116 | "$t": "2"
117 | },
118 | "content": {
119 | "type": "text",
120 | "$t": "test2: B, test3: 4, test4: E"
121 | },
122 | "link": [
123 | {
124 | "rel": "self",
125 | "type": "application/atom+xml",
126 | "href": "https://spreadsheets.google.com/feeds/list/1vfvBKa2e0E1cG310-SnvoYLM_b08g4AucKpYoDQEcOU/od6/public/values/cpzh4"
127 | }
128 | ],
129 | "gsx$test1": {
130 | "$t": "2"
131 | },
132 | "gsx$test2": {
133 | "$t": "B"
134 | },
135 | "gsx$test3": {
136 | "$t": "4"
137 | },
138 | "gsx$test4": {
139 | "$t": "E"
140 | }
141 | },
142 | {
143 | "id": {
144 | "$t": "https://spreadsheets.google.com/feeds/list/1vfvBKa2e0E1cG310-SnvoYLM_b08g4AucKpYoDQEcOU/od6/public/values/cre1l"
145 | },
146 | "updated": {
147 | "$t": "2019-06-23T10:24:45.578Z"
148 | },
149 | "category": [
150 | {
151 | "scheme": "http://schemas.google.com/spreadsheets/2006",
152 | "term": "http://schemas.google.com/spreadsheets/2006#list"
153 | }
154 | ],
155 | "title": {
156 | "type": "text",
157 | "$t": "11"
158 | },
159 | "content": {
160 | "type": "text",
161 | "$t": "test2: C, test3: 77, test4: F"
162 | },
163 | "link": [
164 | {
165 | "rel": "self",
166 | "type": "application/atom+xml",
167 | "href": "https://spreadsheets.google.com/feeds/list/1vfvBKa2e0E1cG310-SnvoYLM_b08g4AucKpYoDQEcOU/od6/public/values/cre1l"
168 | }
169 | ],
170 | "gsx$test1": {
171 | "$t": "11"
172 | },
173 | "gsx$test2": {
174 | "$t": "C"
175 | },
176 | "gsx$test3": {
177 | "$t": "77"
178 | },
179 | "gsx$test4": {
180 | "$t": "F"
181 | }
182 | }
183 | ]
184 | var CsvParserTestObjGoogleSheet;
185 | beforeEach(function(){
186 | CsvParserTestObjGoogleSheet=new CsvParserTest(googleSheetFileObj,"testid2","googleSheet");
187 | });
188 | it('Should Return csvMatrix googleSheet', function () {
189 | //will return a blank matrix because it is not required in the case of googleSheet
190 | var produced=JSON.stringify(CsvParserTestObjGoogleSheet.csvMatrix);
191 | var expected=JSON.stringify([]);
192 | assert.equal(produced,expected);
193 | });
194 | it('Should Return csvHeaders googleSheet with headers', function () {
195 | var produced=JSON.stringify(CsvParserTestObjGoogleSheet.csvHeaders);
196 | var expected=JSON.stringify(["test1","test2","test3","test4"]);
197 | assert.equal(produced,expected);
198 | });
199 | it('Should Return completeCsvMatrix googleSheet', function () {
200 | var produced=JSON.stringify(CsvParserTestObjGoogleSheet.completeCsvMatrix);
201 | var expected=JSON.stringify([[1,2,11],["A","B","C"],[3,4,77],["D","E","F"]]);
202 | assert.equal(produced,expected);
203 | });
204 | it('Should Return completeCsvMatrixTranspose googleSheet', function () {
205 | var produced=JSON.stringify(CsvParserTestObjGoogleSheet.completeCsvMatrixTranspose);
206 | var expected=JSON.stringify([["test1","test2","test3","test4"],[1,"A",3,"D"],[2,"B",4,"E"],[11,"C",77,"F"]]);
207 | assert.equal(produced,expected);
208 | });
209 | it('Should Return csvSampleData googleSheet', function () {
210 | //length of sampleData is less than 5 in this case
211 | var produced=JSON.stringify(CsvParserTestObjGoogleSheet.csvSampleData);
212 | var expected=JSON.stringify([[1,2,11],["A","B","C"],[3,4,77],["D","E","F"]]);
213 | assert.equal(produced,expected);
214 | });
215 | it('Should Return csvValidForYAxis googleSheet', function () {
216 | var produced=JSON.stringify(CsvParserTestObjGoogleSheet.csvValidForYAxis);
217 | var expected=JSON.stringify(["test1","test3"]);
218 | assert.equal(produced,expected);
219 | });
220 | });
221 | describe("CSV Remote test",function(){
222 | var CsvParserTestObjRemote;
223 | beforeEach(function(){
224 | CsvParserTestObjRemote=new CsvParserTest("A1,B1,,C1,\n1,2,3,4,5\n6,7,8,9,10\n11,12,13,14,15\n16,17,18,19,20\n21,22,23,24,25\n26,27,28,29,30","testid3","remote");
225 | });
226 | it('Should Return csvMatrix remote', function () {
227 | var produced=JSON.stringify(CsvParserTestObjRemote.csvMatrix);
228 | var expected=JSON.stringify([["A1","B1",null,"C1",null],[1,2,3,4,5],[6,7,8,9,10],[11,12,13,14,15],[16,17,18,19,20],[21,22,23,24,25],[26,27,28,29,30]]);
229 | assert.equal(produced,expected);
230 | });
231 | it('Should Return csvHeaders remote', function () {
232 | var produced=JSON.stringify(CsvParserTestObjRemote.csvHeaders);
233 | var expected=JSON.stringify(["A1","B1","Column3","C1","Column5"]);
234 | assert.equal(produced,expected);
235 | });
236 | it('Should Return completeCsvMatrix remote', function () {
237 | var produced=JSON.stringify(CsvParserTestObjRemote.completeCsvMatrix);
238 | var expected=JSON.stringify([[1,6,11,16,21,26],[2,7,12,17,22,27],[3,8,13,18,23,28],[4,9,14,19,24,29],[5,10,15,20,25,30]]);
239 | assert.equal(produced,expected);
240 | });
241 | it('Should Return completeCsvMatrixTranspose remote', function () {
242 | var produced=JSON.stringify(CsvParserTestObjRemote.completeCsvMatrixTranspose);
243 | var expected=JSON.stringify([["A1","B1","Column3","C1","Column5"],[1,2,3,4,5],[6,7,8,9,10],[11,12,13,14,15],[16,17,18,19,20],[21,22,23,24,25],[26,27,28,29,30]]);
244 | assert.equal(produced,expected);
245 | });
246 | it('Should Return csvSampleData remote', function () {
247 | var produced=JSON.stringify(CsvParserTestObjRemote.csvSampleData);
248 | var expected=JSON.stringify([[1,6,11,16,21],[2,7,12,17,22],[3,8,13,18,23],[4,9,14,19,24],[5,10,15,20,25]]);
249 | assert.equal(produced,expected);
250 | });
251 | it('Should Return csvValidForYAxis remote', function () {
252 | var produced=JSON.stringify(CsvParserTestObjRemote.csvValidForYAxis);
253 | var expected=JSON.stringify(["A1","B1","Column3","C1","Column5"]);
254 | assert.equal(produced,expected);
255 | });
256 |
257 | });
--------------------------------------------------------------------------------
/src/CsvParser.js:
--------------------------------------------------------------------------------
1 | // import {SimpleDataGrapher} from "./SimpleDataGrapher";
2 | const SimpleDataGrapher = require('./SimpleDataGrapher');
3 | const Papa = require("papaparse");
4 | class CsvParser {
5 |
6 | 'use strict';
7 |
8 | csvFile = null;
9 | csvMatrix = [];
10 | csvHeaders = [];
11 | csvFileStart = 1; //start is variable that will be passed to the function to sort out the columns. start will tell if the existing CSV file has headers or not, therefore, to start the iteration from 0 or 1 Used in header determination
12 | completeCsvMatrix = [];
13 | completeCsvMatrixTranspose = [];
14 | csvSampleData = [];
15 | csvValidForYAxis = [];
16 | elementId = null;
17 | codapHeaders = [];
18 | codapMatrix = [];
19 |
20 | constructor(file, elementId, functionParameter) {
21 | this.elementId = elementId;
22 | this.csvFile = file;
23 | if (functionParameter == "prevfile") {
24 | return this;
25 | } else {
26 | this.allFunctionHandler(functionParameter);
27 | }
28 |
29 | }
30 | //since parsing a local file works asynchronously, a callback function is required to call the remaining functions after the parsing is complete
31 | callbackForLocalFile(csvMatrixLocal) {
32 | this.csvMatrix = csvMatrixLocal;
33 | this.csvHeaders = this.determineHeaders();
34 | this.completeCsvMatrix = this.matrixForCompleteData();
35 | var totalData = this.extractSampleData();
36 | this.csvSampleData = totalData[0];
37 | this.csvValidForYAxis = totalData[1];
38 | this.completeCsvMatrixTranspose = this.createTranspose();
39 | this.codapHeaders = this.headersForCodap();
40 | this.codapMatrix = this.completeMatrixForCodap();
41 | this.startFileProcessing();
42 | }
43 | //a function handler that calls one function after the other after assigning the correct values to different class variables.
44 | allFunctionHandler(functionParameter) {
45 | if (functionParameter == "local") {
46 | this.csvMatrix = this.parse();
47 | } else {
48 | if (functionParameter == "csvstring" || functionParameter == "remote") {
49 | this.csvFile = this.csvFile.split("\n");
50 | this.csvMatrix = this.parseString();
51 | this.csvHeaders = this.determineHeaders();
52 | this.completeCsvMatrix = this.matrixForCompleteData();
53 | } else {
54 | this.csvHeaders = this.headersForGoogleSheet();
55 | this.completeCsvMatrix = this.completeMatrixForGoogleSheet();
56 | }
57 | var totalData = this.extractSampleData();
58 | this.csvSampleData = totalData[0];
59 | this.csvValidForYAxis = totalData[1];
60 | this.completeCsvMatrixTranspose = this.createTranspose();
61 | this.codapHeaders = this.headersForCodap();
62 | this.codapMatrix = this.completeMatrixForCodap();
63 | this.startFileProcessing();
64 | }
65 |
66 | }
67 | //parsing a local file, works asynchronously
68 | parse() {
69 | var csvMatrixLocal = [];
70 | var count = 0;
71 | Papa.parse(this.csvFile, {
72 | download: true,
73 | dynamicTyping: true,
74 | comments: true,
75 | step: (row) => {
76 | csvMatrixLocal[count] = row.data[0];
77 | count += 1;
78 | },
79 | complete: () => {
80 | this.callbackForLocalFile(csvMatrixLocal);
81 |
82 | }
83 | });
84 | }
85 | // parsing string: for remote and csvString import options. Dat is parsed line by line but NOT asynchronously.
86 | parseString() {
87 | var mat = [];
88 | for (var i = 0; i < this.csvFile.length; i++) {
89 | if (this.csvFile[i] == "" || this.csvFile[i] == " ") {
90 | continue;
91 | }
92 | var dataHash = Papa.parse(this.csvFile[i], {
93 | dynamicTyping: true,
94 | comments: true
95 | });
96 | mat[i] = dataHash['data'][0];
97 | }
98 | return mat;
99 | }
100 | // checks for the presence of the corresponding View object in elementIdSimpleDataGraphInstanceMap, if present, the CsvParser object is assigned to the View object and the flow resumes from View.js file
101 | startFileProcessing() {
102 | let self = this;
103 | if (self.elementId in SimpleDataGrapher.SimpleDataGrapher.elementIdSimpleDataGraphInstanceMap) {
104 | SimpleDataGrapher.SimpleDataGrapher.elementIdSimpleDataGraphInstanceMap[self.elementId].view.continueViewManipulation(self);
105 | }
106 | }
107 |
108 | //preparing sample data for the user to choose the columns from
109 | extractSampleData() {
110 | var maxval = 5;
111 | var csvSampleDataLocal = [];
112 | var csvValidForYAxisLocal = [];
113 | var totalDataLocal = [];
114 | for (var i = 0; i < this.csvHeaders.length; i++) {
115 | csvSampleDataLocal[i] = [];
116 | }
117 | if (this.completeCsvMatrix.length[0] < 5) {
118 | maxval = this.completeCsvMatrix[0].length;
119 | }
120 | for (var i = 0; i < this.csvHeaders.length; i++) {
121 | var counter = 0;
122 |
123 | var bool = false;
124 | for (var j = 0; j < this.completeCsvMatrix[i].length; j++) {
125 | if (counter >= maxval) {
126 | break;
127 | } else if (this.completeCsvMatrix[i][j] !== null || this.completeCsvMatrix[i][j] !== undefined) {
128 | if (typeof (this.completeCsvMatrix[i][j]) === 'number') {
129 | bool = true;
130 | }
131 | counter += 1;
132 | csvSampleDataLocal[i].push(this.completeCsvMatrix[i][j]);
133 | }
134 | }
135 | if (bool) {
136 | csvValidForYAxisLocal.push(this.csvHeaders[i]);
137 | }
138 | }
139 | totalDataLocal = [csvSampleDataLocal, csvValidForYAxisLocal];
140 | return totalDataLocal;
141 |
142 | }
143 |
144 | //makes a 2D matrix with the transpose of the CSV file, each column having the same index as its column heading
145 | matrixForCompleteData() {
146 | var completeCsvMatrixLocal = [];
147 | for (var i = 0; i < this.csvHeaders.length; i++) {
148 | completeCsvMatrixLocal[i] = [];
149 | }
150 | for (var i = this.csvFileStart; i < this.csvMatrix.length; i++) {
151 | for (var j = 0; j < this.csvHeaders.length; j++) {
152 | completeCsvMatrixLocal[j].push(this.csvMatrix[i][j]);
153 | }
154 | }
155 | return completeCsvMatrixLocal;
156 | }
157 | //Google Sheet's data is in a JSON, traversal through the JSON and string manipulation are used to extract the data
158 | completeMatrixForGoogleSheet() {
159 | var matrixComplete = [];
160 | for (var i = 0; i < this.csvHeaders.length; i++) {
161 | matrixComplete[i] = [];
162 | }
163 | for (var i = 0; i < this.csvHeaders.length; i++) {
164 | for (var key in this.csvFile) {
165 | var valueCell = this.csvFile[key][this.csvHeaders[i]]["$t"];
166 | if (!isNaN(valueCell)) {
167 | matrixComplete[i].push(+valueCell);
168 | } else {
169 | matrixComplete[i].push(valueCell);
170 | }
171 | }
172 | }
173 | for (var i = 0; i < this.csvHeaders.length; i++) {
174 | this.csvHeaders[i] = this.csvHeaders[i].slice(4, this.csvHeaders[i].length);
175 | }
176 | return matrixComplete;
177 | }
178 | // matrix in JSON form for CODAP export
179 | completeMatrixForCodap() {
180 | var codapMatrix = [];
181 | for (var i = 1; i < this.completeCsvMatrixTranspose.length; i++) {
182 | var element = {};
183 | for (var j = 0; j < this.csvHeaders.length; j++) {
184 | element[this.csvHeaders[j]] = this.completeCsvMatrixTranspose[i][j];
185 | }
186 | codapMatrix.push(element);
187 | }
188 | return codapMatrix;
189 | }
190 | //checks if the first row has most of the potential header names, if not, assign dummy headers to the file.
191 | determineHeaders() {
192 | var csvHeadersLocal = [];
193 | var flag = false;
194 | for (var i = 0; i < this.csvMatrix[0].length; i++) {
195 | if (i == 0) {
196 | if (typeof (this.csvMatrix[0][i]) == "string") {
197 | csvHeadersLocal[i] = this.csvMatrix[0][i];
198 | } else {
199 | flag = true;
200 | break;
201 | }
202 | } else {
203 | if ((typeof (this.csvMatrix[0][i]) == typeof (this.csvMatrix[0][i - 1]) && typeof (this.csvMatrix[0][i]) != 'object') || (typeof (this.csvMatrix[0][i]) != typeof (this.csvMatrix[0][i - 1]) && csvHeadersLocal[i - 1].substring(0, 6) == "Column")) {
204 | csvHeadersLocal[i] = this.csvMatrix[0][i];
205 | }
206 | //in case of an unnamed column
207 | else if (typeof (this.csvMatrix[0][i]) == 'object') {
208 |
209 | csvHeadersLocal[i] = "Column" + (i + 1);
210 | } else {
211 | flag = true;
212 | break;
213 | }
214 | }
215 | }
216 | //if there are no headers present, make dummy header names
217 | if (flag && csvHeadersLocal.length != this.csvMatrix[0].length) {
218 | this.csvFileStart = 0;
219 | for (var i = 0; i < this.csvMatrix[0].length; i++) {
220 | csvHeadersLocal[i] = "Column" + (i + 1);
221 | }
222 | }
223 | return csvHeadersLocal;
224 | }
225 | //Google Sheet's data is in a JSON, extracting column names by string slicing
226 | headersForGoogleSheet() {
227 | var headers_sheet = [];
228 | for (var key in this.csvFile) {
229 | var h = this.csvFile[key];
230 | for (var headKey in h) {
231 | if (headKey.slice(0, 4) == "gsx$") {
232 | headers_sheet.push(headKey);
233 | }
234 | }
235 | break;
236 | }
237 | return headers_sheet;
238 | }
239 | //determine a JSON for headers for CODAP
240 | headersForCodap() {
241 | var codapHeaders = [];
242 | for (var i = 0; i < this.csvHeaders.length; i++) {
243 | var element = {};
244 | element["name"] = this.csvHeaders[i];
245 | codapHeaders.push(element);
246 | }
247 | return codapHeaders;
248 | }
249 | // creating the transpose of the entire data ie complete data + headers, for createSpreadsheet in View.js
250 | createTranspose() {
251 | var completeCsvMatrixTransposeLocal = [];
252 | for (var i = 0; i <= this.completeCsvMatrix[0].length; i++) {
253 | completeCsvMatrixTransposeLocal[i] = [];
254 | }
255 | for (var i = 0; i < this.completeCsvMatrix.length; i++) {
256 | completeCsvMatrixTransposeLocal[0][i] = this.csvHeaders[i];
257 | }
258 | for (var i = 0; i < this.completeCsvMatrix.length; i++) {
259 | for (var j = 0; j < this.completeCsvMatrix[0].length; j++) {
260 | completeCsvMatrixTransposeLocal[j + 1][i] = this.completeCsvMatrix[i][j];
261 | }
262 | }
263 | return completeCsvMatrixTransposeLocal;
264 | }
265 | };
266 |
267 | module.exports = CsvParser;
268 |
--------------------------------------------------------------------------------
/dist/transpiled_code/CsvParser.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4 |
5 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6 |
7 | function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
8 |
9 | function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
10 |
11 | function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
12 |
13 | // import {SimpleDataGrapher} from "./SimpleDataGrapher";
14 | var SimpleDataGrapher = require('./SimpleDataGrapher');
15 |
16 | var Papa = require("papaparse");
17 |
18 | var CsvParser =
19 | /*#__PURE__*/
20 | function () {
21 | //start is variable that will be passed to the function to sort out the columns. start will tell if the existing CSV file has headers or not, therefore, to start the iteration from 0 or 1 Used in header determination
22 | function CsvParser(file, elementId, functionParameter) {
23 | _classCallCheck(this, CsvParser);
24 |
25 | _defineProperty(this, 'use strict', void 0);
26 |
27 | _defineProperty(this, "csvFile", null);
28 |
29 | _defineProperty(this, "csvMatrix", []);
30 |
31 | _defineProperty(this, "csvHeaders", []);
32 |
33 | _defineProperty(this, "csvFileStart", 1);
34 |
35 | _defineProperty(this, "completeCsvMatrix", []);
36 |
37 | _defineProperty(this, "completeCsvMatrixTranspose", []);
38 |
39 | _defineProperty(this, "csvSampleData", []);
40 |
41 | _defineProperty(this, "csvValidForYAxis", []);
42 |
43 | _defineProperty(this, "elementId", null);
44 |
45 | _defineProperty(this, "codapHeaders", []);
46 |
47 | _defineProperty(this, "codapMatrix", []);
48 |
49 | this.elementId = elementId;
50 | this.csvFile = file;
51 |
52 | if (functionParameter == "prevfile") {
53 | return this;
54 | } else {
55 | this.allFunctionHandler(functionParameter);
56 | }
57 | } //since parsing a local file works asynchronously, a callback function is required to call the remaining functions after the parsing is complete
58 |
59 |
60 | _createClass(CsvParser, [{
61 | key: "callbackForLocalFile",
62 | value: function callbackForLocalFile(csvMatrixLocal) {
63 | this.csvMatrix = csvMatrixLocal;
64 | this.csvHeaders = this.determineHeaders();
65 | this.completeCsvMatrix = this.matrixForCompleteData();
66 | var totalData = this.extractSampleData();
67 | this.csvSampleData = totalData[0];
68 | this.csvValidForYAxis = totalData[1];
69 | this.completeCsvMatrixTranspose = this.createTranspose();
70 | this.codapHeaders = this.headersForCodap();
71 | this.codapMatrix = this.completeMatrixForCodap();
72 | this.startFileProcessing();
73 | } //a function handler that calls one function after the other after assigning the correct values to different class variables.
74 |
75 | }, {
76 | key: "allFunctionHandler",
77 | value: function allFunctionHandler(functionParameter) {
78 | if (functionParameter == "local") {
79 | this.csvMatrix = this.parse();
80 | } else {
81 | if (functionParameter == "csvstring" || functionParameter == "remote") {
82 | this.csvFile = this.csvFile.split("\n");
83 | this.csvMatrix = this.parseString();
84 | this.csvHeaders = this.determineHeaders();
85 | this.completeCsvMatrix = this.matrixForCompleteData();
86 | } else {
87 | this.csvHeaders = this.headersForGoogleSheet();
88 | this.completeCsvMatrix = this.completeMatrixForGoogleSheet();
89 | }
90 |
91 | var totalData = this.extractSampleData();
92 | this.csvSampleData = totalData[0];
93 | this.csvValidForYAxis = totalData[1];
94 | this.completeCsvMatrixTranspose = this.createTranspose();
95 | this.codapHeaders = this.headersForCodap();
96 | this.codapMatrix = this.completeMatrixForCodap();
97 | this.startFileProcessing();
98 | }
99 | } //parsing a local file, works asynchronously
100 |
101 | }, {
102 | key: "parse",
103 | value: function parse() {
104 | var _this = this;
105 |
106 | var csvMatrixLocal = [];
107 | var count = 0;
108 | var f = this.parseReturn;
109 | Papa.parse(this.csvFile, {
110 | download: true,
111 | dynamicTyping: true,
112 | comments: true,
113 | step: function step(row) {
114 | csvMatrixLocal[count] = row.data[0];
115 | count += 1;
116 | },
117 | complete: function complete() {
118 | _this.callbackForLocalFile(csvMatrixLocal);
119 | }
120 | });
121 | } // parsing string: for remote and csvString import options. Dat is parsed line by line but NOT asynchronously.
122 |
123 | }, {
124 | key: "parseString",
125 | value: function parseString() {
126 | var mat = [];
127 |
128 | for (var i = 0; i < this.csvFile.length; i++) {
129 | if (this.csvFile[i] == "" || this.csvFile[i] == " ") {
130 | continue;
131 | }
132 |
133 | var dataHash = Papa.parse(this.csvFile[i], {
134 | dynamicTyping: true,
135 | comments: true
136 | });
137 | mat[i] = dataHash['data'][0];
138 | }
139 |
140 | return mat;
141 | } // checks for the presence of the corresponding View object in elementIdSimpleDataGraphInstanceMap, if present, the CsvParser object is assigned to the View object and the flow resumes from View.js file
142 |
143 | }, {
144 | key: "startFileProcessing",
145 | value: function startFileProcessing() {
146 | var self = this;
147 |
148 | if (self.elementId in SimpleDataGrapher.SimpleDataGrapher.elementIdSimpleDataGraphInstanceMap) {
149 | SimpleDataGrapher.SimpleDataGrapher.elementIdSimpleDataGraphInstanceMap[self.elementId].view.continueViewManipulation(self);
150 | }
151 | } //preparing sample data for the user to choose the columns from
152 |
153 | }, {
154 | key: "extractSampleData",
155 | value: function extractSampleData() {
156 | var maxval = 5;
157 | var csvSampleDataLocal = [];
158 | var csvValidForYAxisLocal = [];
159 | var totalDataLocal = [];
160 |
161 | for (var i = 0; i < this.csvHeaders.length; i++) {
162 | csvSampleDataLocal[i] = [];
163 | }
164 |
165 | if (this.completeCsvMatrix.length[0] < 5) {
166 | maxval = this.completeCsvMatrix[0].length;
167 | }
168 |
169 | for (var i = 0; i < this.csvHeaders.length; i++) {
170 | var counter = 0;
171 | var bool = false;
172 |
173 | for (var j = 0; j < this.completeCsvMatrix[i].length; j++) {
174 | if (counter >= maxval) {
175 | break;
176 | } else if (this.completeCsvMatrix[i][j] !== null || this.completeCsvMatrix[i][j] !== undefined) {
177 | if (typeof this.completeCsvMatrix[i][j] === 'number') {
178 | bool = true;
179 | }
180 |
181 | counter += 1;
182 | csvSampleDataLocal[i].push(this.completeCsvMatrix[i][j]);
183 | }
184 | }
185 |
186 | if (bool) {
187 | csvValidForYAxisLocal.push(this.csvHeaders[i]);
188 | }
189 | }
190 |
191 | totalDataLocal = [csvSampleDataLocal, csvValidForYAxisLocal];
192 | return totalDataLocal;
193 | } //makes a 2D matrix with the transpose of the CSV file, each column having the same index as its column heading
194 |
195 | }, {
196 | key: "matrixForCompleteData",
197 | value: function matrixForCompleteData() {
198 | var completeCsvMatrixLocal = [];
199 |
200 | for (var i = 0; i < this.csvHeaders.length; i++) {
201 | completeCsvMatrixLocal[i] = [];
202 | }
203 |
204 | for (var i = this.csvFileStart; i < this.csvMatrix.length; i++) {
205 | for (var j = 0; j < this.csvHeaders.length; j++) {
206 | completeCsvMatrixLocal[j].push(this.csvMatrix[i][j]);
207 | }
208 | }
209 |
210 | return completeCsvMatrixLocal;
211 | } //Google Sheet's data is in a JSON, traversal through the JSON and string manipulation are used to extract the data
212 |
213 | }, {
214 | key: "completeMatrixForGoogleSheet",
215 | value: function completeMatrixForGoogleSheet() {
216 | var matrixComplete = [];
217 |
218 | for (var i = 0; i < this.csvHeaders.length; i++) {
219 | matrixComplete[i] = [];
220 | }
221 |
222 | for (var i = 0; i < this.csvHeaders.length; i++) {
223 | for (var key in this.csvFile) {
224 | var valueCell = this.csvFile[key][this.csvHeaders[i]]["$t"];
225 |
226 | if (!isNaN(valueCell)) {
227 | matrixComplete[i].push(+valueCell);
228 | } else {
229 | matrixComplete[i].push(valueCell);
230 | }
231 | }
232 | }
233 |
234 | for (var i = 0; i < this.csvHeaders.length; i++) {
235 | this.csvHeaders[i] = this.csvHeaders[i].slice(4, this.csvHeaders[i].length);
236 | }
237 |
238 | return matrixComplete;
239 | } // matrix in JSON form for CODAP export
240 |
241 | }, {
242 | key: "completeMatrixForCodap",
243 | value: function completeMatrixForCodap() {
244 | var codapMatrix = [];
245 |
246 | for (var i = 1; i < this.completeCsvMatrixTranspose.length; i++) {
247 | var element = {};
248 |
249 | for (var j = 0; j < this.csvHeaders.length; j++) {
250 | element[this.csvHeaders[j]] = this.completeCsvMatrixTranspose[i][j];
251 | }
252 |
253 | codapMatrix.push(element);
254 | }
255 |
256 | return codapMatrix;
257 | } //checks if the first row has most of the potential header names, if not, assign dummy headers to the file.
258 |
259 | }, {
260 | key: "determineHeaders",
261 | value: function determineHeaders() {
262 | var csvHeadersLocal = [];
263 | var flag = false;
264 |
265 | for (var i = 0; i < this.csvMatrix[0].length; i++) {
266 | if (i == 0) {
267 | if (typeof this.csvMatrix[0][i] == "string") {
268 | csvHeadersLocal[i] = this.csvMatrix[0][i];
269 | } else {
270 | flag = true;
271 | break;
272 | }
273 | } else {
274 | if (_typeof(this.csvMatrix[0][i]) == _typeof(this.csvMatrix[0][i - 1]) && _typeof(this.csvMatrix[0][i]) != 'object' || _typeof(this.csvMatrix[0][i]) != _typeof(this.csvMatrix[0][i - 1]) && csvHeadersLocal[i - 1].substring(0, 6) == "Column") {
275 | csvHeadersLocal[i] = this.csvMatrix[0][i];
276 | } //in case of an unnamed column
277 | else if (_typeof(this.csvMatrix[0][i]) == 'object') {
278 | csvHeadersLocal[i] = "Column" + (i + 1);
279 | } else {
280 | flag = true;
281 | break;
282 | }
283 | }
284 | } //if there are no headers present, make dummy header names
285 |
286 |
287 | if (flag && csvHeadersLocal.length != this.csvMatrix[0].length) {
288 | this.csvFileStart = 0;
289 |
290 | for (var i = 0; i < this.csvMatrix[0].length; i++) {
291 | csvHeadersLocal[i] = "Column" + (i + 1);
292 | }
293 | }
294 |
295 | return csvHeadersLocal;
296 | } //Google Sheet's data is in a JSON, extracting column names by string slicing
297 |
298 | }, {
299 | key: "headersForGoogleSheet",
300 | value: function headersForGoogleSheet() {
301 | var headers_sheet = [];
302 |
303 | for (var key in this.csvFile) {
304 | var h = this.csvFile[key];
305 |
306 | for (var headKey in h) {
307 | if (headKey.slice(0, 4) == "gsx$") {
308 | headers_sheet.push(headKey);
309 | }
310 | }
311 |
312 | break;
313 | }
314 |
315 | return headers_sheet;
316 | } //determine a JSON for headers for CODAP
317 |
318 | }, {
319 | key: "headersForCodap",
320 | value: function headersForCodap() {
321 | var codapHeaders = [];
322 |
323 | for (var i = 0; i < this.csvHeaders.length; i++) {
324 | var element = {};
325 | element["name"] = this.csvHeaders[i];
326 | codapHeaders.push(element);
327 | }
328 |
329 | return codapHeaders;
330 | } // creating the transpose of the entire data ie complete data + headers, for createSpreadsheet in View.js
331 |
332 | }, {
333 | key: "createTranspose",
334 | value: function createTranspose() {
335 | var completeCsvMatrixTransposeLocal = [];
336 |
337 | for (var i = 0; i <= this.completeCsvMatrix[0].length; i++) {
338 | completeCsvMatrixTransposeLocal[i] = [];
339 | }
340 |
341 | for (var i = 0; i < this.completeCsvMatrix.length; i++) {
342 | completeCsvMatrixTransposeLocal[0][i] = this.csvHeaders[i];
343 | }
344 |
345 | for (var i = 0; i < this.completeCsvMatrix.length; i++) {
346 | for (var j = 0; j < this.completeCsvMatrix[0].length; j++) {
347 | completeCsvMatrixTransposeLocal[j + 1][i] = this.completeCsvMatrix[i][j];
348 | }
349 | }
350 |
351 | return completeCsvMatrixTransposeLocal;
352 | }
353 | }]);
354 |
355 | return CsvParser;
356 | }();
357 |
358 | ;
359 | module.exports = CsvParser;
--------------------------------------------------------------------------------
/src-old/parsing.js:
--------------------------------------------------------------------------------
1 | var counting=0;
2 | function saveAsImage(){
3 | console.log("at image");
4 | var x=new Date();
5 | var timestamp=x.getTime();
6 | $("#save_as_image").click(function() {
7 | $("#canvas").get(0).toBlob(function(blob) {
8 | saveAs(blob, "chart"+timestamp);
9 | });
10 | });
11 | }
12 | function colorBackground(ctx,canv){
13 | Chart.plugins.register({
14 | beforeDraw: function() {
15 | ctx.fillStyle = 'white';
16 | ctx.fillRect(0, 0, canv.width, canv.height);
17 | }
18 | });
19 | }
20 | function determineType(type){
21 | console.log("at type");
22 | if (type=="Basic" || type=="Stepped" || type=="Point"){
23 | return 'line';
24 | }
25 | else if (type=="Horizontal"){
26 | return 'horizontalBar';
27 | }
28 | else if (type=="Vertical"){
29 |
30 | return 'bar';
31 | }
32 | else{
33 | return type.toLowerCase();
34 | }
35 | }
36 | function determineData(type,i,hash){
37 | console.log("at data");
38 | h={};
39 | if (type=="Basic"){
40 | h['fill'] = false;
41 | }
42 | else if (type=="Stepped"){
43 | h['steppedLine']= true;
44 | h['fill']= false;
45 | }
46 | else if (type=="Point"){
47 | h['showLine']= false;
48 | h['pointRadius']= 10;
49 | }
50 | h['backgroundColor']=colorGenerator(i,"bg",type,hash['y_axis_values'+i].length);
51 | h['borderColor']=colorGenerator(i,"bo",type,hash['y_axis_values'+i].length);
52 | h['borderWidth']=1;
53 | h['label']=hash['labels'][1][i];
54 | h['data']=hash['y_axis_values'+i];
55 | return h;
56 |
57 | }
58 | function graphMenu(){
59 | console.log("at menu");
60 | document.getElementById("graph_menu").innerHTML="";
61 | var bar=["Bar","Horizontal","Vertical"];
62 | var line=["Line","Basic","Stepped","Point"];
63 | var disc=["Disc","Pie","Doughnut","Radar"];
64 | var types=[bar,line,disc];
65 | for (var i=0;i<3;i++){
66 | var tr=document.createElement('tr');
67 | var td_head=document.createElement('td');
68 | td_head.className=types[i][0];
69 | td_head.appendChild(document.createTextNode(types[i][0]));
70 | tr.appendChild(td_head);
71 | for (var j=1;j=maxval){
278 | break;
279 | }
280 | else if (completeData[i][j]!=null || completeData[i][j]!=undefined){
281 | if (typeof(completeData[i][j])=='number'){
282 | bool=true;
283 | }
284 | counter+=1;
285 | sampleData[i].push(completeData[i][j]);}
286 | }
287 | if (bool){
288 | validForYAxis.push(headers[i]);
289 | }
290 | }
291 | console.log(sampleData,"sampleData");
292 | console.log(validForYAxis);
293 | sampleDataXandY(sampleData,headers,validForYAxis,completeData);
294 |
295 | }
296 | //makes a 2D matrix with the transpose of the CSV file, each column having the same index as its column heading
297 | function matrixForCompleteData(headers,mat,start){
298 | var completeData=[];
299 | for (var i=0;i= maxval) {
309 | break;
310 | } else if (completeData[i][j] != null || completeData[i][j] != undefined) {
311 | if (typeof completeData[i][j] == 'number') {
312 | bool = true;
313 | }
314 |
315 | counter += 1;
316 | sampleData[i].push(completeData[i][j]);
317 | }
318 | }
319 |
320 | if (bool) {
321 | validForYAxis.push(headers[i]);
322 | }
323 | }
324 |
325 | console.log(sampleData, "sampleData");
326 | console.log(validForYAxis);
327 | sampleDataXandY(sampleData, headers, validForYAxis, completeData);
328 | } //makes a 2D matrix with the transpose of the CSV file, each column having the same index as its column heading
329 |
330 |
331 | function matrixForCompleteData(headers, mat, start) {
332 | var completeData = [];
333 |
334 | for (var i = 0; i < headers.length; i++) {
335 | completeData[i] = [];
336 | }
337 |
338 | for (var i = start; i < mat.length; i++) {
339 | for (var j = 0; j < headers.length; j++) {
340 | completeData[j].push(mat[i][j]);
341 | }
342 | }
343 |
344 | console.log(completeData, "completeData");
345 | extractSampleData(completeData, headers);
346 | } //determines headers for columns
347 |
348 |
349 | function determineHeaders(mat) {
350 | var headers = [];
351 | var flag = false;
352 | var start = 1; //start is variable that will be passed to the function to sort out the columns. start will tell if the existing CSV file has headers or not, therefore, to start the iteration from 0 or 1
353 |
354 | for (var i = 0; i < mat[0].length; i++) {
355 | if (i == 0) {
356 | headers[i] = mat[0][i];
357 | } else {
358 | if (_typeof(mat[0][i]) == _typeof(mat[0][i - 1]) && _typeof(mat[0][i]) != 'object') {
359 | headers[i] = mat[0][i];
360 | } else if (_typeof(mat[0][i]) == 'object') {
361 | headers[i] = "Column" + (i + 1);
362 | } else {
363 | flag = true;
364 | break;
365 | }
366 | }
367 | } //if there are no headers present, make dummy header names
368 |
369 |
370 | if (flag && headers.length != mat[0].length) {
371 | start = 0;
372 |
373 | for (var i = 0; i < mat[0].length; i++) {
374 | headers[i] = "Column" + (i + 1);
375 | }
376 | }
377 |
378 | console.log(headers);
379 | matrixForCompleteData(headers, mat, start);
380 | } //using papaparse, parsing the retrieved file
381 |
382 |
383 | function parse(file) {
384 | var mat = [];
385 | var count = 0;
386 | Papa.parse(file, {
387 | download: true,
388 | dynamicTyping: true,
389 | comments: true,
390 | step: function step(row) {
391 | mat[count] = row.data[0];
392 | count += 1;
393 | },
394 | complete: function complete() {
395 | console.log(mat);
396 | $('.carousel').carousel(1); //calling a function to determine headers for columns
397 |
398 | determineHeaders(mat);
399 | }
400 | });
401 | }
402 |
403 | function parse_string(stringVal) {
404 | var values = Papa.parse(stringVal, {
405 | dynamicTyping: true,
406 | comments: true
407 | });
408 | console.log(values);
409 | } //extracts the file uploaded in the field
410 |
411 |
412 | function handleFileSelectlocal(evt) {
413 | var csv_file_local = evt.target.files[0];
414 |
415 | if (csv_file_local['name'].split(".")[1] != "csv") {
416 | alert("Invalid file type");
417 | } else {
418 | $('.drag_drop_heading').text(csv_file_local['name']);
419 |
420 | document.getElementById("upload").onclick = function (e) {
421 | parse(csv_file_local);
422 | };
423 | }
424 | } //reads the input from the text field in which the link of the remote file is included
425 |
426 |
427 | function handleFileSelectremote(val) {
428 | var csv_file_remote = val;
429 | var l = csv_file_remote.length;
430 |
431 | if (csv_file_remote.slice(l - 3, l) != "csv") {
432 | alert("Invalid URL");
433 | } else {
434 | document.getElementById("upload").onclick = function (e) {
435 | parse(csv_file_remote);
436 | };
437 | }
438 | }
439 |
440 | function handleFileSelectstring(val) {
441 | var csv_string = val.split("\n");
442 | var mat = [];
443 |
444 | document.getElementById("upload").onclick = function (e) {
445 | for (var i = 0; i < csv_string.length; i++) {
446 | if (csv_string[i] == "" || csv_string[i] == " ") {
447 | continue;
448 | }
449 |
450 | var dataHash = Papa.parse(csv_string[i], {
451 | dynamicTyping: true,
452 | comments: true
453 | });
454 | mat[i] = dataHash['data'][0];
455 | }
456 |
457 | console.log(mat);
458 | $('.carousel').carousel(1);
459 | determineHeaders(mat);
460 | };
461 | } //this triggers handleFileSelectLocal function whenever a file is uploaded in the field
462 |
463 |
464 | $(document).ready(function () {
465 | $(".csv_file").change(handleFileSelectlocal);
466 | $(".remote_file").on('change', function () {
467 | handleFileSelectremote(this.value);
468 | });
469 | $(".csv_string").on('change', function () {
470 | handleFileSelectstring(this.value);
471 | });
472 | });
473 |
474 | document.getElementById("update_graph").onclick = function (e) {
475 | $('.carousel').carousel(1);
476 | };
477 |
478 | $('.carousel').carousel({
479 | interval: false
480 | });
481 | $('.xytoggle').bootstrapToggle({
482 | on: 'X-Axis',
483 | off: 'Y-Axis'
484 | });
485 | $('input[name=xy]:checked').change(function () {
486 | var ixy = $('input[name=xy]:checked').val();
487 | var ixx = 0;
488 |
489 | if (ixy == undefined) {
490 | ixx = 1;
491 | }
492 |
493 | $('#xtable').toggle(ixx === 0);
494 | $('#ytable').toggle(ixx === 1);
495 | });
--------------------------------------------------------------------------------
/src/View.js:
--------------------------------------------------------------------------------
1 | const CsvParser = require('./CsvParser');
2 | const SimpleDataGrapher = require('./SimpleDataGrapher');
3 | const ChartjsPlotter = require('./ChartjsPlotter');
4 | const PlotlyjsPlotter = require('./PlotlyjsPlotter');
5 | const iframe_phone = require('iframe-phone')
6 |
7 | class View {
8 | 'use strict';
9 | elementId = null;
10 | element = null;
11 | fileUploadId = null;
12 | remoteFileUploadId = null;
13 | csvStringUploadId = null;
14 | googleSheetUploadId = null;
15 | csvFile = null;
16 | dragDropHeadingId = null;
17 | uploadButtonId = null;
18 | csvParser = null;
19 | chartjsPlotter = null;
20 | plotlyjsPlotter = null;
21 | graphCounting = 0;
22 | addGraphButtonId = null;
23 | tableXId = null;
24 | tableYId = null;
25 | tableXInputName = null;
26 | tableYInputName = null;
27 | carousalClass = null;
28 | carousalId = null;
29 | graphMenuId = null;
30 | plotGraphId = null;
31 | graphMenuTypeInputName = null;
32 | canvasContinerId = null;
33 | xyToggle = null;
34 | xyToggleName = null;
35 | tableXParentId = null;
36 | tableYParentId = null;
37 | upload_button_container = null;
38 | fileTitle = "";
39 | fileDescription = "";
40 | codapExportButton = null;
41 | //extracts the uploaded file from input field and creates an object of CsvParser class with the file as one of the parameters
42 | handleFileSelectlocal(event) {
43 | this.csvFile = event.target.files[0];
44 | if (this.csvFile['name'].split(".")[1] != "csv") {
45 | alert("Invalid file type");
46 | } else {
47 | $('#' + this.dragDropHeadingId).text(this.csvFile['name']);
48 | let self = this;
49 | document.getElementById(this.uploadButtonId).onclick = (e) => {
50 | self.csvParser = new CsvParser(self.csvFile, self.elementId, "local");
51 | }
52 | }
53 | }
54 | //receives the string value and creates an object of CsvParser class with the string as one of the parameters
55 | handleFileSelectstring(val) {
56 | // var csv_string = val.split("\n");
57 | this.csvFile = val;
58 | let self = this;
59 | document.getElementById(this.uploadButtonId).onclick = (e) => {
60 | self.csvParser = new CsvParser(self.csvFile, self.elementId, "csvstring");
61 | };
62 |
63 | }
64 | // function for using a previously uploaded and saved file from the data base
65 | usingPreviouslyUploadedFile() {
66 | let self = this;
67 | self.csvParser = new CsvParser("dummy", self.elementId, "prevfile");
68 | }
69 | //receives the JSON file value and creates an object of CsvParser class with the file as one of the parameters
70 | handleFileSelectGoogleSheet(googleSheetData) {
71 | this.csvFile = googleSheetData;
72 | let self = this;
73 | document.getElementById(this.uploadButtonId).onclick = (e) => {
74 | self.csvParser = new CsvParser(self.csvFile, self.elementId, "googleSheet");
75 | };
76 | }
77 | // get's the JSON form of the Google Sheet through Google Sheet's URL and passes it to the handler
78 | getValueGoogleSheet(googleSheetLink) {
79 | let self = this;
80 | $.getJSON(googleSheetLink, function (data) {
81 | self.handleFileSelectGoogleSheet(data.feed.entry);
82 | });
83 |
84 | }
85 | // uses a CORS proxy to fetch the value of a remote files and passes the received value to a callback function
86 | sendRemoteFileToHandler(val) {
87 | const proxyurl = "https://cors-anywhere.herokuapp.com/";
88 | const url = val;
89 | fetch(proxyurl + url)
90 | .then(response => response.text())
91 | .then(contents => this.handleFileSelectremote(contents))
92 | .catch((e) => console.log(e));
93 |
94 | }
95 | // callback function which receives the remote file's value and creates an object of CsvParser class with the file as one of the parameters
96 | handleFileSelectremote(remoteVal) {
97 | this.csvFile = remoteVal;
98 | let self = this;
99 | document.getElementById(this.uploadButtonId).onclick = (e) => {
100 | self.csvParser = new CsvParser(self.csvFile, self.elementId, "remote");
101 | };
102 | }
103 | // adapter function which switches between Plotly.js and Chart.js as a graph plotting library and creates theri respective objects which take over the graph plotting
104 | plotGraph(hash, length, type, flag, library) {
105 | if (library == "chartjs") {
106 | this.chartjsPlotter = new ChartjsPlotter(hash, length, type, flag, this.canvasContinerId, this.elementId, this.graphCounting);
107 | } else {
108 | this.plotlyjsPlotter = new PlotlyjsPlotter(hash, length, type, flag, this.canvasContinerId, this.elementId, this.graphCounting);
109 | }
110 | $('.' + this.carousalClass).carousel(2);
111 | }
112 | //set tool tip for impot options
113 | setTooltip(importType) {
114 | if (importType === "container_drag_drop") {
115 | return "Select a local file from your system";
116 | } else if (importType === "container_csv_string") {
117 | var x = "Type in or Paste a CSV string. \r\n";
118 | x += "Example: \r\n";
119 | x += "A,B,C \r\n";
120 | x += "1,2,3";
121 | return x;
122 | } else if (importType === "container_remote_link") {
123 | return "Type in or Paste the link of a remote CSV file. Example: \
124 | http://example.com/example.csv";
125 | } else if (importType === "container_google_sheet") {
126 | return "Type in or Paste the link of a Published Google Sheet. To publish a Google Sheet: 1. File -> Publish to the web -> Publish 2. Share -> Get shareable link -> Anyone with the link can -> More -> On - Public on the web -> Save 3. Copy link";
127 | }
128 | }
129 | //set tool tip for graph tips
130 | setTooltipGraph(graphType) {
131 | if (graphType == "Horizontal") {
132 | return "Data is categorical and tells how many, widths proportional to the values";
133 | } else if (graphType === "Vertical") {
134 | return "Data is categorical and tells how many, heights proportional to the values";
135 | } else if (graphType == "Stacked") {
136 | return "Ideal for comparing the total amounts across each group/segmented bar";
137 | } else if (graphType == "Basic") {
138 | return "Used to visualize a trend in data over intervals of time or to see the growth of a quantity";
139 | } else if (graphType == "Stepped") {
140 | return "Vertical parts of a step chart denote changes in the data and their magnitude";
141 | } else if (graphType == "Point") {
142 | return "Used to show the relationship between two data variables";
143 | } else if (graphType == "Pie") {
144 | return "Used to show percentage or proportional data, should be used for less number of categories";
145 | } else if (graphType == "Doughnut") {
146 | return "Used to show percentage or proportional data, but have better data intensity ratio and space efficiency";
147 | } else if (graphType == "Radar") {
148 | return "Used to display multivariate observations with an arbitrary number of variables";
149 | }
150 |
151 | }
152 | // create a popover against each import method for adding a file title and description
153 | createPopover(buttonId) {
154 | let self = this;
155 | var html = ''
156 | $('#' + buttonId).popover({
157 |
158 | placement: 'bottom',
159 | title: 'Add Description',
160 | html: true,
161 | content: html
162 | }).on('click', function () {
163 | $('#save').click(function (e) {
164 | e.preventDefault();
165 | self.fileTitle = $('#' + "title" + buttonId).val();
166 | self.fileDescription = $('#' + "desc" + buttonId).val();
167 |
168 | });
169 | });
170 | }
171 | // renders the required buttons for saving the files if the use is logged in
172 | createButtons(userLoginCheck) {
173 | this.listenersForIntegration();
174 | if (userLoginCheck == "yes") {
175 | var save_file_button = document.createElement('button');
176 | save_file_button.classList.add("btn");
177 | save_file_button.classList.add("btn-primary");
178 | save_file_button.innerHTML = "Save CSV";
179 | save_file_button.id = this.elementId + "_save_CSV";
180 | var upload_prev_file = document.createElement('button');
181 | upload_prev_file.classList.add("btn");
182 | upload_prev_file.classList.add("btn-primary");
183 | upload_prev_file.innerHTML = "Choose a previously uploaded file";
184 | upload_prev_file.id = this.elementId + "_prev_file";
185 | var publish_research_button = document.createElement('button');
186 | publish_research_button.classList.add("btn");
187 | publish_research_button.classList.add("btn-primary");
188 | publish_research_button.innerHTML = "Publish as a Research Note";
189 | publish_research_button.id = this.elementId + "_publish";
190 | var container = document.getElementById(this.upload_button_container);
191 | var div_container = document.createElement('div');
192 | div_container.appendChild(save_file_button);
193 | div_container.appendChild(upload_prev_file);
194 | var container2 = document.getElementById(this.feature_button_container);
195 | container2.appendChild(publish_research_button);
196 | container.prepend(div_container);
197 | }
198 | }
199 | // create dataset for CODAP table
200 | createDataset() {
201 | let dataset = {};
202 | dataset["action"] = "create";
203 | dataset["resource"] = "dataContext";
204 | let values = {};
205 | values["name"] = "my dataset";
206 | values["title"] = "Case Table";
207 | let collections = [];
208 | let hashCollections = {};
209 | hashCollections["name"] = "cases";
210 | hashCollections["attrs"] = this.csvParser.codapHeaders;
211 | collections.push(hashCollections);
212 | values["collections"] = collections;
213 | dataset["values"] = values;
214 | let dataset2 = {};
215 | dataset2["action"] = "create";
216 | dataset2["resource"] = "dataContext[my dataset].item";
217 | dataset2["values"] = this.csvParser.codapMatrix;
218 | let dataset3 = {};
219 | dataset3["action"] = "create";
220 | dataset3["resource"] = "component";
221 | let values3 = {};
222 | values3["type"] = "caseTable";
223 | values3["dataContext"] = "my dataset";
224 | dataset3["values"] = values3;
225 | return [dataset, dataset2, dataset3];
226 |
227 |
228 | }
229 | iframePhoneHandler() {
230 | //callbackforCODAP
231 | }
232 | // renders the iframe for CODAP export
233 | codapExport() {
234 | let self = this;
235 | var iframeBody = ''
236 | var modal_body = document.getElementById("body_for_CODAP");
237 | modal_body.innerHTML = iframeBody;
238 | var iframe = document.getElementById("codap-iframe");
239 | modal_body.style.height = "500px";
240 | iframe.style.width = "750px";
241 | iframe.style.height = "90%";
242 | var codapIframe = document.getElementById('codap-iframe');
243 | var rpcHandler = new iframe_phone.IframePhoneRpcEndpoint(
244 | self.iframePhoneHandler, "data-interactive", codapIframe);
245 |
246 | var createCodapButton = document.createElement("button");
247 | createCodapButton.classList.add("btn");
248 | createCodapButton.classList.add("btn-primary");
249 | createCodapButton.innerHTML = "Go!";
250 | createCodapButton.id = this.elementId + "_create_codap";
251 | modal_body.prepend(createCodapButton);
252 | var apiCall = this.createDataset();
253 | $("#" + this.elementId + "_create_codap").click(function () {
254 | rpcHandler.call(apiCall, function (resp) {
255 | console.log('Response:' + JSON.stringify(resp));
256 | });
257 | });
258 |
259 |
260 | }
261 | // creates a downloadable spreadsheet for the imported data using SheetJS
262 | createSheet() {
263 | var wb = XLSX.utils.book_new();
264 | wb.Props = {
265 | Title: "New Spreadsheet" + this.elementId,
266 | CreatedDate: new Date()
267 | };
268 |
269 | wb.SheetNames.push("Sheet" + this.elementId);
270 | var ws_data = this.csvParser.completeCsvMatrixTranspose;
271 | var ws = XLSX.utils.aoa_to_sheet(ws_data);
272 | wb.Sheets["Sheet" + this.elementId] = ws;
273 | var wbout = XLSX.write(wb, {
274 | bookType: 'xlsx',
275 | type: 'binary'
276 | });
277 |
278 | function s2ab(s) {
279 |
280 | var buf = new ArrayBuffer(s.length);
281 | var view = new Uint8Array(buf);
282 | for (var i = 0; i < s.length; i++) view[i] = s.charCodeAt(i) & 0xFF;
283 | return buf;
284 |
285 | }
286 | saveAs(new Blob([s2ab(wbout)], {
287 | type: "application/octet-stream"
288 | }), 'newSpreadsheet' + this.elementId + '.xlsx');
289 |
290 | }
291 | // creates a hash of the entire data in an accesible format for the charting libraries {labels: [legendx, [legendy0, legendy1 ... lengendyn]], x_axis_values: [...], y_axis_0: [...], y_axis_1: [...], ... y_axis_n: [...]} n: selected number of columns
292 | // flag is just for seeing if we're plotting the graph for the first time, if yes, we will have to clear the canvas.
293 | afterSampleData(flag, type) {
294 | document.getElementById(this.plotGraphId).onclick = (e) => {
295 | e.preventDefault();
296 | var hash = {};
297 | var ix = $('input[name=' + this.tableXInputName + ']:checked').val();
298 | hash["x_axis_labels"] = this.csvParser.completeCsvMatrix[ix];
299 | var columns = new Array();
300 | var y_axis_names = new Array();
301 | $("input:checkbox[name=" + this.tableYInputName + "]:checked").each((index, element) => {
302 | columns.push(element.value);
303 | });
304 | for (var i = 0; i < columns.length; i++) {
305 | hash["y_axis_values" + (i)] = this.csvParser.completeCsvMatrix[columns[i]];
306 | y_axis_names.push(this.csvParser.csvHeaders[columns[i]]);
307 | }
308 | var labels = [this.csvParser.csvHeaders[ix], y_axis_names];
309 | hash["labels"] = labels;
310 | var selectedGraph = $('.selected');
311 | var type = selectedGraph.attr('data-value');
312 |
313 | this.plotGraph(hash, columns.length, type, flag, "plotly");
314 |
315 | };
316 | }
317 | // generates a graph menu with different graph options
318 | graphMenu(flag) {
319 | var self = this;
320 | $('.' + this.carousalClass).carousel(1);
321 | var menuDiv = document.getElementById("menu_holder");
322 | menuDiv.innerHTML = '
'
545 |
546 | }
547 | }
548 |
549 | export {
550 | View
551 | }
552 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------