Giter Club home page Giter Club logo

circosjs's Introduction

Circos Circle CI Coverage Status

Demo: nicgirault.github.io/circosJS/demo

table of contents

Introduction

Circos is a javascript library to easily build interactive graphs in a circular layout. It's based on d3.js. It aims to be a javascript version of the Circos software.

You should consider using Circos to show:

  • relationships between entities
  • periodical data

temperatures
Average temperatures in Paris from 2007 (inner) to 2014 (outer). The circular layout highlights seasonal effect.

Installation

If you don't know what is npm you can skip this step and get started with this canvas. Otherwise:

npm install --save circos

Layout

To instantiate a new circos:

var myCircos = new Circos({
    container: '#chart',
    width: 500,
    height: 500,
});

A circos graph is based on a circular axis layout. Data tracks appear inside and/or outside the circular layout.

In order to place data on the circos graph, you must first specify the layout.

myCircos.layout(data, configuration);

The first argument of the layout function is a configuration object that control the format of the layout.

Here are the default parameters for a layout:

var configuration = {
  innerRadius: 250,
  outerRadius: 300,
  cornerRadius: 10,
  gap: 0.04, // in radian
  labels: {
    display: true,
    position: 'center',
    size: '14px',
    color: '#000000',
    radialOffset: 20,
  },
  ticks: {
    display: true,
    color: 'grey',
    spacing: 10000000,
    labels: true,
    labelSpacing: 10,
    labelSuffix: 'Mb',
    labelDenominator: 1000000,
    labelDisplay0: true,
    labelSize: '10px',
    labelColor: '#000000',
    labelFont: 'default',
    majorSpacing: 5,
    size: {
      minor: 2,
      major: 5,
    }
  },
  events: {}
}

The second argument of the layout function is an array of data that describe the layout regions. Each layout region must have an id and a length. You can also specify a color and a label.

var data = [
  { len: 31, color: "#8dd3c7", label: "January", id: "january" },
  { len: 28, color: "#ffffb3", label: "February", id: "february" },
  { len: 31, color: "#bebada", label: "March", id: "march" },
  { len: 30, color: "#fb8072", label: "April", id: "april" },
  { len: 31, color: "#80b1d3", label: "May", id: "may" },
  { len: 30, color: "#fdb462", label: "June", id: "june" },
  { len: 31, color: "#b3de69", label: "July", id: "july" },
  { len: 31, color: "#fccde5", label: "August", id: "august" },
  { len: 30, color: "#d9d9d9", label: "September", id: "september" },
  { len: 31, color: "#bc80bd", label: "October", id: "october" },
  { len: 30, color: "#ccebc5", label: "November", id: "november" },
  { len: 31, color: "#ffed6f", label: "December", id: "december" }
]

The id parameter will be used to place data points on the layout.

To visualize the result:

myCircos.render();

Tracks

A track is a series of data points.

To add a track to your graph you should write something like this:

myCircos.heatmap(
    'my-heatmap',
    data,
    {
        // your heatmap configuration (optional)
    },
);

This pattern is similar to all track types:

myCircos.trackType('track-id', data, configuration);

Note: The track name is used as a HTML class name so here are the format limitations.

  • Must be unique.
  • Should be slug style for simplicity, consistency and compatibility. Example: my-heatmap
  • Lowercase, a-z, can contain digits, 0-9, can contain dash or dot but not start/end with them.
  • Consecutive dashes or dots not allowed.
  • 50 characters or less.

Chords

Chords tracks connect layout regions.

chords
Some gene fusions in human karyotype (source)

Data should looks like this:

var data = [
  {
    source: {
      id: 'january',
      start: 1,
      end: 12
    },
    target: {
      id: 'april',
      start: 18,
      end: 20
    }
  },
  {
    source: {
      id: 'february',
      start: 20,
      end: 28
    },
    target: {
      id: 'december',
      start: 1,
      end: 13
    }
  },
  ...
];

Optionally each datum can define a value attribute to draw colored ribbons with palettes or a color function.

The available configuration fields are:

Heatmap

heatmap
Electrical comsumption in France in 2014

To add a heatmap to your circos instance:

myCircos.heatmap('electrical-consumption', data, configuration);

Configuration:

{
  innerRadius: null,
  outerRadius: null,
  min: null,
  max: null,
  color: 'YlGnBu',
  logScale: false,
  tooltipContent: null,
  events: {}
}

Data format:

var data = [
  {
    block_id: 'january',
    start: 0,
    end: 1,
    value: 1368001
  },
  {
    block_id: 'january',
    start: 1,
    end: 2,
    value: 1458583
  },
  ...
]

Highlight

highlight
Human karyotype with cytobands highlighted (source)

To add a highlight to your circos instance:

myCircos.highlight('cytobands', data, configuration);

The minimal datum should have block_id, start and end attributes.

Configuration:

{
  innerRadius: null,
  outerRadius: null,
  min: null,
  max: null,
  color: 'd3d3d3',
  strokeColor: null,
  strokeWidth: 0,
  opacity: 1,
  logScale: false,
  tooltipContent: null,
  events: {}
}

Histogram

histogram
Genetic abnormalities in human stem cells (source)

Data should looks like this:

var data = [
    {
      block_id: 'january',
      start: 1,
      end: 10,
      value: 5
    }
];

The available configuration fields are:

Line

line
Some single nucleotide polymorphism on chromosomes 1, 2 and 3 (source)

myCircos.line('line1', data, configuration);

The minimal datum should have block_id, position and value attributes (see above tracks for more details).

The available configuration fields are:

Note: The tooltip option is not available for line track. To display a tooltip, you should superimpose an invisble scatter track (fill: false and strokeWidth: 0) and set a tooltip for this track.

Scatter

scatter
source

myCircos.scatter('scatter1', data, configuration);

The minimal datum should have block_id, position and value attributes (see above tracks for more details).

The available configuration fields are:

Stack

stack
source

myCircos.stack('stack', data, configuration);

The minimal datum should have block_id, start and end attributes (see above tracks for more details).

Configuration:

{
  innerRadius: null,
  outerRadius: null,
  min: null,
  max: null,
  color: '#fd6a62',
  strokeColor: '#d3d3d3',
  strokeWidth: 1,
  direction: 'out',
  thickness: 10,
  radialMargin: 2,
  margin: 2,
  opacity: 1,
  logScale: false,
  tooltipContent: null,
  events: {}
}

Text

text
source

myCircos.text('text', data, configuration);

The minimal datum should have block_id, position and value attributes (see above tracks for more details).

Configuration:

{
  innerRadius: null,
  outerRadius: null,
  style: {
    'font-size': 12,
    fill: 'black',
    opacity: 1,
  },
  events: {}
}

Configuration Attributes

backgrounds

You can add a list of backgrounds:

{
  backgrounds: [
    {
      start: 0.006,
      color: '#4caf50',
      opacity: 0.1
    },
    {
      start: 0.002,
      end: 0.006,
      color: '#d3d3d3',
      opacity: 0.1
    },
    {
      end: 0.002,
      color: '#f44336',
      opacity: 0.1
    }
  ]
}

The start and end fields are interpreted as values on the same scale than the track values.

  • If start is not specified, default is the min value of the track.
  • If end is not specified, default is the max value of the track.

You can also specify a color and an opacity.

events

All tracks and the layout configurations can receive an events attribute. This attribute must be an object where keys are event names and values are event callbacks. For example:

{
  events: {
    'click.alert': function (datum, index, nodes, event) {
      window.alert(datum)
    }
  }
}

The documentation about d3 events is here. You can add all events described in this documentation. I recommend using event namespaces (click.alert instead of click) to avoid possible conflicts with internal circosjs events.

innerRadius/outerRadius

For the layout, the innerRadius and outerRadius values are always interpreted as a number of pixel.

For tracks:

If innerRadius and outerRadius are between 0 and 1, the value is interpreted as a fraction of the innerRadius of the layout.

eg:

{
  innerRadius: 0.5,
  outerRadius: 0.8
}

If innerRadius and outerRadius are between 1 and 10, the value is interpreted as a fraction of the outerRadius of the layout.

eg:

{
  innerRadius: 1,
  outerRadius: 1.2
}

Otherwise it is interpreted as a number of pixels.

min/max

The default min and max values are computed according to the dataset. You can override these values by specifying a min or max attribute in the configuration.

color

The color attribute can be either:

CSS color code

e.g #d3d3d3, blue, rgb(0, 0, 0)

Palette name from d3-scale-chromatic

The color will be computed dynamically according to the track data value field.

If you prefix the palette name with a - (e.g -BrBG), the palette will be reversed.

The list of palette names are:

BrBG: PRGn: PiYG: PuOr: RdBu: RdGy: RdYlBu: RdYlGn: Spectral: Blues: Greens: Greys: Oranges: Purples: Reds: BuGn: BuPu: GnBu: OrRd: PuBuGn: PuBu: PuRd: RdPu: YlGnBu: YlGn: YlOrBr: YlOrRd:

Custom function

You can specify a function that compute the color code given the track data and the datum index. For example:

{
  color: function(datum, index) {
    return datum.value < 5 ? 'red' : 'green'
  }
}

axes

The default value is an empty array:

{
  axes: []
}

You can add items to this array to render an axis or a group of axes. You can give axes a color (default: '#d3d3d3'), thickness (default: 1) and opacity (default: track opacity):

{
  axes: [
    {
      color: 'black',
      thickness: 2, // in pixel
      opacity: 0.3 // between 0 and 1
    }
  ]
}

Then you should specify where to place the axes.

You can either define a single axis by defining a position attribute with a value between the min and max value of the track:

{
  axes: [
    {
      color: 'red',
      position: 4
    },
    {
      color: 'green',
      position: 15
    }
  ]
}

axes-1
source

Or define a range of axes with a spacing attribute and optionnally a start and end attributes:

{
  axes: [
    {
      spacing: 2
    }
  ]
}

axes-2
source

Here is an advanced example:

{
  axes: [
    {
      color: 'red',
      spacing: 2,
      end: 4
    },
    {
      color: 'green',
      spacing: 2,
      start: 16
    },
    {
      spacing: 2,
      start: 4,
      end: 16,
      thickness: 2
    },
    {
      spacing: 1,
      start: 4,
      end: 16,
      thickness: 1
    }
  ]
}

axes-3
source

The values that you set for position, spacing, start and end are in the unit of the track values.

tooltipContent

A function that receive the datum and the index as a value and return a string displayed in the tooltip (HTML is accepted):

{
  tooltipContent: function (datum, index) {
    return `<h5>${datum.block_id}:${datum.start}-${datum.end}${datum.value}</h5> <i>(CTRL+C to copy to clipboard)</i>`
  }
}

Then when you mouseover the datum, a tooltip will be displayed. Note that you can use the keyboard shortcut CTRL+C to copy the content to clipboard.

showAxesTooltip

Show or not a tooltip with the value of the axis. Default is true.

direction

It should be either in or out. Default is out. For stack you can also use center.

fill

true or false.

fillColor

A color such as #d3d3d3, red, rgb(112, 255, 1).

logScale

true or false. Default is false.

logScaleBase

The log base if logScale is true. Default is Math.E.

radius

In the chords configuration you can specify a radius parameter. Default is null.

Examples:

// when there is no value, default is null:
// the radius will be the one of the innerRadius of the layout
{}

// when the value is a number greater than 1, it is interpreted as
// a number of pixel from the center
{
  radius: 200
}

// when the value is a number lower than 1, it is interpreted as
// a fraction of the layout inner radius
{
  radius: 0.8
}

// you can also specify a function that return a number that
// will be interpreted as explained above. The function takes
// a datum as parameter
{
  radius: function (d) {
    if (d.source.id === 'chr1') {
      return 0.8
    }
    if (d.source.id === 'chr2') {
      return 0.7
    }
  }
}

shape

It should be one of:

  • circle
  • cross
  • diamond
  • square
  • triangle
  • star
  • wye

zIndex

This should be an integer. The higher it is the more above the track will appear.

Contact

Nicolas Girault [email protected]

Your feedbacks are welcome. If you're struggling using the librairy, the best way to ask questions is to use the Github issues so that they are shared with everybody.

circosjs's People

Contributors

microdou avatar nicgirault avatar pollen8 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

circosjs's Issues

Labels on Scatter Chart Axes

Hi @nicgirault ,

Is there a way to create labels on the axes on scatter chart like below. Please let me know. Thank you.
I tried label0Display=true on ticks but they are showing on the ticks.

scatter_labels

Accessibility from one track to another

Hello.

I have a question about how different tracks can interact. For example if I need to change the color of the circular diagram sector after click on the corresponding text on the Text Track. Is it possible to change styles of different tracks via the block_id or in some another way?

Thank you in advance

Documentation error in gitbook

When I try to run the initial example given in https://nicgirault.gitbooks.io/circosjs/content/layout.html then I get the error message:

circos.js:4483 Uncaught TypeError: Cannot create property 'offset' on number '250'
    at Layout.agg.blocks (circos.js:4483)
    at circos.js:6959
    at circos.js:1845
    at baseForOwn (circos.js:3274)
    at circos.js:3387
    at baseReduce (circos.js:6956)
    at reduce (circos.js:5542)
    at new Layout (circos.js:4482)
    at Core.layout (circos.js:151)
    at circos_test.html:67

It looks like perhaps the gitbook is outdated?

One clear discrepancy I find between it and what is in the layout section of the README.md is the order of the configuration and data arguments supplied to instance.layout:

gitbook: instance.layout(configuration, layout_data);
README.md: myCircos.layout(data, configuration);

Zooming in CircosJS

Hello @nicgirault,

Is there a way to implement normal D3 zooming abilities within Circos layouts?

I'm using the Chords track similar to this example: https://github.com/nicgirault/circosJS/blob/master/doc/chords.png. I want to implement normal pan and zoom by scrolling with the mouse (https://bl.ocks.org/sgruhier/50990c01fe5b6993e82b8994951e23d0), and this is what I'm trying to do:

var width = 1000;
var height = 850;

var svg = d3.select("body")
  .append("div")
  .attr('id', 'chart')
  .attr("width", width)
  .attr("height", height);

svg.select(".all")
  .call(d3.zoom().on("zoom", function() {
    svg.select(".all").attr("transform", d3.event.transform)
  }))
  .append("g");

var myCircos = new Circos({
  container: '#chart',
  width: width,
  height: height
});

// ...
// Adding the configuration data for the layout and chords, and rendering

The zooming is not working as expected. As you can see, I have to do svg.select(".all") to actually select the svg element within the div tag.

Thank you!

Documentation Update: Track Data Formatting

Hi there, after countless hours of trying to get chords rendered (receiving 'No data source at index [0..n-1]' for each array of data given to the track), I found a discrepency after running through the source for the provided demo seen here.

I found the chord data used in the demo was formatted as objects, seen below:

[
    {
        source: {
            id: 'sourceID',
            start: sourceStart,
            end: sourceEnd
        },
        target: {
            id: 'targetID',
            start: targetStart,
            end: targetEnd
        }
    },
[

Yet any documentation I found was stating chord data be formatted as arrays:

[
    ['sourceID', sourceStart, sourceEnd, 'targetID', targetStart, targetEnd],
]

Only after using the object formatting for my data did the chords render without error.
Taking a quick look at the heatmap demo, it would seem the case is the same, data is formatted in objects as opposed to arrays seen in the documentation.

Hoping this can be updated to help out others :)
Thanks.

allow es6 import/require

its not possible to require/import circos ....

in circos.js, add this on the end:

module.exports = Circos;

this will allow to import like this:
import Circos from 'circos/dist/circos'

to allow direct inclussion add index.js directly in the circos folder with this content: (first change is still needed)

module.exports = require('./dist/circos');

now its possible to include like
import Circos from 'circos';

RawGit js file CDN url?

I just noticed that all of the work I did for a client showing CircosJS charts no longer render. I've used the RawGit CDN URL https://cdn.rawgit.com/nicgirault/circosJS/master/dist/circosJS.js, which points to a file that no longer exists. I tried the URL to "circos.js", which does exist, but the charts still do not render. I have to use a CDN because the client did not give me the ability to upload a JS file for re-use. CDNjs.com does not have the file.

Because the client did not want the charts in newer articles, I have not had reason to go through your revision notes, but maybe you can save me a bit of time by saying whether there have been significant changes in function names? Any suggestions for how I can quickly fix all these CircosJS charts no longer rendering? E.g., is there any archive of the original JS file on RawGit?

Thanks in advance.
-raj

Embedded demos not showing up

The embedded demos are not showing up. Sometimes there are Fiddles or similar one can click to see them, but sometimes there are not.

I tried Firefox and Chrome with the same results.

Two examples (from here and here):
circosjs embed
circosjs embed2

How to cite circosJS?

Hi @nicgirault

A nice project. I used the circosJS in my project and will publish a paper. Could you please inform me the appropriate way to cite circosJS? Thanks!

Questions about heatmap color configuration

I am trying to run the heatmap graph in the demo but with error about color configuration. But the highlight graph is ok with the color settings.
The error is:"circos.js:13427 Uncaught TypeError: Cannot read property '0' of undefined"

How to import and instantiate a new circos in ES6?

Hi @nicgirault,
I couldn't any information on README on how to use circosjs in ES6, so I tried this:

import React, { Component } from 'react';
import Circos from 'circos';

class Chart extends Component {
  render() {
    let myCircos = new Circos({
      container: '#lineChart',
      width: 500,
      height: 500,
    });
    return (
        <div id="lineChart"></div>
    );
  }
}

But I got this error:

TypeError: __WEBPACK_IMPORTED_MODULE_2_circos___default.a is not a constructor

I am very new to ES6 so please bear with me. Thank you very much, would appreciate any help.

Compatibility with d3 > 3.5.5

v 1.7.0 cause error on my project. It may not be circosJS's problem though.

It appears that the package d3-tip depends on d3 of the exact version 3.5.5, which may cause compatibility issues. d3-tip should have depended on ~3.5.5 to be compatible with newer versions. Author of d3-tip hasn't done any update for a long time :)

onClick callback for tracks to return Datum objects

Hi,
I wonder how I do to hook up a listener to detect a click event, returning datum object in the same way as it is done for the tooltipContent implementation?

Have managed to detect a click event for the Layout using onClick but it is returning HTML elements and it is not working for any other tracks.

Any suggestions?

best wishes

Problem instantiating Circos in ES6

Hi @nicgirault ,

Thank you for your response in the earlier issue. I really appreciate that you spend your time on the problem.

I've tried re-installing circos using

npm remove circos && npm install [email protected]

and importing and instantiating it as per the suggestion by @ferrantejake in #38

import * as Circos from 'circos';

class Chart extends Component {
  render() {
    let myCircos = Circos({
      width: 700,
      height: 700,
      container: 'lineChart',
      defaultTrackWidth: 10
    });
    return (<div id="lineChart"/>);
  }
}

but still getting the same error:

TypeError: __WEBPACK_IMPORTED_MODULE_2_circos__ is not a function

What did I miss?

Thank you.

SVG container

Hi,

Great project,
In my project I need to have the svg created in my code vs. in the circosJS;
Is there a way that I can bybass the creation of the svg in circosJS and append the created elements in an #id?

Thanks

library bundle

I just noticed that the library is pretty big in size because it includes several other libraries. I am not sure how good of a practice this is. On one hand you get everything and you dont have to worry about anything else. On the other hand if a project already includes loadash or d3 it gets everything twice. Maybe a distribution that includes everything and one that does not?

What do other people think?

Update track performance

When you re-render a track with only one configuration parameter that change, you should not re-render all the track

Errors from canvas example

In using your canvas example, I get

layout.selectAll('g').data(instance._layout.data).enter is not a function. (In 'layout.selectAll('g').data(instance._layout.data).enter()', 'layout.selectAll('g').data(instance._layout.data).enter' is undefined)

circos.js:7430

Configuration setting for closing margins

screenshot2017-08-14
This is the current illustration that I am working on, and I am wondering what the setting is to remove these "longitudinal" margins between the wedges of data. I tried setting 'radialMargin' to 0 but that does not appear to help.

Documentation request: multiple layouts or lengths?

Another doc request, if it's suitable... I recently tried to have two different sets of "layouts" in a complex college data CircosJS comparison chart for a client. Didn't work: the 2nd layout obliterated the first-defined one, and as a result, some tracks did not render. I tried with both the same ID set and a different set. What I was trying to do is have a track where each layout item (a college) could have a different "length" than what was defined in the layout.

So if I defined "len": 3 for, say, Harvard, and used it to show a histogram track for in-state tuition, out-of state tuition and net price, great. But in a different track, I might want to show two variables -- e.g., number of undergrads and grads. As it stands, I have to introduce a third value per layout item. I'm wondering if there's a way to effectively change "len" for a single track, but have the track bind to the original layout items. I tried two .layout(...) blocks - no luck. Just adding more data points per school with one layout block does not render correctly, either.

Here's an example:
http://affordableschools.net/25-exclusive-public-bachelors-colleges-admission-rate/

In this example chart, I have the 3rd track counting in as a heatmap of the college's age. To get the effect, I had to repeat the age three times in total in the age array. Similarly, for track 2 (text) just inside the green histogram track, I had to have a 3-tuple for each college, but the third value is a blank string.

I'm wondering if there's anyway that a given track can "locally" override the layout item's "len" value.

Error: <path> attribute d: Expected number, "….43564672524005LNaN,NaNZ"

Hi,
I got the following errors with my data:

    1 "datum" "unknown parent id" {line: 1, value: undefined, header: "sourceId", layoutSummary: {…}}
    circos.js:19573 1 "datum" "unknown parent id" {line: 2, value: undefined, header: "sourceId", layoutSummary: {…}}
    circos.js:19573 1 "datum" "unknown parent id" {line: 3, value: undefined, header: "sourceId", layoutSummary: {…}}
    circos.js:19573 1 "datum" "unknown parent id" {line: 4, value: undefined, header: "sourceId", layoutSummary: {…}}
    circos.js:19573 1 "datum" "unknown parent id" {line: 5, value: undefined, header: "sourceId", layoutSummary: {…}}
    circos.js:19573 1 "datum" "unknown parent id" {line: 6, value: undefined, header: "sourceId", layoutSummary: {…}}
    circos.js:19573 1 "datum" "unknown parent id" {line: 7, value: undefined, header: "sourceId", layoutSummary: {…}}
    circos.js:19573 1 "datum" "unknown parent id" {line: 8, value: undefined, header: "sourceId", layoutSummary: {…}}
    circos.js:19573 1 "datum" "unknown parent id" {line: 9, value: undefined, header: "sourceId", layoutSummary: {…}}
    circos.js:19573 1 "datum" "unknown parent id" {line: 10, value: undefined, header: "sourceId", layoutSummary: {…}}
    circos.js:3998 Error: <path> attribute d: Expected number, "….43564672524005LNaN,NaNZ".
    (anonymous) @ circos.js:3998
    selection_each @ circos.js:3963
    selection_attr @ circos.js:4020
    renderLayout @ circos.js:7440
    render @ circos.js:7017
    render @ circos.js:205
    drawCircos @ chords.js:83
    _call @ d3-queue.js:42
    maybeNotify @ d3-queue.js:118
    (anonymous) @ d3-queue.js:89
    (anonymous) @ d3.js:10999
    call @ d3.js:668
    respond @ d3.js:10924
    XMLHttpRequest.send (async)
    send @ d3.js:11001
    get @ d3.js:10981
    (anonymous) @ d3.js:11042
    start @ d3-queue.js:72
    poke @ d3-queue.js:56
    defer @ d3-queue.js:33
    (anonymous) @ chords.js:88
    1365circos.js:3998 Error: <path> attribute d: Expected number, "MNaN,NaNLNaN,NaNZ".
    (anonymous) @ circos.js:3998
    selection_each @ circos.js:3963
    selection_attr @ circos.js:4020
    renderLayout @ circos.js:7440
    render @ circos.js:7017
    render @ circos.js:205
    drawCircos @ chords.js:83
    _call @ d3-queue.js:42
    maybeNotify @ d3-queue.js:118
    (anonymous) @ d3-queue.js:89
    (anonymous) @ d3.js:10999
    call @ d3.js:668
    respond @ d3.js:10924
    XMLHttpRequest.send (async)
    send @ d3.js:11001
    get @ d3.js:10981
    (anonymous) @ d3.js:11042
    start @ d3-queue.js:72
    poke @ d3-queue.js:56
    defer @ d3-queue.js:33
    (anonymous) @ chords.js:88
    circos.js:3998 Error: <path> attribute d: Expected number, "….72942341610366LNaN,NaNZ".
    (anonymous) @ circos.js:3998
    selection_each @ circos.js:3963
    selection_attr @ circos.js:4020
    renderLayoutLabels @ circos.js:7365
    renderLayout @ circos.js:7447
    render @ circos.js:7017
    render @ circos.js:205
    drawCircos @ chords.js:83
    _call @ d3-queue.js:42
    maybeNotify @ d3-queue.js:118
    (anonymous) @ d3-queue.js:89
    (anonymous) @ d3.js:10999
    call @ d3.js:668
    respond @ d3.js:10924
    XMLHttpRequest.send (async)
    send @ d3.js:11001
    get @ d3.js:10981
    (anonymous) @ d3.js:11042
    start @ d3-queue.js:72
    poke @ d3-queue.js:56
    defer @ d3-queue.js:33
    (anonymous) @ chords.js:88
    1365circos.js:3998 Error: <path> attribute d: Expected number, "MNaN,NaNLNaN,NaNZ".
    (anonymous) @ circos.js:3998
    selection_each @ circos.js:3963
    selection_attr @ circos.js:4020
    renderLayoutLabels @ circos.js:7365
    renderLayout @ circos.js:7447
    render @ circos.js:7017
    render @ circos.js:205
    drawCircos @ chords.js:83
    _call @ d3-queue.js:42
    maybeNotify @ d3-queue.js:118
    (anonymous) @ d3-queue.js:89
    (anonymous) @ d3.js:10999
    call @ d3.js:668
    respond @ d3.js:10924
    XMLHttpRequest.send (async)
    send @ d3.js:11001
    get @ d3.js:10981
    (anonymous) @ d3.js:11042
    start @ d3-queue.js:72
    poke @ d3-queue.js:56
    defer @ d3-queue.js:33
    (anonymous) @ chords.js:88
    1366circos.js:3998 Error: <g> attribute transform: Expected number, "rotate(NaN)translate(14…".

This is chord.js code:

    var gieStainColor = {
      gpos100: 'rgb(0,0,0)',
      gpos: 'rgb(0,0,0)',
      gpos75: 'rgb(130,130,130)',
      gpos66: 'rgb(160,160,160)',
      gpos50: 'rgb(200,200,200)',
      gpos33: 'rgb(210,210,210)',
      gpos25: 'rgb(200,200,200)',
      gvar: 'rgb(220,220,220)',
      gneg: 'rgb(255,255,255)',
      acen: 'rgb(217,47,39)',
      stalk: 'rgb(100,127,164)',
      select: 'rgb(135,177,255)'
    }
    
    var drawCircos = function (error, GRCh37, data) {
      var width = document.getElementsByClassName('mdl-card__supporting-text')[0].offsetWidth
      var circos = new Circos({
        container: '#chordsChart',
        width: width,
        height: width
      })
    
      data = data.map(function (d) {
        return {
          source: {
            id: d.source_id,
            start: parseInt(d.source_breakpoint) - 2000000,
            end: parseInt(d.source_breakpoint) + 2000000
          },
          target: {
            id: d.target_id,
            start: parseInt(d.target_breakpoint) - 2000000,
            end: parseInt(d.target_breakpoint) + 2000000
          }
        }
      })
    
      circos
        .layout(
          GRCh37,
        {
          innerRadius: width/2 - 80,
          outerRadius: width/2 - 40,
          labels: {
            radialOffset: 70
          },
          ticks: {
            display: true,
            labelDenominator: 1000000
          },
          events: {
            'click.demo': function (d, i, nodes, event) {
              console.log('clicked on layout block', d, event)
            }
          }
        }
        )
        .chords(
          'l1',
          data,
        {
          radius: function (d) {
            if (d.source.id === 'chr1') {
              return 0.5
            } else {
              return null
            }
          },
          logScale: false,
          opacity: 0.7,
          color: '#ff5722',
          tooltipContent: function (d) {
            return '<h3>' + d.source.id + ' ➤ ' + d.target.id + ': ' + d.value + '</h3><i>(CTRL+C to copy to clipboard)</i>'
          },
          events: {
            'mouseover.demo': function (d, i, nodes, event) {
              console.log(d, i, nodes, event.pageX)
            }
          }
        }
        )
        .render()
    }
    
    d3.queue()
      .defer(d3.json, './data/circle.json')
      .defer(d3.json, './data/data.json')
      .await(drawCircos)

This is circle.json:

    [
      {
        "color": "#996600", 
        "id": "chr03", 
        "len": "35020413", 
        "label": "chr03"
      }, 
      {
        "color": "#666600", 
        "id": "tig00007144", 
        "len": 40868, 
        "label": "tig00007144"
      }
    ]

This is data.json

    [
      {
        "source": {
          "start": 30824, 
          "end": 23113, 
          "id": "tig00007144"
        }, 
        "target": {
          "start": 33203431, 
          "end": 33211142, 
          "id": "chr03"
        }
      }, 
      {
        "source": {
          "start": 5564, 
          "end": 1, 
          "id": "tig00007144"
        }, 
        "target": {
          "start": 33172892, 
          "end": 33178421, 
          "id": "chr03"
        }
      }, 
      {
        "source": {
          "start": 36357, 
          "end": 30947, 
          "id": "tig00007144"
        }, 
        "target": {
          "start": 33211132, 
          "end": 33216579, 
          "id": "chr03"
        }
      }
      ]

This is the index.html:

   <!doctype html>
   <html lang="en">
     <head>
       <meta charset="utf-8">
       <meta http-equiv="X-UA-Compatible" content="IE=edge">
       <meta name="description" content="A front-end template that helps you build fast, modern mobile web apps.">
       <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
       <title>Circos</title>
   
       <!-- Add to homescreen for Chrome on Android -->
       <meta name="mobile-web-app-capable" content="yes">
       <link rel="icon" sizes="192x192" href="images/android-desktop.png">
   
       <!-- Add to homescreen for Safari on iOS -->
       <meta name="apple-mobile-web-app-capable" content="yes">
       <meta name="apple-mobile-web-app-status-bar-style" content="black">
       <meta name="apple-mobile-web-app-title" content="Material Design Lite">
       <link rel="apple-touch-icon-precomposed" href="images/ios-desktop.png">
   
       <!-- Tile icon for Win8 (144x144 + tile color) -->
       <meta name="msapplication-TileImage" content="images/touch/ms-touch-icon-144x144-precomposed.png">
       <meta name="msapplication-TileColor" content="#3372DF">
   
       <link rel="shortcut icon" href="images/favicon.png">
   
       <!-- SEO: If your mobile URL is different from the desktop URL, add a canonical link to the desktop page https://developers.google.com/webmasters/smartphone-sites/feature-phones -->
       <!--
       <link rel="canonical" href="http://www.example.com/">
       -->
   
       <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:regular,bold,italic,thin,light,bolditalic,black,medium&amp;lang=en">
       <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
       <link rel="stylesheet" href="//code.getmdl.io/1.3.0/material.deep_purple-pink.min.css">
       <link rel="stylesheet" href="styles.css">
   
       <script src='https://cdn.rawgit.com/nicgirault/circosJS/v2/dist/circos.js'></script>
       <script src='https://cdnjs.cloudflare.com/ajax/libs/d3/4.5.0/d3.js'></script>
       <script src='https://cdnjs.cloudflare.com/ajax/libs/d3-queue/3.0.3/d3-queue.js'></script>
     </head>
     <body class="mdl-demo mdl-color--grey-100 mdl-color-text--grey-700 mdl-base">
       <div class="mdl-layout mdl-js-layout mdl-layout--fixed-header">
         <header class="mdl-layout__header mdl-layout__header--scroll mdl-color--primary">
           <div class="mdl-layout__tab-bar mdl-js-ripple-effect mdl-color--primary-dark">
             <a href="#chords" class="mdl-layout__tab is-active">Chords</a>
             <a href="#heatmap" class="mdl-layout__tab">Heatmap</a>
             <a href="#highlight" class="mdl-layout__tab">Highlight</a>
             <a href="#histogram" class="mdl-layout__tab">Histogram</a>
             <a href="#line" class="mdl-layout__tab">Line</a>
             <a href="#scatter" class="mdl-layout__tab">Scatter</a>
             <a href="#stack" class="mdl-layout__tab">Stack</a>
             <a href="#text" class="mdl-layout__tab">Text</a>
           </div>
         </header>
         <main class="mdl-layout__content">
           <div class="mdl-layout__tab-panel is-active" id="chords">
             <section class="section--center mdl-grid mdl-grid--no-spacing mdl-shadow--2dp">
               <div class="mdl-card mdl-cell mdl-cell--12-col">
                 <div class="mdl-card__supporting-text">
                   <h4>Chords</h4>
                   <div id='chordsChart'></div>
                 </div>
                 <div class="mdl-card__actions">
                   <a href="#" class="mdl-button">Read the documentation</a>
                 </div>
               </div>
             </section>
           </div>
           <div class="mdl-layout__tab-panel" id="line">
             <section class="section--center mdl-grid mdl-grid--no-spacing mdl-shadow--2dp">
               <div class="mdl-card mdl-cell mdl-cell--12-col">
                 <div class="mdl-card__supporting-text">
                   <h4>Line</h4>
                   <div id='lineChart'></div>
                 </div>
                 <div class="mdl-card__actions">
                   <a href="#" class="mdl-button">Read the documentation</a>
                 </div>
               </div>
             </section>
           </div>
           <div class="mdl-layout__tab-panel" id="scatter">
             <section class="section--center mdl-grid mdl-grid--no-spacing mdl-shadow--2dp">
               <div class="mdl-card mdl-cell mdl-cell--12-col">
                 <div class="mdl-card__supporting-text">
                   <h4>Scatter</h4>
                   <div id='scatterChart'></div>
                 </div>
                 <div class="mdl-card__actions">
                   <a href="#" class="mdl-button">Read the documentation</a>
                 </div>
               </div>
             </section>
           </div>
           <div class="mdl-layout__tab-panel" id="stack">
             <section class="section--center mdl-grid mdl-grid--no-spacing mdl-shadow--2dp">
               <div class="mdl-card mdl-cell mdl-cell--12-col">
                 <div class="mdl-card__supporting-text">
                   <h4>Stack</h4>
                   <div id='stackChart'></div>
                 </div>
                 <div class="mdl-card__actions">
                   <a href="#" class="mdl-button">Read the documentation</a>
                 </div>
               </div>
             </section>
           </div>
           <div class="mdl-layout__tab-panel" id="text">
             <section class="section--center mdl-grid mdl-grid--no-spacing mdl-shadow--2dp">
               <div class="mdl-card mdl-cell mdl-cell--12-col">
                 <div class="mdl-card__supporting-text">
                   <h4>Text</h4>
                   <div id='textChart'></div>
                 </div>
                 <div class="mdl-card__actions">
                   <a href="#" class="mdl-button">Read the documentation</a>
                 </div>
               </div>
             </section>
           </div>
           <div class="mdl-layout__tab-panel" id="highlight">
             <section class="section--center mdl-grid mdl-grid--no-spacing mdl-shadow--2dp">
               <div class="mdl-card mdl-cell mdl-cell--12-col">
                 <div class="mdl-card__supporting-text">
                   <h4>Highlight</h4>
                   <div id='highlightChart'></div>
                 </div>
                 <div class="mdl-card__actions">
                   <a href="#" class="mdl-button">Read the documentation</a>
                 </div>
               </div>
             </section>
           </div>
           <div class="mdl-layout__tab-panel" id="heatmap">
             <section class="section--center mdl-grid mdl-grid--no-spacing mdl-shadow--2dp">
               <div class="mdl-card mdl-cell mdl-cell--12-col">
                 <div class="mdl-card__supporting-text">
                   <h4>Heatmap</h4>
                   <div id='heatmapChart'></div>
                 </div>
                 <div class="mdl-card__actions">
                   <a href="#" class="mdl-button">Read the documentation</a>
                 </div>
               </div>
             </section>
           </div>
           <div class="mdl-layout__tab-panel" id="histogram">
             <section class="section--center mdl-grid mdl-grid--no-spacing mdl-shadow--2dp">
               <div class="mdl-card mdl-cell mdl-cell--12-col">
                 <div class="mdl-card__supporting-text">
                   <h4>Histogram</h4>
                   <div id='histogramChart'></div>
                 </div>
                 <div class="mdl-card__actions">
                   <a href="#" class="mdl-button">Read the documentation</a>
                 </div>
               </div>
             </section>
           </div>
         </main>
       </div>
       <script src="//code.getmdl.io/1.3.0/material.min.js"></script>
       <script src='./chords.js'></script>
   
     </body>
   </html>

What did I miss?

Thank you in advance.

legend for heatmap

Hi nicgirault,

I really like your circosJS.
Do you have any plans to add legend feature for the heatmap plot in CircosJS?

Thanks,

J

Some problems about stack of CircosJS

The documentation says that Stack tracks can be used to show spans over the layout. Spans will stack within their track to avoid overlap.
Now I want spans will stack within their track to allow overlap ,the same data will be stack together at one place. Or how to modify the CircosJS make the same color tracks only one round about the follow picture .

image

empty page with chord.js

Hi, I have the following chords.js file

var gieStainColor = {
  gpos100: 'rgb(0,0,0)',
  gpos: 'rgb(0,0,0)',
  gpos75: 'rgb(130,130,130)',
  gpos66: 'rgb(160,160,160)',
  gpos50: 'rgb(200,200,200)',
  gpos33: 'rgb(210,210,210)',
  gpos25: 'rgb(200,200,200)',
  gvar: 'rgb(220,220,220)',
  gneg: 'rgb(255,255,255)',
  acen: 'rgb(217,47,39)',
  stalk: 'rgb(100,127,164)',
  select: 'rgb(135,177,255)'
}

var drawCircos = function (error, GRCh37, data) {
  var width = document.getElementsByClassName('mdl-card__supporting-text')[0].offsetWidth
  var circos = new Circos({
    container: '#chordsChart',
    width: width,
    height: width
  })

  cytobands = cytobands.map(function (d) {
    return {
      block_id: d.chrom,
      start: parseInt(d.chromStart),
      end: parseInt(d.chromEnd),
      gieStain: d.gieStain,
      name: d.name
    }
  })

  data = data.map(function (d) {
    return {
      source: {
        id: d.source_id,
        start: parseInt(d.source_breakpoint) - 2000000,
        end: parseInt(d.source_breakpoint) + 2000000
      },
      target: {
        id: d.target_id,
        start: parseInt(d.target_breakpoint) - 2000000,
        end: parseInt(d.target_breakpoint) + 2000000
      }
    }
  })

  circos
    .layout(
      GRCh37,
    {
      innerRadius: width/2 - 80,
      outerRadius: width/2 - 40,
      labels: {
        radialOffset: 70
      },
      ticks: {
        display: true,
        labelDenominator: 1000000
      },
      events: {
        'click.demo': function (d, i, nodes, event) {
          console.log('clicked on layout block', d, event)
        }
      }
    }
    )
    .highlight('cytobands', cytobands, {
      innerRadius: width/2 - 80,
      outerRadius: width/2 - 40,
      opacity: 0.3,
      color: function (d) {
        return gieStainColor[d.gieStain]
      },
      tooltipContent: function (d) {
        return d.name
      }
    })
    .chords(
      'l1',
      data,
    {
      radius: function (d) {
        if (d.source.id === 'chr1') {
          return 0.5
        } else {
          return null
        }
      },
      logScale: false,
      opacity: 0.7,
      color: '#ff5722',
      tooltipContent: function (d) {
        return '<h3>' + d.source.id + ' ➤ ' + d.target.id + ': ' + d.value + '</h3><i>(CTRL+C to copy to clipboard)</i>'
      },
      events: {
        'mouseover.demo': function (d, i, nodes, event) {
          console.log(d, i, nodes, event.pageX)
        }
      }
    }
    )
    .render()
}

d3.queue()
  .defer(d3.json, './data/circle.json')
  .defer(d3.csv, './data/data.json')
  .await(drawCircos)

and my index.html is:

<html lang="en">
  <head>
    
    <title>Circos</title>
      <script src="https://cdn.rawgit.com/nicgirault/circosJS/master/dist/circosJS.js" type="text/javascript"></script>
      <script src='https://cdnjs.cloudflare.com/ajax/libs/d3/4.5.0/d3.js'></script>
      <script src='https://cdnjs.cloudflare.com/ajax/libs/d3-queue/3.0.3/d3-queue.js'></script>

  </head>
  <body>
    <script src='./chords.js'></script>
  </body>
</html>

I am just got an empty page with:

$ python -m SimpleHTTPServer 8000
Serving HTTP on 0.0.0.0 port 8000 ...
127.0.0.1 - - [29/Oct/2017 22:50:44] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [29/Oct/2017 22:50:50] "GET /chords.js HTTP/1.1" 200 -
127.0.0.1 - - [29/Oct/2017 22:50:50] "GET /data/circle.json HTTP/1.1" 200 -
127.0.0.1 - - [29/Oct/2017 22:50:54] code 404, message File not found
127.0.0.1 - - [29/Oct/2017 22:50:54] "GET /favicon.ico HTTP/1.1" 404 -
127.0.0.1 - - [29/Oct/2017 22:50:54] "GET /data/data.json HTTP/1.1" 200 -

What did I miss?

Thank you in advance

Michal

importing for Angular2

I'm trying to use circosJS in a Angular2 project but I am struggling with getting it to import. Have installed the library using npm which seem to be successful. Any suggestions/solution?

SVG Text in Chrome

I am having this very strange issue where the SVG text has 0w and 0h in chrome for my particular web application. The JS fiddle example works fine for me, as does my current code in MS Edge and Safari. I can see the text in the actual html code, and have compared the CSS between my application and the sample, they are completely identical.

Thanks for any help.

issuechrome

question about the input

This is a great project.
Can you please explain what the input is?

var heatmap = [
    ['january',0,1,1368001],

It seems that it is MONTH, DAY, DAY, POWER.
but heatmap is supposed to have 3 dimensions so why there are 4?
thanks

Resize Chart - Responsiveness

Hi,

Does CircosJS has resize chart method/functionality?. I would like to resize the chart according to the window resize. Is there anything which is in built already?. If not, please let me know if anyone has done anything similar. Thanks.

Swap <div> for <svg>?

I use circos.js as a smaller part of a large SVG construction. I cannot get circos to draw to an <svg> element despite the fact that <svg> elements can contain more <svg> elements. Since Circos.js is only looking for an "id" attribute, what is keeping it from using an <svg id="circos"> kind of tag as opposed to a <div>?

Something about line

Sorry to bother you.
This is great job. But i have some trouble in working with "line". When i using "fill",i can't change its color,it is always gray.Is that normal? How can i change fill-color?
Thank you.

Is there a way to set the `g.all` transform parameters through configuration?

I would like to configure my circos plots to center on <0,0> when I create them. It looks like there's a g element with a .all class that gets a transform such that the circos plot appears nicely when it is generated on its own. However, I am generating circos plots inside of my own g elements and I'd like to turn off the transform. Is there a way to configure the plot that way? I realize I could also just delete the translate attribute on all .all elements after I create the plot.

On further thought, the .all class might better be name-spaced so that it does not clash with user classes. Perhaps it might be worth adding a "standalone" configuration option. If it is false, then perhaps the g.all element is just never created?

Documentation update request

I love circosJS and have used it several times in college rankings articles for a client. But for the life of me, I cannot figure out how to add tooltips like the ones that appear in the Global Migration chord diagram. I'm using layout, histogram, heatmap, and text in one circular chart, but none have provisions for tooltips. Or at least the documentation does not show that. I'm going to see if I can use D3js to query my objects and bind tooltips, but I wanted to see if there was a simpler way before first. If there is (for at least histogram and heatmap), I'm wondering if you could add something in the documentation to show that. Please and thank you.

chords plot relationship file format.

Hi,
I am interested to get similar chords plot. I have the following table which shows the relationship between the data

query   | subject     | query  start | query end | subject start | Subject end
Locus_1 | tig00007234 | 1            | 1054      | 140511        | 137383
Locus_1 | tig00007234 | 1            | 1057      | 77478         | 74353
Locus_1 | tig00007234 | 1            | 1057      | 46295         | 43158

How should I format the above data to make it compatible to CircosJS?

Thank you in advance,

Michal

Documentation request: Example in ES6.

Hi @nicgirault,

Thank you for creating this library. This is the only the I found to be able to do what I need ie. create flexible polar chart. Recently I've been using for my work and now I want to integrate it into reactjs so that it is more modular.

However, I am stuck. I am having problem migrating my code into ES6. So, I request that you show example in the documentation on how to create a simple chart in ES6, preferably in reactjs. I think will be useful to many junior developers like me since ES6 and reactjs are taking place really soon.

Thank you.

Heatmap data

Hi,

Firstly... amazing library! Well done. It looks spectacular.

The documentation for Heatmap on the front page says the data should look like this:
Data format:

var data = [
// each datum should be
// layout_block_id, start, end, value
['january', 0, 1, 1368001],
['january', 1, 2, 1458583],
['january', 2, 3, 1481633],
]

i.e. each datum is an array. However, when I tried using this nothing would render.

When I changed the data format to use objects as datum:

var data = [
{
block_id: 'january',
start: 1,
end: 10,
value: 5
}
];

Then it renders. I spent many hours trying to debug why it wasn't working. This is either a bug (I think it should accept the array datum, Highchart series work this way) or else a regression?

Label orientation in text.js example

Hello!

I've faced a problem with label orientation in text track. It seems that it changes angle clockwise but I need different behaviour like in the example in the demo. I have not found the parameter that manages it so I'm wondering how to do that.

Thank you in advance

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.