0

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

user977828
  • 7,259
  • 16
  • 66
  • 117
  • What's your console say? When I try your code I get a 404 from `https://cdn.rawgit.com/nicgirault/circosJS/master/dist/circosJS.js` – Mark Oct 30 '17 at 01:01
  • I provided new url to `circos.min.js` but I got ```Refused to execute script from 'https://github.com/nicgirault/circosJS/blob/master/dist/circos.min.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled. chords.js:17 Uncaught TypeError: Cannot read property 'offsetWidth' of undefined at drawCircos (chords.js:17) at Queue._call (d3-queue.js:42) at maybeNotify (d3-queue.js:118) at abort (d3-queue.js:111) at Object. (d3-queue.js:85) at Dispatch.call (d3.js:668) at XMLHttpRequest.respond (d3.js:10918)``` – user977828 Oct 30 '17 at 01:21
  • This STILL give me not found: `https://github.com/nicgirault/circosJS/blob/master/dist/cir‌​cos.min.js` – Mark Oct 30 '17 at 01:23
  • I suggest going here and downloading a local copy: http://circos.ca/software/download/circos/ Then try to get a minimal example working with no errors before trying to put it all together. You have way too much code for not even getting the library loaded. – Mark Oct 30 '17 at 01:28
  • I changed it to `https://raw.githubusercontent.com/nicgirault/circosJS/master/dist/circos.min.js` but it did not help. I try to get this project running https://github.com/nicgirault/circosJS – user977828 Oct 30 '17 at 01:32
  • The url they suggest there is `` I just used it to make a graphic and it worked by following the example on that page. – Mark Oct 30 '17 at 01:42
  • Here's a minimal working example: https://jsfiddle.net/markm/at075hb8/ – Mark Oct 30 '17 at 01:46
  • I used your url and one of the problems disappear but this one still remains: Uncaught TypeError: Cannot read property 'offsetWidth' of undefined at drawCircos (chords.js:17) at Queue._call (d3-queue.js:42) at maybeNotify (d3-queue.js:118) at abort (d3-queue.js:111) at Object. (d3-queue.js:85) at Dispatch.call (d3.js:668) at XMLHttpRequest.respond (d3.js:10918) – user977828 Oct 30 '17 at 01:57
  • I would love to help you more, but I can't run your code without knowing what your data looks like. – Mark Oct 30 '17 at 02:04
  • Please find here (https://drive.google.com/open?id=0ByXM-Pf2rHncb0UzTlFWUGo5ZWc) the code and data – user977828 Oct 30 '17 at 02:36
  • I updated `data/data.json` which is stored in above link – user977828 Oct 30 '17 at 07:51
  • I fixed my data and my `index.html` was missing few elements but I got new problems which I describe [here](https://stackoverflow.com/questions/47024634/error-path-attribute-d-expected-number-43564672524005lnan-nanz) – user977828 Oct 30 '17 at 21:45

0 Answers0