Display a BACKGROUND module step by step

0. Download all files in this tutorial.

Download BACKGROUND.zip and click *.html file(in BACKGROUND.zip) to open this demo in local browser!.

1. Including BACKGROUND configuration

    Example file: BACKGROUND01.js

    Data structure

    Users should prepare the input data in the following format (separated by tabs).

    var BACKGROUND01 = [ "BACKGROUND01" , {
      BginnerRadius: 230,
      BgouterRadius: 200,
      BgFillColor: "#F2F2F2",
      BgborderColor : "#000",
      BgborderSize : 0.3,
      axisShow: "true",
      axisWidth: 0.1,
      axisColor: "#000",
      axisNum: 8
    }];
    var BACKGROUND02 = [ "BACKGROUND02" , {
      BginnerRadius: 170,
      BgouterRadius: 130,
      BgFillColor: "#F2F2F2",
      BgborderColor : "#000",
      BgborderSize : 0.3,
      axisShow: "true",
      axisWidth: 0.1,
      axisColor: "#000",
      axisNum: 8
    }];
    var BACKGROUND03 = [ "BACKGROUND03" , {
      BginnerRadius: 100,
      BgouterRadius: 50,
      BgFillColor: "#F2F2F2",
      BgborderColor : "#000",
      BgborderSize : 0.3,
      axisShow: "false",
      axisWidth: 0.1,
      axisColor: "#000",
      axisNum: 8
    }];
    

2. Initialize BACKGROUND configuration with data tag : BACKGROUND01, BACKGROUND02, BACKGROUND03

    Prepare a <div> tag with “example” id to set the picture position your will draw in html, e.g.:

    NGCircos01 = new NGCircos(BACKGROUND01,BACKGROUND02,BACKGROUND03,NGCircosGenome,{ // Initialize with "BACKGROUND01,BACKGROUND02,BACKGROUND03" data tag

3. Source code

    When step 1 and 2 are finished, the configuration for NGCircos:

    <button class="svg-action-btn download-img" style="height: 18px;line-height: 18px;padding: 0 11px;background: #FFFFFF;border: 1px #D9D9D9 solid;border-radius: 3px;display: inline-block;font-size: 12px;outline: none;color: black">Download png ↓</button>
    <a href="javascript:(function () { var e = document.createElement('script');if (window.location.protocol === 'https:') { e.setAttribute('src', './lib/svg-crowbar.js'); } else { e.setAttribute('src', './lib/svg-crowbar.js'); } e.setAttribute('class', 'svg-crowbar'); document.body.appendChild(e); })();" style="height: 18px;line-height: 18px;padding: 0 11px;background: #FFFFFF;border: 1px #D9D9D9 solid;border-radius: 3px;display: inline-block;font-size: 12px;outline: none;color: black" >Download svg ↓</a>
    <div id="NGCircos"></div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-lg-12">
                        <div id="NGCircos"></div>
                    </div>
                </div>
    <!-- Data configuration -->
    <script src="./lib/jquery.js"></script>
    <script src="./lib/d3.js"></script>
    <script src="./lib/NGCircos.js"></script>
    <script src="js/BACKGROUND01.js"></script>
    <!-- Genome configuration -->
    <script>
    var BACKGROUND01 = [ "BACKGROUND01" , {
      BginnerRadius: 230,
      BgouterRadius: 200,
      BgFillColor: "#F2F2F2",
      BgborderColor : "#000",
      BgborderSize : 0.3,
      axisShow: "true",
      axisWidth: 0.1,
      axisColor: "#000",
      axisNum: 8
    }];
    var BACKGROUND02 = [ "BACKGROUND02" , {
      BginnerRadius: 170,
      BgouterRadius: 130,
      BgFillColor: "#F2F2F2",
      BgborderColor : "#000",
      BgborderSize : 0.3,
      axisShow: "true",
      axisWidth: 0.1,
      axisColor: "#000",
      axisNum: 8
    }];
    var BACKGROUND03 = [ "BACKGROUND03" , {
      BginnerRadius: 100,
      BgouterRadius: 50,
      BgFillColor: "#F2F2F2",
      BgborderColor : "#000",
      BgborderSize : 0.3,
      axisShow: "false",
      axisWidth: 0.1,
      axisColor: "#000",
      axisNum: 8
    }];
      var NGCircosGenome = [
        [
         ["1" , 249250621],
         ["2" , 243199373],
         ["3" , 198022430],
         ["4" , 191154276],
         ["5" , 180915260],
         ["6" , 171115067],
         ["7" , 159138663],
         ["8" , 146364022],
         ["9" , 141213431],
         ["10" , 135534747],
         ["11" , 135006516],
         ["12" , 133851895],
         ["13" , 115169878],
         ["14" , 107349540],
         ["15" , 102531392],
         ["16" , 90354753],
         ["17" , 81195210],
         ["18" , 78077248],
         ["19" , 59128983],
         ["20" , 63025520],
         ["21" , 48129895],
         ["22" , 51304566],
         ["X" , 155270560],
         ["Y" , 59373566]
        ]
      ];
      NGCircos01 = new NGCircos(BACKGROUND01,BACKGROUND02,BACKGROUND03,NGCircosGenome,{  // Initialize with "BACKGROUND01,BACKGROUND02,BACKGROUND03" data tag
      //Main configuration
         target : "NGCircos",                       // Main configuration "target"
         svgWidth : 900,                             // Main configuration "svgWidth"
         svgHeight : 600,                            // Main configuration "svgHeight"
         chrPad : 0.04,                              // Main configuration "chrPad"
         innerRadius: 246,                           // Main configuration "innerRadius"
         outerRadius: 270,                           // Main configuration "outerRadius"
      });
      NGCircos01.draw_genome(NGCircos01.genomeLength); // NGCircos.js callback
      NGCircos01.draw_genome(NGCircos01.genomeLength2); // NGCircos2.js callback second time
    </script>
    <script src="./lib/saveSvgAsPng.js"></script>
    <script>
    
          (function(){
            var downloadImg = getEle(".download-img"),
              imgName = getEle("."+NGCircos01.svgClassName);
    
            //          imgScale = getEle(".img-scale");
    
            downloadImg.addEventListener("click",function(){
              var mySvg = getEle("."+NGCircos01.svgClassName),
                //iImgScale = parseInt(imgScale.value) || 1,
                oImgName = imgName.value || NGCircos01.svgClassName;
    
    //          saveSvgAsPng(mySvg, oImgName+".png", iImgScale);
              saveSvgAsPng(mySvg, oImgName+".png");
    
            })
    
            function getEle(obj){
              var d = document;
              return d.querySelector(obj);
            }
          })()
    </script>

4. Visualization of BACKGROUND data using NG-Circos

Download svg ↓