%( $Id: anclist_aad.txt mickroue(a)yahoo.fr 20140312 templ=templm %)

%( %import;anclist_deslist_stat_age %)

%( begin $Id: anclist_deslist_stat_age.txt mickroue(a)yahoo.fr 20131203 templ=templm %)

%define;stat_age1()
  <div class="col">
    110<br%/>100<br%/>90<br%/>80<br%/>
    70<br%/>60<br%/>50<br%/>40<br%/>
    30<br%/>20<br%/>10<br%/>0
  </div>
  <div class="body">
    %reset_count;
    %foreach;sorted_list_item;
      %if;(item.1 = 0)
        %incr_count;
        %if;(next_item.2 != item.2)
          %let;l_width0;%expr(count * l_size)%in;
          %let;l_width;%if;(l_width0 > max_width)%max_width;%else;%l_width0;%end;%in;
          <span class="a%item.1;%item.2;" style="border-left:solid %l_width;px #4682B4;">%count;</span>
          %reset_count;
        %end;
      %end;
      %if;(item.1 = 1)
        %incr_count;
        %if;(next_item.2 != item.2)
          %let;l_width0;%expr(count * l_size)%in;
          %let;l_width;%if;(l_width0 > max_width)%max_width;%else;%l_width0;%end;%in;
          <span class="a%item.1;%item.2;" style="border-left:solid %l_width;px #FF69B4;">%count;</span>
          %reset_count;
        %end;
      %end;
    %end;
  </div>
%end;

%define;stat_age2()
  %let;l_height;%expr(40 + (count *2))%in;
  <div class="body bcbg1" style="height:%l_height;px;">
    %reset_count;
    %foreach;sorted_list_item;
      %incr_count;
      %let;l_top;%expr(20 + (count * 2))%in;
      %let;l_left0;%expr(20 + item.2 * 8)%in;
      %let;l_left;%if;(l_left0 > 840)840%else;%l_left0;%end;%in;
      %if;(count = 1)
        <span class="date">%item.1;</span>
        <span class="lev">%level;</span>
      %end;
      %if;(next_item.1 = "")<span class="date" style="top:%l_top;px;">%item.1;</span>%end;
      <a href="%prefix;i=%item.4;" class="link"
         style="color:#%if;(item.3 = 0)4682B4;%else;FF69B4%end;;left:%l_left;px;top:%l_top;px;">%item.2;</a>
    %end;
  </div>
%end;
%( end $Id: anclist_deslist_stat_age.txt mickroue(a)yahoo.fr 20131203 templ=templm %)

%( age_at_death by generation tf1 = aad %)
  %apply;gen()
  %reset_count;
  %empty_sorted_list;
  %foreach;ancestor_level(l_v)
    %if;(level > 1 and (evar.only != "on" or level = l_v))
      %foreach;ancestor;
        %if;(ancestor.same = "")
          %let;l_aby;%if;(ancestor.birth_date.year = "")9999%else;%ancestor.birth_date.year;%end;%in;
          %let;l_ady;%if;(ancestor.death_date.year = "")0%else;%ancestor.death_date.year;%end;%in;
          %if;(ancestor.computable_death_age and l_ady >= l_aby)
            %incr_count;
            %let;l_age;%expr((l_ady - l_aby)/10)%in;
            %apply;add_in_sorted_list(ancestor.sex,l_age,ancestor.index)
          %end;
        %end;
      %end;
    %end;
  %end;
  %let;max_width;360%in;
  %let;l_size;%expr(36 / ((60 + count) / 6 / 10))%in;
  <div class="stat_age1 bcbg1">
    <table class="title" width="100%%"><tr>
    <td>[*age]</td>
    <td align="center">[*age at death]
      (<span style="color:#4682B4;"/>[M/F]0</span>,
       <span style="color:#FF69B4;"/>[M/F]1</span>)</td>
    <td align="right"><em>%count; [date/dates]1</em></td>
    </tr></table>
    %apply;stat_age1()
  </div>
  <div class="stat_age2 bcbg1">
    <table class="title" width="100%%"><tr>
      <td>[*generation/generations]0</td>
      <td align="center">[*age at death]
          (<span style="color:#4682B4;"/>[M/F]0</span>,
           <span style="color:#FF69B4;"/>[M/F]1</span>)</td>
      <td align="right">[*date of birth]</td>
    </tr></table>
    %foreach;ancestor_level(l_v)
      %empty_sorted_list;
      %reset_count;
      %if;(level > 1 and (evar.only != "on" or level = l_v))
        %foreach;ancestor;
          %if;(ancestor.same = "")
            %let;l_aby;%if;(ancestor.birth_date.year = "")9999%else;%ancestor.birth_date.year;%end;%in;
            %let;l_ady;%if;(ancestor.death_date.year = "")0%else;%ancestor.death_date.year;%end;%in;
            %if;(ancestor.computable_death_age and l_ady >= l_aby)
              %incr_count;
              %let;l_age;%expr(l_ady - l_aby)%in;
              %apply;add_in_sorted_list(l_aby,l_age,ancestor.sex,ancestor.index)
            %end;
          %end;
        %end;
        %apply;stat_age2()
      %end;
    %end;
  </div>
