title: Prepare data for line chart of active tasks using d3
body: <p>I am trying to create a Line Chart to display how many Task have started, how many have ended, and how many are active at a given moment. The relevant Data of my Tasks is given in the form (taskID,taskType,starttime,endtime,caller,callerType). An example of this Data is given here:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>TaskID,TaskType,Start,End,Caller,CallerType,Generation
  construct,construct,0,6.5,Null,Null,0
  start1,startsweep,0.4,0.7,construct,construct,1
  start2,startsweep,0.8,4,construct,construct,1
  start3,startsweep,1.5,3,construct,construct,1
  start4,startsweep,2,3.3,construct,construct,1
  start5,startsweep,2.8,4.9,construct,construct,1
  start6,startsweep,3.4,4,construct,construct,1
  start7,startsweep,4.1,5.6,construct,construct,1
  start8,startsweep,5,6,construct,construct,1
  start9,startsweep,5.1,5.7,construct,construct,1
  start10,startsweep,6,6.3,construct,construct,1
  start11,startsweep,1.2,1.7,start2,startsweep,2
  start12,startsweep,1.7,2.9,start2,startsweep,2
  start13,startsweep,2.2,3,start2,startsweep,2
  start14,startsweep,3.1,3.9,start2,startsweep,2
  start15,startsweep,3,4,start5,startsweep,2
  start16,startsweep,5.1,5.4,start8,startsweep,2
  start17,startsweep,1.3,1.5,start11,startsweep,3
  start18,startsweep,1.9,2.5,start12,startsweep,3
  start19,startsweep,3.1,3.8,start15,startsweep,3
  start20,startsweep,5.2,5.3,start16,startsweep,3
  start21,startsweep,1.35,1.4,start17,startsweep,4
  start22,startsweep,3.15,3.75,start19,startsweep,4
  start23,startsweep,5.2,5.25,start20,startsweep,4
  start24,startsweep,3.15,3.25,start22,startsweep,5
  start25,startsweep,3.2,3.3,start22,startsweep,5
  start26,startsweep,3.25,3.7,start22,startsweep,5
  start27,startsweep,3.6,3.7,start22,startsweep,5
  start28,startsweep,3.3,3.5,start26,startsweep,6
  start29,startsweep,3.4,3.45,start28,startsweep,7</code></pre>
  </div>
  </div>
  </p>
  <p>The problem that I am having is how exactly to prepare this data for a line chart, given that a line chart only accepts data in the form (x[],y[]). I´ve been stuck thinking about creating a timespan with the minimum and maximum time and n Steps inbetween and then computing the starting(ending or active) tasks for the nearest step. <br> So for this example <code>createTimespan(0,6.5,20)</code> would create an array with 20 equally spaced numbers between 0 and 6.5, to thereafter count how many task started (ended or are active) in each of these steps. This would be a good enough solution for the given Dataset but lack precission for larger Datasets, aswell as probably be bad for performance. <br>
  So I am asking if someone had a similar Problem or has any idea on how to prepare this kind of Data for a line chart.</p>
  <p>Thank you in advance.</p>
  <p>Edit: Example data.</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>time,taskStarted,taskEnded,activeTasks
  0.1,2,0,2
  0.13,4,1,3
  0.16,5,3,2
  0.2,10,5,5
  0.5,11,9,2
  0.7,13,9,4
  1,15,10,5
  1.3,18,12,6
  1.5,20,15,5
  1.7,22,18,4
  2.4,22,22,0</code></pre>
  </div>
  </div>
  </p>