1

Here's a link to D3 code for a Hive Plot .. http://bl.ocks.org/mbostock/2066415

I have 2 questions regarding this:

  1. What does the index 'y' denote in the objects from the array 'nodes'

    var nodes = [ {x: 0, y: .1}, {x: 0, y: .9}, {x: 1, y: .2}, {x: 1, y: .3}, {x: 2, y: .1}, {x: 2, y: .8} ];

  2. How do I bind my data (json file) to the elements to get a more complex Hive Plot ? Can I even do it? My data is a protein-protein interaction dataset with source protein node, target protein node, protein type, protein name and protein group. I would like to make a network visualization using a Hive Plot.

Kindly help. I'm new to programming.

1 Answer 1

0
  1. the y attribute is the domain value that is mapped as the radius in the chart. by using the radius function (that is declared as a d3 linear scale) values between 0..1 are mapped to values between 40 and 240 (innerRadius, outerRadius). for better understanding, compare it with the x value: it is passed to the angle function, that again is a d3 scale, but this time, it is of type ordinal: it transform the discrete values 0, 1, 2 into an angle between 0 and 2*PI.

  2. you may bind arbitrary data (including json) through the data(..) method. the datum (the "d" attribute that you see everywhere) is any json object that you provide to the select function. the combination of select(..) and data(..) is known as a join: it matches svg elements with each item in your data. in this point you are free to interpret-access your custom datum in the way that best fits your needs.

2
  • If I have to use my protein data, I was thinking of using the type of the protein (0,1,2) as the x index and the protein number (1-2114) as the y index. It hasn't worked. I see the axes but no data points on the hive plot. How do I get the y index or the radius from my protein data?
    – Minu
    Commented Nov 16, 2014 at 1:41
  • keep in mind that you are free to name your vars to whatever value you want. in this example x and y are totally arbitrary, it is just the way how the values appear in the data array. notice that they are accessed as attributes of the datum: d.x, d.y. it could be d.myCrazyVar or whatever.second: notice that the y scale is being built without domain. it means that it expect values in the range 0..1. maybe that is why you cant see nothing. scale your data or provide a valid domain, check other examples and read the doc to better understand scales and domains. Commented Nov 16, 2014 at 18:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.