Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
alexsocha committed Dec 23, 2018
0 parents commit 9726905
Show file tree
Hide file tree
Showing 73 changed files with 4,871 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .gitignore
@@ -0,0 +1,10 @@
node_modules/
dist/
docs/
public/
coverage/
.vscode/
/*_cache
package-lock.json
*.log
.DS_Store
28 changes: 28 additions & 0 deletions .travis.yml
@@ -0,0 +1,28 @@
language: node_js
node_js:
- stable

cache:
directories:
- node_modules

branches:
only:
- master

install:
- npm install

jobs:
include:
- stage: test
script: "npm run test && node_modules/codecov/bin/codecov"
# waiting for TypeDoc to update to TypeScript 3.2
# - stage: docs
# script: "npm run docs && node scripts/deployDocs.js"

env:
global:
- GITHUB_REPO: "algrx/algorithmx"
# GITHUB_TOKEN
- secure: "Tzc2EJFUO1XudQSTvw7s+1EymXDugDB1qoOI7CYwVhvy3oqsfHcHnd9AAeP1D3+EtuvHRxl+p/YRxc71kruqSZknevFm3W9Jqwv1UWHtQ8cerAidDlfuzm3x+yQ1S5FBUpO389kcLXMHbOn9ad5Q4k4j/EmVdzWcKq4MkDhZF5JVsw7qZhEYXGVics0xjP5PFbWnkBkj67+4gsk6DdzKvyeOt1LQX4BiHYOgUvWO45w1G5eoQmLJ4TxpsCWqH0iPKxpzUtCTHcfDmLdWCyX3T7+SNezk2enzWOX4Bd5M6+BPLpE4hu4k/lGCnu8/IJObpozNREvi/Dq5Bze1saoU4SF0CzTVFaE6K2NbGNVX6cDo+Mo0aPn4f+bfZ3A/0rzl6AxAU8jpqr3Fj+jUaHxQRJQHKrXz+xPWKWkfZ1M/NTL7YoTolkMXsDr2BtNOPPVNR0zLA/8qfADj9NO/FINoTfqTyx/mTsElJTP3HLdQGeGOCixQNHgbUTb6L5SYN4ykpCu2srZCgEVyLgf/bu1xH/FH7H8fUr0h6nNF1DGw2df24vhI3GA1ZcrWSmRTk3k+VxSdwQfwx4G4VktEbiBjQHCEJV5Zep1CsNuHb29M777OpxLDwjG61870XtiFakIFSlxdSTIIxInfV6eT/18UFBdRH0krAWMBW/Jf/eCwwv0="
21 changes: 21 additions & 0 deletions LICENSE.txt
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Alex Socha

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
46 changes: 46 additions & 0 deletions README.md
@@ -0,0 +1,46 @@
# AlgorithmX
[![npm](https://travis-ci.com/algrx/algorithmx.svg)](https://travis-ci.com/algrx/algorithmx)
[![npm](https://img.shields.io/npm/v/algorithmx.svg)](https://www.npmjs.com/package/algorithmx)
[![codecov](https://codecov.io/gh/algrx/algorithmx/branch/master/graph/badge.svg)](https://codecov.io/gh/algrx/algorithmx)

<img src="https://raw.githubusercontent.com/algrx/algorithmx/master/img/logo.svg?sanitize=true" align="left" hspace="10" width="80px">

**AlgorithmX** is an event-driven network visualization library, built on top of <a href="https://github.com/d3/d3">D3</a> and <a href="https://github.com/tgdwyer/WebCola">WebCola</a>. It can be used to create highly customizable interactive networks, as well as animated algorithm simulations.
<br><br>

## Installing
**Browser:**
```html
<script src="https://d3js.org/d3.v5.min.js"></script>
<script src="http://marvl.infotech.monash.edu/webcola/cola.min.js"></script>
<script src="https://unpkg.com/algorithmx"></script>
```
This will expose a global `algorithmx` variable.


**Module:**

Run `npm install algorithmx`. AlgorithmX is written in <a href="https://www.typescriptlang.org/">TypeScript</a>, and comes with complete type definitions. To use in a TypeScript or ES6 JavaScript project:
```javascript
import * as algorithmx from 'algorithmx'
```

## Example Usage
```js
// select a div with id 'output' for rendering the network
const canvas = algorithmx.canvas('output')

// add three blue nodes
canvas.nodes(['A', 'B', 'C']).add().color('blue')

// add an edge
canvas.edge(['A', 'C']).add()

// pause for half a second
canvas.pause(500)

// temporarily make node 'B' 1.5 times as large
canvas.node('B').highlight().size('1.5x')
```

Refer to the <a href="https://algrx.github.io/algorithmx/docs/js">docs</a> for more information.
7 changes: 7 additions & 0 deletions img/logo.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
70 changes: 70 additions & 0 deletions karma.config.js
@@ -0,0 +1,70 @@
module.exports = config => {
config.set({
basePath: '',
frameworks: ['karma-typescript', 'mocha', 'chai'],
files: [
'node_modules/webcola/WebCola/cola.js',
'node_modules/d3-color/dist/d3-color.js',
'node_modules/d3-dispatch/dist/d3-dispatch.js',
'node_modules/d3-drag/dist/d3-drag.js',
'node_modules/d3-ease/dist/d3-ease.js',
'node_modules/d3-interpolate/dist/d3-interpolate.js',
'node_modules/d3-path/dist/d3-path.js',
'node_modules/d3-selection/dist/d3-selection.js',
'node_modules/d3-shape/dist/d3-shape.js',
'node_modules/d3-timer/dist/d3-timer.js',
'node_modules/d3-transition/dist/d3-transition.js',
'node_modules/d3-zoom/dist/d3-zoom.js',
'src/**/*.ts',
'tests/**/*.ts',
],
exclude: [],
client: {
mocha: {
reporter: 'html'
}
},
preprocessors: {
'**/*.ts': ['karma-typescript']
},
karmaTypescriptConfig: {
coverageOptions: {
exclude: /tests/
},
reports: {
lcovonly: {
directory: 'coverage',
filename: 'lcov.info',
subdirectory: '.'
},
json: {
directory: 'coverage',
filename: 'coverage-final.json',
subdirectory: '.'
},
html: {
directory: 'coverage',
subdirectory: 'html'
}
},
compilerOptions: {
module: 'commonjs'
},
include: [
'src/**/*.ts',
'tests/**/*.ts'
],
tsconfig: './tsconfig.json'
},

reporters: ['mocha', 'karma-typescript'],

port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: false,
browsers: ['ChromeHeadless'],
singleRun: true,
concurrency: Infinity
})
}
81 changes: 81 additions & 0 deletions package.json
@@ -0,0 +1,81 @@
{
"name": "algorithmx",
"version": "1.0.0-alpha.1",
"description": "An event-driven library for network visualization.",
"main": "dist/algorithmx.js",
"module": "dist/algorithmx.es.js",
"unpkg": "dist/algorithmx.min.js",
"types": "dist/types/index.d.ts",
"files": [
"dist/"
],
"scripts": {
"build:es": "./node_modules/.bin/rollup -c --environment format:es",
"build:cjs": "./node_modules/.bin/rollup -c --environment format:cjs",
"build:iife": "./node_modules/.bin/rollup -c --environment format:iife",
"build:iife:min": "./node_modules/.bin/rollup -c --environment format:iife,min:true",
"build:umd": "./node_modules/.bin/rollup -c --environment format:umd",
"build:umd:min": "./node_modules/.bin/rollup -c --environment format:umd,min:true",
"build:umd:dev": "./node_modules/.bin/rollup -c --sourcemap --environment format:umd",
"build": "npm run build:es && npm run build:iife && npm run build:iife:min && npm run build:umd && npm run build:umd:min",
"typecheck": "./node_modules/typescript/bin/tsc --noEmit",
"docs": "./node_modules/typedoc/bin/typedoc --out docs/ --module umd --mode file --excludeExternals --excludePrivate --excludeProtected src/server/types src/index.ts",
"karma": "./node_modules/.bin/karma start karma.config.js",
"lint": "./node_modules/.bin/tslint --project . 'src/**/*.ts'",
"test": "npm run lint && npm run karma"
},
"repository": {
"type": "git",
"url": "https://github.com/algrx/algorithmx.git"
},
"keywords": [
"network",
"graph",
"visualization"
],
"author": {
"name": "Alex Socha"
},
"license": "MIT",
"bugs": {
"url": "https://github.com/algrx/algorithmx/issues"
},
"homepage": "https://github.com/algrx/algorithmx",
"dependencies": {
"d3-color": "^1.2.3",
"d3-dispatch": "^1.0.3",
"d3-drag": "^1.2.1",
"d3-ease": "^1.0.3",
"d3-interpolate": "^1.3.2",
"d3-path": "^1.0.7",
"d3-selection": "^1.3.0",
"d3-shape": "^1.2.2",
"d3-timer": "^1.0.7",
"d3-transition": "^1.1.1",
"d3-zoom": "^1.7.3",
"webcola": "^3.3.8"
},
"devDependencies": {
"@types/chai": "^4.1.7",
"@types/d3": "^5.0.0",
"@types/mocha": "^5.2.5",
"chai": "^4.2.0",
"codecov": "^3.1.0",
"karma": "^3.1.4",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^2.2.0",
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.5",
"karma-typescript": "^3.0.13",
"mocha": "^5.2.0",
"rollup": "^0.68.0",
"rollup-plugin-node-resolve": "^4.0.0",
"rollup-plugin-typescript2": "^0.18.0",
"rollup-plugin-uglify": "^6.0.0",
"tslint": "^5.12.0",
"tslint-config-standard": "^8.0.1",
"tslint-immutable": "^5.0.0",
"typedoc": "^0.13.0",
"typescript": "^3.2.2"
}
}
56 changes: 56 additions & 0 deletions rollup.config.js
@@ -0,0 +1,56 @@
import { uglify } from 'rollup-plugin-uglify'
import nodeResolve from 'rollup-plugin-node-resolve'
import typescript from 'rollup-plugin-typescript2'
import * as pkg from "./package.json"

const FORMAT = process.env.format
const MIN = process.env.min === 'true'

const copyright = `// ${pkg.homepage} v${pkg.version} Copyright ${(new Date).getFullYear()} ${pkg.author.name}`

const formatExtension = FORMAT === 'umd' ? '' : `.${FORMAT}`
const fullExtension = MIN ? formatExtension + '.min' : formatExtension

export default {
input: 'src/index.ts',
output: {
file: `dist/${pkg.name}${fullExtension}.js`,
name: pkg.name,
format: process.env.format,
banner: copyright,
globals: {
'webcola': 'cola',
'd3-color': 'd3',
'd3-dispatch': 'd3',
'd3-drag': 'd3',
'd3-ease': 'd3',
'd3-interpolate': 'd3',
'd3-path': 'd3',
'd3-selection': 'd3',
'd3-shape': 'd3',
'd3-timer': 'd3',
'd3-transition': 'd3',
'd3-zoom': 'd3'
}
},
plugins: [
...(MIN ? [uglify()] : []),
nodeResolve({ jsnext: true }),
typescript({ useTsconfigDeclarationDir: true })
],
external: [
'webcola',
'd3-color',
'd3-drag',
'd3-dispatch',
'd3-drag',
'd3-ease',
'd3-interpolate',
'd3-path',
'd3-selection',
'd3-shape',
'd3-timer',
'd3-transition',
'd3-zoom'
]
}
46 changes: 46 additions & 0 deletions scripts/deployDocs.js
@@ -0,0 +1,46 @@
const pkg = require('../package.json')
const exec = require('child_process').exec;

const versionSplit = pkg.version.split('.')
const versionMajorMinor = versionSplit[0] + '.' + versionSplit[1]

const htmlRedirect = `<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="refresh" content="0; url=${versionMajorMinor}/">
</head>
</html>`

const script = `
rm -rf public
mkdir public
# config
git config --global user.email "travis@travis-ci.com"
git config --global user.name "Travis CI"
# git
cd public
git init
git remote add origin "https://\${GITHUB_TOKEN}@github.com/\${GITHUB_REPO}.git"
git pull origin gh-pages
# copy
rm -rf docs/js/${versionMajorMinor}
mkdir -p docs/js/${versionMajorMinor}
cp -rf ../docs/. docs/js/${versionMajorMinor}
# redirect
echo '${htmlRedirect}' > docs/js/index.html
# deploy
git add .
git commit -m "Deploy to GitHub Pages"
git push -u origin master:gh-pages
`

exec(script, (error, stdout, stderr) => {
console.log(stdout)
console.log(stderr)
})

0 comments on commit 9726905

Please sign in to comment.