Giter Club home page Giter Club logo

lexicon-rainbow's Introduction

Build Status Gitter npm version Codacy Badge Patreon donate






NPM

If you are reading this document from NPM, relative links and images might not work, instead refer to the GITHUB README.

Guidelines

Legends

Below table describes the techinal jargon used for this repository.

Phrase Definition
๐Ÿ”— link to related doc, if not then this
๐Ÿ” link to script
xyz.(a) single argument a
xyz.(a[,b[,c]]) {a'|a'',b',c'} optional arguments b and c with argument a having variable type(s) a' or a'',b having b' and c having c'.*
{x} a variable y with typeof y === "x"
lexiconRainbow lexicon-rainbow instance
LexiconRainbow lexicon-rainbow constructor

*: Possible variable types: "number", "string", "function", "boolean". For clear distinction '{}' represents object literal while '[]' represents an array literal.

Repository folder structure

As a developer, you are probably more interested in just getting the script and dropping in your html file. So the ones you should care about are marked with โœ…

root
|-- dev
|   |-- lexiconRainbow.d3v3.dev.js (development version of the library for d3 v3) ๐Ÿ” โœ”
|   `-- lexiconRainbow.d3v4.dev.js (development version of the library for d3 v4) ๐Ÿ” โœ”
|-- min
|   |-- lexiconRainbow.d3v3.min.js (minified version of the library for d3 v3) ๐Ÿ” โœ”
|   `-- lexiconRainbow.d3v4.min.js (minified version of the library for d3 v4) ๐Ÿ” โœ”
|-- pretty
|   |-- lexiconRainbow.d3v3.pretty.js (beautified version of the library for d3 v3) ๐Ÿ” โœ”
|   `-- lexiconRainbow.d3v4.pretty.js (beautified version of the library for d3 v4) ๐Ÿ” โœ”
|-- examples
|   |-- AminoAcids
|   |   |-- AAColorScheme.png (Glyph) ๐Ÿ”
|   |   |-- aminoAcids.jpg (Output of the example) ๐Ÿ”
|   |   |-- droplet.png (Glyph) ๐Ÿ”
|   |   |-- index_v3.html (d3 v4 example) ๐Ÿ”
|   |   |-- index_v4.html (d3 v4 example) ๐Ÿ”
|   |   `-- loadData.js (Load data via script tag) ๐Ÿ”
|   |-- Minimal
|   |   |-- index_v3.html (d3 v3 example) ๐Ÿ”
|   |   |-- index_v4.html (d3 v4 example) ๐Ÿ”
|   |   `-- minimal.jpg (Output of the example) ๐Ÿ”
|   |-- RandomDataset
|   |   |-- index_v3.html (d3 v3 example) ๐Ÿ”
|   |   |-- index_v4.html (d3 v4 example) ๐Ÿ”
|   |   |-- droplet.png (Glyph) ๐Ÿ”
|   |   `-- randomDataset.jpg (Output of the example) ๐Ÿ”
|   |-- ServerDownTime
|   |   |-- index_v3.html (d3 v3 example) ๐Ÿ”
|   |   |-- index_v4.html (d3 v4 example) ๐Ÿ”
|   |   |-- server.png (Glyph) ๐Ÿ”
|   |   `-- serverDownTime.jpg (Output of the example) ๐Ÿ”
|   |-- USvotes
|   |   |-- index_v3.html (d3 v3 example) ๐Ÿ”
|   |   |-- index_v4.html (d3 v4 example) ๐Ÿ”
|   |   |-- loadData.js (Load data via script tag) ๐Ÿ”
|   |   |-- usFlag.png (Glyph) ๐Ÿ”
|   |   `-- USvotes.jpg (Output of the example) ๐Ÿ”
|   |-- USvotes_programmatic
|   |   |-- index_v3.html (d3 v3 example) ๐Ÿ”
|   |   |-- index_v4.html (d3 v4 example) ๐Ÿ”
|   |   |-- loadData.js (Load data via script tag) ๐Ÿ”
|   |   |-- usFlag.png (Glyph) ๐Ÿ”
|   |    `-- USvotes_programmatic.jpg (Output of the example) ๐Ÿ”
|   `-- Protein
|       |-- index_v3.html (d3 v3 example) ๐Ÿ”
|       |-- index_v4.html (d3 v4 example) ๐Ÿ”
|       |-- protein1.jpeg (Glyph) ๐Ÿ”
|       |-- protein2.jpg (Glyph) ๐Ÿ”
|       |-- protein3.png (Glyph) ๐Ÿ”
|       `-- rainbow.gif (Output of the example) ๐Ÿ”
|-- snippets (Code samples for BioJS)
|-- img
|   `-- anatomy.png (Parts of the visualization) ๐Ÿ”
|-- tests
|   |-- index_v3.html (Page for headless testing with d3 v3) ๐Ÿ”
|   |-- index_v4.html (Page for headless testing with d3 v4) ๐Ÿ”
|   |-- phantomjsTest.js (Render ../index.*\.html and print base64 data uri) ๐Ÿ”
|   `-- nodejsTest.js (test for node, npm install) ๐Ÿ”
|-- docs
|   |-- CODE_OF_CONDUCT.md (CoC) ๐Ÿ”
|   |-- LICENSE (License) ๐Ÿ”
|   |-- README.md (Readme) ๐Ÿ” โœ”
|   |-- API.md (Readme) ๐Ÿ” โœ”
|   `-- CONTRIBUTING.md (Contribution guideline) ๐Ÿ”
|-- .gitignore (Ignore ./private) ๐Ÿ”
|-- package.json (Package json file for npm) ๐Ÿ”
|-- .travis.yml (For testing with PhantomJS) ๐Ÿ”
|-- .eslintrc.json (Custom linting rules :trollface:) ๐Ÿ”
`-- .jsbeautifyrc.json (Rules for jsbeautify) ๐Ÿ”



Anatomy

Below is an summary of different parts of the visualization.

Anatomy


What is it ?

Lexicon-rainbow is a library for visualizing combination of an ordinal scale (top) and a linear scale (bottom). Suppose you have items sorted based on some criteria at the top. From each item, you can define a link (ribbon, arm or whatever name you fancy) that goes to the linear scale. This link can be an integer, float or a range. You can specify as many ordinal and linear scales as you like. Then you either use the inbuit GUI or programmatic access (lexiconRainbow.ordinalG.update({number})) to create new views of your data.


Which browsers ?

Lexicon-rainbow is tested with ie11, safari, chrome and firefox. It should also work on ie10, however svg related bugs maybe present under ie10. If you find one, please report them.


Which version of Javascript ?

It is written in ES5. You do NOT need Babel and Browserify.


Which dependencies ?

There are 2 versions of lexicon-rainbow, one compatible with d3.v3 (3.5.17) and the other with d3.v4 (latest).


How do I use it ?

Refer to Usage and API Reference


Usage

Drop one of the script tags below in your html file.

Your version of d3 Script tag to use
Development version d3v3 <script src="//cdn.rawgit.com/IbrahimTanyalcin/lexicon-rainbow/170be4b9/dev/lexiconRainbow.d3v3.dev.js"></script>
<script src="//ibrahimtanyalcin.com/lexiconRainbow.d3v3.dev.js"></script>
d3v4 <script src="//cdn.rawgit.com/IbrahimTanyalcin/lexicon-rainbow/e2a8a5a0/dev/lexiconRainbow.d3v4.dev.js"></script>
<script src="//ibrahimtanyalcin.com/lexiconRainbow.d3v4.dev.js"></script>
Pretty version d3v3 <script src="//cdn.rawgit.com/IbrahimTanyalcin/lexicon-rainbow/170be4b9/pretty/lexiconRainbow.d3v3.pretty.js"></script>
<script src="//ibrahimtanyalcin.com/lexiconRainbow.d3v3.pretty.js"></script>
d3v4 <script src="//cdn.rawgit.com/IbrahimTanyalcin/lexicon-rainbow/170be4b9/pretty/lexiconRainbow.d3v4.pretty.js"></script>
<script src="//ibrahimtanyalcin.com/lexiconRainbow.d3v4.pretty.js"></script>
Minified version d3v3 <script src="//cdn.rawgit.com/IbrahimTanyalcin/lexicon-rainbow/170be4b9/min/lexiconRainbow.d3v3.min.js"></script>
<script src="//ibrahimtanyalcin.com/lexiconRainbow.d3v3.min.js"></script>
d3v4 <script src="//cdn.rawgit.com/IbrahimTanyalcin/lexicon-rainbow/170be4b9/min/lexiconRainbow.d3v4.min.js"></script>
<script src="//ibrahimtanyalcin.com/lexiconRainbow.d3v4.min.js"></script>

โš ๏ธ WARNING: The rawgit cache expires every 24 hours. In case there is a new version pushed to master branch, you might need to wait until the cache expires. Alternatively you can use ibrahimtanyalcin.com which will be active in a week (waiting for SSL). The cache expiration time on ibrahimtanyalcin.com will be 10 minutes.

Installation

$ npm install lexicon-rainbow

โš ๏ธ WARNING: The install assumes that you will be using d3 version 4 by default. If not, you have to remove the default d3, install d3 version ^3.5.17 and use one of the d3 version 3 compatible scripts within dev/ pretty/ or min/ folders.


Testing

Once you install the module you can call from the root of your project:

$ node node_modules/lexicon-rainbow/tests/nodejsTest.js

or you can move to the directory of the lexicon rainbow and call:

$ npm run test

OR

$ npm test

The test file requires module and prints out all enumerable properties of the exported object. This library is not for use on server side (because you cannot manipulate the DOM). The test file is just there to control if the object can be exported. To use this library with other libraries on the server side to be later used for client consumption you shoulduse a tool like Browserify.


API

For a detailed list of available methods, refer to API.md.

The general pattern for invoking lexicon-rainbow is as follows:

(new LexiconRainbow) //initiate a new instance

.container("#containerDiv") //pass a node or id

.forceStyle() //take advantage of embedded style

.w(600) //set width of the viewbox

.h(200) //set height of the viewbox

.sW("1000px") //set css style width of the viewport

.sH("auto") //set css style height of the viewport

.position("relative") //set css style position

.sTop("0px") //set css style top property of the viewport

.sLeft("0px") //set css style left property of the viewport

.sMargin("100px auto 0px auto") //set css style margin property of the viewport

.lexID("lexiconRainbow") //set an id for the generated SVG

.input(sample) //provide the data

.append(true) //initialize internal variables

.render(); //render scene

Note: Viewport means the space taken up by the ownerSVGElement in document coordinates. Think of it as the values returned by SVGElement.getBoundingClientRect(). (Space excluding the SVG's border) The Viewbox on the other hand is the user defined coordinate system in units of userSpaceOnUse


UMD

The library is wrapped inside UMD. You should be able to use it with CommonJS or AMD. In browser environment you will have LexiconRainbow constructor as global variable.


Youtube

Static figures only gives an idea. You can go to my youtube channel and start from this video to have a better overview.


Known Issues

  • When there are too many links coming out from one item, you might have flicker issues, as the event.target/elementFromPoint does not point to the right element. For the time being consider turning off enableOnpick.
  • In lexicon-rainbow d3v3 version, if your data object has the "axis" field set, the tick path won't get colored due to stroke style not set. This will be fixed in the next patch.

Acknowledgement

  • People
  • Projects
    • The Mutaframe () project, started in 2016 aims to be a visualization platform for mutations in human proteome (single nucleotide variants on coding regions of the human genome) that is guided by machine learning. What was unique about the project is that, it's not just about visualization of any data, it is related to healthcare. Several tools that is developed during this project (including this one) can also be used for generic purpose. I will document and release these tools as I sieze the opportunity.
  • Organizations
    • for a fruitfull project that lead to development of Mutaframe and many other micro libraries.
    • for coordinating funds for the Mutaframe project which eventually lead to development of many small libraries including this one.
    • for funding the Mutaframe project.

Support

I work on several small to medium sized projects. Development in one can also lead to development of the others. So if you would like to show your support for this project you can contribute to my PATREON page.


lexicon-rainbow's People

Contributors

ibrahimtanyalcin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

gitter-badger

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.