title: d3.min / d3.max - getting values with related date
body: <p>I'm using d3.js for displaying some line-graphs based on a csv-file which holds the SERP-rankings for different keywords for each day.</p>
  
  <p>The structure of the csv-file looks like this:</p>
  
  <pre><code>Keyword,Date,Google
  Keyword1,2015/5/24,6
  Keyword1,2015/5/25,6
  Keyword1,2015/5/26,6
  Keyword1,2015/5/27,6
  Keyword1,2015/5/28,6
  Keyword1,2015/5/29,6
  Keyword1,2015/5/30,6
  Keyword1,2015/5/31,6
  Keyword1,2015/6/1,6
  Keyword1,2015/6/2,6
  Keyword1,2015/6/3,6
  Keyword1,2015/6/4,6
  Keyword1,2015/6/6,6
  Keyword1,2015/6/7,6
  Keyword1,2015/6/8,6
  Keyword1,2015/6/9,6
  Keyword1,2015/6/10,6
  Keyword1,2015/6/11,6
  Keyword1,2015/6/12,6
  Keyword1,2015/6/13,6
  Keyword1,2015/6/14,6
  Keyword1,2015/6/16,6
  Keyword1,2015/6/17,6
  Keyword1,2015/6/18,6
  Keyword1,2015/6/19,6
  Keyword1,2015/6/20,6
  Keyword1,2015/6/21,20
  Keyword1,2015/6/22,20
  Keyword1,2015/6/23,20
  Keyword1,2015/6/24,20
  Keyword1,2015/6/25,21
  Keyword1,2015/6/26,21
  Keyword1,2015/6/27,21
  Keyword1,2015/6/28,21
  Keyword1,2015/6/29,21
  Keyword1,2015/6/30,21
  Keyword1,2015/7/1,21
  Keyword1,2015/7/2,21
  Keyword1,2015/7/3,22
  Keyword1,2015/7/4,22
  Keyword1,2015/7/5,22
  Keyword1,2015/7/6,22
  Keyword1,2015/7/7,22
  Keyword1,2015/7/8,22
  Keyword1,2015/7/9,22
  Keyword1,2015/7/10,22
  Keyword1,2015/7/11,22
  Keyword1,2015/7/12,22
  Keyword1,2015/7/15,22
  Keyword1,2015/7/16,21
  Keyword1,2015/7/19,21
  Keyword1,2015/7/20,21
  Keyword1,2015/7/21,21
  Keyword1,2015/7/22,21
  Keyword1,2015/7/24,21
  Keyword1,2015/7/25,20
  Keyword1,2015/7/26,21
  Keyword1,2015/7/27,21
  Keyword1,2015/7/28,22
  Keyword1,2015/7/29,20
  Keyword1,2015/7/30,20
  Keyword1,2015/7/31,20
  Keyword1,2015/8/1,21
  Keyword1,2015/8/3,22
  Keyword1,2015/8/4,22
  Keyword1,2015/8/5,18
  Keyword1,2015/8/6,35
  Keyword1,2015/8/7,5
  Keyword1,2015/8/8,5
  Keyword1,2015/8/9,3
  Keyword1,2015/8/10,3
  Keyword1,2015/8/11,3
  Keyword1,2015/8/12,3
  Keyword1,2015/8/13,3
  Keyword1,2015/8/14,3
  Keyword1,2015/8/15,3
  Keyword1,2015/8/16,3
  Keyword1,2015/8/16,6
  Keyword2,2015/5/6,40
  Keyword2,2015/5/7,39
  Keyword2,2015/5/8,41
  Keyword2,2015/5/9,41
  Keyword2,2015/5/10,41
  Keyword2,2015/5/11,48
  Keyword2,2015/5/12,45
  Keyword2,2015/5/13,44
  Keyword2,2015/5/14,45
  Keyword2,2015/5/15,49
  Keyword2,2015/5/16,49
  Keyword2,2015/5/17,91
  Keyword2,2015/5/18,26
  Keyword2,2015/5/19,27
  Keyword2,2015/5/20,26
  Keyword2,2015/5/21,55
  Keyword2,2015/5/22,51
  Keyword2,2015/5/23,51
  Keyword2,2015/5/24,56
  Keyword2,2015/5/25,26
  Keyword2,2015/5/26,59
  Keyword2,2015/5/27,59
  Keyword2,2015/5/28,58
  Keyword2,2015/5/29,58
  Keyword2,2015/5/30,58
  Keyword2,2015/5/31,53
  Keyword2,2015/6/1,57
  Keyword2,2015/6/2,56
  Keyword2,2015/6/3,57
  Keyword2,2015/6/4,59
  Keyword2,2015/6/6,28
  Keyword2,2015/6/7,54
  Keyword2,2015/6/8,53
  Keyword2,2015/6/9,51
  Keyword2,2015/6/10,57
  Keyword2,2015/6/11,59
  Keyword2,2015/6/12,60
  Keyword2,2015/6/13,55
  Keyword2,2015/6/14,55
  Keyword2,2015/6/16,55
  Keyword2,2015/6/17,55
  Keyword2,2015/6/18,59
  Keyword2,2015/6/19,57
  Keyword2,2015/6/20,59
  Keyword2,2015/6/21,29
  Keyword2,2015/6/22,27
  Keyword2,2015/6/23,29
  Keyword2,2015/6/24,29
  Keyword2,2015/6/25,31
  Keyword2,2015/6/26,28
  Keyword2,2015/6/27,28
  Keyword2,2015/6/28,27
  Keyword2,2015/6/29,35
  Keyword2,2015/6/30,35
  Keyword2,2015/7/1,34
  Keyword2,2015/7/2,29
  Keyword2,2015/7/3,29
  Keyword2,2015/7/4,25
  Keyword2,2015/7/5,25
  Keyword2,2015/7/6,27
  Keyword2,2015/7/7,27
  Keyword2,2015/7/8,27
  Keyword2,2015/7/9,27
  Keyword2,2015/7/10,30
  Keyword2,2015/7/11,29
  Keyword2,2015/7/12,29
  Keyword2,2015/7/15,26
  Keyword2,2015/7/16,25
  Keyword2,2015/7/19,23
  Keyword2,2015/7/20,27
  Keyword2,2015/7/21,28
  Keyword2,2015/7/22,28
  Keyword2,2015/7/23,21
  Keyword2,2015/7/24,21
  Keyword2,2015/7/25,20
  Keyword2,2015/7/26,20
  Keyword2,2015/7/27,27
  Keyword2,2015/7/28,26
  Keyword2,2015/7/29,27
  Keyword2,2015/7/30,20
  Keyword2,2015/7/31,20
  Keyword2,2015/8/1,21
  Keyword2,2015/8/3,21
  Keyword2,2015/8/4,21
  Keyword2,2015/8/5,20
  Keyword2,2015/8/6,19
  Keyword2,2015/8/7,33
  Keyword2,2015/8/8,30
  Keyword2,2015/8/9,29
  Keyword2,2015/8/10,29
  Keyword2,2015/8/11,29
  Keyword2,2015/8/12,26
  Keyword2,2015/8/13,27
  Keyword2,2015/8/14,37
  Keyword2,2015/8/15,33
  Keyword2,2015/8/16,36
  Keyword2,2015/8/16,36
  </code></pre>
  
  <p>When I use some code the "normal" way, like I saw in my researches, everything works fine:</p>
  
  <pre><code>s.max = d3.max(s.values, function (d) {
      return d.Google;
  })
  s.min = d3.min(s.values, function (d) {
      return d.Google;
  })
  </code></pre>
  
  <p>This works well and outputs this:</p>
  
  <blockquote>
    <p>Keyword1</p>
    
    <p>Best position: 3</p>
    
    <p>Worst position: 35</p>
    
    <p>Keyword2</p>
    
    <p>Best position: 19</p>
    
    <p>Worst position: 91</p>
  </blockquote>
  
  <p>But this only outputs the Google-value.</p>
  
  <p><strong>What I want to achieve is that the related "Date" to the found max-value gets displayed as well.</strong></p>
  
  <p>So I tried it like this:</p>
  
  <pre><code>s.max = d3.max(s.values, function (d) {
      var parseDate = d3.time.format("%d-%m-%Y");
      return d.Google + " (" + parseDate(d.Date) + ")";
  })
  
  s.min = d3.min(s.values, function (d) {
      var parseDate = d3.time.format("%d-%m-%Y");
      return d.Google + " (" + parseDate(d.Date) + ")";
  })
  </code></pre>
  
  <p>This looks nice at first. But the problem is, that sometimes the output isn't correct.</p>
  
  <blockquote>
    <p>Keyword1</p>
    
    <p>Best position: 18 (05-08-2015)</p>
    
    <p>Worst position: 6 (31-05-2015)</p>
    
    <p>Keyword2</p>
    
    <p>Best position: 19 (06-08-2015)</p>
    
    <p>Worst position: 91 (17-05-2015)</p>
  </blockquote>
  
  <p>So as you can see, the output for Keyword2 is correct, but not for Keyword1 ,which should be :</p>
  
  <blockquote>
    <p>Keyword1</p>
    
    <p>Best position: 3 (09-08-2015)  </p>
    
    <p>Worst position: 35 (06-08-2015)</p>
  </blockquote>
  
  <p>I also tried it without the "parseDate", but this results in the same wrong output.</p>
  
  <p>Can anyone tell me what is getting wrong here, why the output isn't correct?</p>