Author Archives: remkohdev

D3: Binding Multi-Dimensional Arrays and Deep Nested Data

The easiest way to work with D3 data arrays is to create simple arrays. For example, to create a stacked array, represent each stack in a stacked bar by the a comma separated value in a row per bar.

state, males, females
CT, 125, 135
NY, 240, 250

But if you are retrieving data from an open data API via REST for instance or if you want to use dynamic data visualizations where the visualization depends on user input, it is easier to use the built-in d3.nest function. For example, the following data comes from http://www.clinicaltrials.gov and is formatted as a .csv file:

"nct_id","gender","status","phase","city","state","minimum_age","maximum_age"
"NCT00000102","Both","Completed","Phase 1/Phase 2","Charleston","South Carolina","14 Years","35 Years",
"NCT00000104","Female","Completed","N/A","Minneapolis","Minnesota","N/A","N/A",
"NCT00000105","Male","Completed","Phase 3","Charleston","South Carolina","10 Years","14 Years",

If you use a simple nested array with one level of parent-child structure, it is straightforward to bind data to your elements.

var data1 = d3.nest()
  .key(function(d) { return d.state; }).sortKeys(d3.ascending)
  .entries(data);

Using the d3.nest() function with a single key generates the following data array structure. Continue reading

Der Engel und das Mädchen

durch ein Loch in den Himmel
schaue ich in die Wolken
und ich sehe das Lächeln eines Engels
aus der Augenhöhle rollt eine einzige Träne
und fällt in die weichen Kissen
einzigartig wie sie mir anschaut
und flüstert leise Worte der Trauer
zärtlich trinken meine Lippen von ihrem Kummer
und zaubert das Lächeln eines kleinen Mädchens
das in den Himmel steigt

I look into the clouds
through a hole in the sky
and I see the smile of an angel
from her socket a single tear rolls
and falls into the soft cushion
she looks at me singularly
and whispers sorrowful words
my lips drink from her tender grief
and the smile of a little girl appears
who rises toward the sky

Tree with Deep Roots

Tree with Deep Roots is the great saga of king Sejong and the creation of the Korean alphabet. The new script was announced in volume 102 of the Annals of King Sejong, which was published on October 9, 1446, now commemorated as Hangul Day. The publication was officially named ‘The Correct Sounds for the Instruction of the People’, in Korean 훈민정음 or Hunminjeong-eum, but became known as 한글 or Hangul. The new script caused huge controversy as it replaced the Chinese script, and with it threatened the Chinese influence, the existing Confucian order and the Korean socio-political system. Continue reading

Drupal: template.php form_alter and breadcrumb hooks

Add a Read-Only field to User Register Form

To create a read-only field on the user registration form in Drupal, for instance to add a Terms & Conditions textarea field, you must override the form_alter hook.

function _form_alter(&$form, &$form_state, $form_id) {
 if ($form_id == 'user_register_form') {
  $form['field_developer_agreement']['und'][0]['value']['#attributes']['readonly'] = 'readonly';
  $form['field_developer_agreement']['und'][0]['value']['#resizable'] = FALSE;
  $form['field_developer_agreement']['und'][0]['value']['#cols'] = 40;
 }
}

Continue reading