13aed5063SGreg Roach<?php 23aed5063SGreg Roach 3b6c326d8SGreg Roachuse Fisharebest\Webtrees\I18N; 4b6c326d8SGreg Roachuse Fisharebest\Webtrees\View; 5c6266a77SGreg Roach 6b6c326d8SGreg Roach?> 7b6c326d8SGreg Roach 8b6c326d8SGreg Roach<div class="container pt-3"> 9b6c326d8SGreg Roach <h4 class="border-bottom p-2 mb-4"> 10b6c326d8SGreg Roach <?= I18N::translate('Create your own chart') ?> 11b6c326d8SGreg Roach </h4> 12b6c326d8SGreg Roach 13*3aa29b97SGreg Roach <form method="post" action="<?= e(route('module', ['module' => $module->name(), 'action' => 'CustomChart', 'tree' => $tree->name()])) ?>" id="own-stats-form" class="wt-page-options wt-page-options-statistics"> 14*3aa29b97SGreg Roach <?= csrf_field() ?> 15*3aa29b97SGreg Roach 16b6c326d8SGreg Roach <div class="form-group row"> 17b6c326d8SGreg Roach <div class="col-sm-2 wt-page-options-label"> 18b6c326d8SGreg Roach <?= I18N::translate('Chart type') ?> 19b6c326d8SGreg Roach </div> 20b6c326d8SGreg Roach 21b6c326d8SGreg Roach <div class="col-sm-4 wt-page-options-value"> 22b6c326d8SGreg Roach <fieldset> 23b6c326d8SGreg Roach <legend><?= I18N::translate('Individual') ?></legend> 24b6c326d8SGreg Roach 2571378461SGreg Roach <?= view('components/radios', [ 2671378461SGreg Roach 'name' => 'x-as', 'selected' => $module::X_AXIS_BIRTH_MONTH, 'options' => [ 27b6c326d8SGreg Roach $module::X_AXIS_BIRTH_MONTH => I18N::translate('Month of birth'), 28b6c326d8SGreg Roach $module::X_AXIS_DEATH_MONTH => I18N::translate('Month of death'), 29b6c326d8SGreg Roach $module::X_AXIS_FIRST_CHILD_MONTH => I18N::translate('Month of birth of first child in a relation'), 30b6c326d8SGreg Roach $module::X_AXIS_AGE_AT_DEATH => I18N::translate('Average age at death'), 31b6c326d8SGreg Roach $module::X_AXIS_AGE_AT_MARRIAGE => I18N::translate('Age in year of marriage'), 32b6c326d8SGreg Roach $module::X_AXIS_AGE_AT_FIRST_MARRIAGE => I18N::translate('Age in year of first marriage'), 33b6c326d8SGreg Roach 3471378461SGreg Roach ], 3571378461SGreg Roach ]) ?> 36b6c326d8SGreg Roach </fieldset> 37b6c326d8SGreg Roach 38b6c326d8SGreg Roach <fieldset> 39b6c326d8SGreg Roach <legend><?= I18N::translate('Family') ?></legend> 40b6c326d8SGreg Roach 4171378461SGreg Roach <?= view('components/radios', [ 4271378461SGreg Roach 'name' => 'x-as', 'selected' => $module::X_AXIS_BIRTH_MONTH, 'options' => [ 43b6c326d8SGreg Roach $module::X_AXIS_MARRIAGE_MONTH => I18N::translate('Month of marriage'), 44b6c326d8SGreg Roach $module::X_AXIS_FIRST_MARRIAGE_MONTH => I18N::translate('Month of first marriage'), 45b6c326d8SGreg Roach $module::X_AXIS_NUMBER_OF_CHILDREN => I18N::translate('Number of children'), 46b6c326d8SGreg Roach 4771378461SGreg Roach ], 4871378461SGreg Roach ]) ?> 49b6c326d8SGreg Roach </fieldset> 50b6c326d8SGreg Roach 51b6c326d8SGreg Roach <fieldset> 52b6c326d8SGreg Roach <legend><?= I18N::translate('Map') ?></legend> 53b6c326d8SGreg Roach 5471378461SGreg Roach <?= view('components/radios', [ 5571378461SGreg Roach 'name' => 'x-as', 'selected' => $module::X_AXIS_BIRTH_MONTH, 'options' => [ 56b6c326d8SGreg Roach $module::X_AXIS_INDIVIDUAL_MAP => I18N::translate('Individuals'), 57b6c326d8SGreg Roach $module::X_AXIS_BIRTH_MAP => I18N::translate('Births'), 58b6c326d8SGreg Roach $module::X_AXIS_MARRIAGE_MAP => I18N::translate('Marriages'), 59b6c326d8SGreg Roach $module::X_AXIS_DEATH_MAP => I18N::translate('Deaths'), 6071378461SGreg Roach ], 6171378461SGreg Roach ]) ?> 62b6c326d8SGreg Roach </fieldset> 63b6c326d8SGreg Roach </div> 64b6c326d8SGreg Roach 65b6c326d8SGreg Roach <div class="col-sm-2 wt-page-options-label"> 66b6c326d8SGreg Roach <?= I18N::translate('Details') ?> 67b6c326d8SGreg Roach </div> 68b6c326d8SGreg Roach 69b6c326d8SGreg Roach <div class="col-sm-4 wt-page-options-value"> 70b6c326d8SGreg Roach <fieldset id="axes"> 71b6c326d8SGreg Roach <legend><?= I18N::translate('Categories') ?></legend> 72b6c326d8SGreg Roach 73b6c326d8SGreg Roach <label> 74b6c326d8SGreg Roach <input type="radio" id="z_none" name="z-as" value="<?= $module::Z_AXIS_ALL ?>" onclick="statusDisable('z-axis-boundaries-periods');"> 75b6c326d8SGreg Roach <?= I18N::translate('none') ?> 76b6c326d8SGreg Roach </label> 77b6c326d8SGreg Roach <br> 78b6c326d8SGreg Roach <label> 79b6c326d8SGreg Roach <input type="radio" id="z_sex" name="z-as" value="<?= $module::Z_AXIS_SEX ?>" onclick="statusDisable('z-axis-boundaries-periods');"> 80b6c326d8SGreg Roach <?= I18N::translate('gender') ?> 81b6c326d8SGreg Roach </label> 82b6c326d8SGreg Roach <br> 83b6c326d8SGreg Roach <label> 84b6c326d8SGreg Roach <input type="radio" id="z_time" name="z-as" value="<?= $module::Z_AXIS_TIME ?>" checked onclick="statusEnable('z-axis-boundaries-periods');"> 85b6c326d8SGreg Roach <?= I18N::translate('date periods') ?> 86b6c326d8SGreg Roach </label> 87b6c326d8SGreg Roach <label for="z-axis-boundaries-periods" class="sr-only"> 88b6c326d8SGreg Roach <?= I18N::translate('Date range') ?> 89b6c326d8SGreg Roach </label> 90b6c326d8SGreg Roach <select id="z-axis-boundaries-periods" class="form-control" name="z-axis-boundaries-periods"> 91b6c326d8SGreg Roach <option value="1700,1750,1800,1850,1900,1950,2000" selected> 92b6c326d8SGreg Roach <?= /* I18N: from 1700 interval 50 years */ 93b6c326d8SGreg Roach I18N::plural('from %1$s interval %2$s year', 'from %1$s interval %2$s years', 50, I18N::digits(1700), I18N::number(50)) ?> 94b6c326d8SGreg Roach </option> 95b6c326d8SGreg Roach <option value="1800,1840,1880,1920,1950,1970,2000"> 96b6c326d8SGreg Roach <?= I18N::plural('from %1$s interval %2$s year', 'from %1$s interval %2$s years', 40, I18N::digits(1800), I18N::number(40)) ?> 97b6c326d8SGreg Roach </option> 98b6c326d8SGreg Roach <option value="1800,1850,1900,1950,2000"> 99b6c326d8SGreg Roach <?= I18N::plural('from %1$s interval %2$s year', 'from %1$s interval %2$s years', 50, I18N::digits(1800), I18N::number(50)) ?> 100b6c326d8SGreg Roach </option> 101b6c326d8SGreg Roach <option value="1900,1920,1940,1960,1980,1990,2000"> 102b6c326d8SGreg Roach <?= I18N::plural('from %1$s interval %2$s year', 'from %1$s interval %2$s years', 20, I18N::digits(1900), I18N::number(20)) ?> 103b6c326d8SGreg Roach </option> 104b6c326d8SGreg Roach <option value="1900,1925,1950,1975,2000"> 105b6c326d8SGreg Roach <?= I18N::plural('from %1$s interval %2$s year', 'from %1$s interval %2$s years', 25, I18N::digits(1900), I18N::number(25)) ?> 106b6c326d8SGreg Roach </option> 107b6c326d8SGreg Roach <option value="1940,1950,1960,1970,1980,1990,2000"> 108b6c326d8SGreg Roach <?= I18N::plural('from %1$s interval %2$s year', 'from %1$s interval %2$s years', 10, I18N::digits(1940), I18N::number(10)) ?> 109b6c326d8SGreg Roach </option> 110b6c326d8SGreg Roach </select> 111b6c326d8SGreg Roach </fieldset> 112b6c326d8SGreg Roach 113b6c326d8SGreg Roach <fieldset id="zyaxes"> 114b6c326d8SGreg Roach <legend><?= I18N::translate('Results') ?></legend> 115b6c326d8SGreg Roach 116b6c326d8SGreg Roach <label> 117b6c326d8SGreg Roach <input type="radio" name="y-as" value="<?= $module::Y_AXIS_NUMBERS ?>" checked> 118b6c326d8SGreg Roach <?= I18N::translate('numbers') ?> 119b6c326d8SGreg Roach </label> 120b6c326d8SGreg Roach <br> 121b6c326d8SGreg Roach <label> 122b6c326d8SGreg Roach <input type="radio" name="y-as" value="<?= $module::Y_AXIS_PERCENT ?>"> 123b6c326d8SGreg Roach <?= I18N::translate('percentage') ?> 124b6c326d8SGreg Roach </label> 125b6c326d8SGreg Roach </fieldset> 126b6c326d8SGreg Roach 127b6c326d8SGreg Roach <fieldset id="x_years" style="display:none;"> 128b6c326d8SGreg Roach <legend><?= I18N::translate('Age interval') ?></legend> 129b6c326d8SGreg Roach 130b6c326d8SGreg Roach <label for="x-axis-boundaries-ages" class="sr-only"> 131b6c326d8SGreg Roach <?= I18N::translate('Age interval') ?> 132b6c326d8SGreg Roach </label> 133c9e11c2aSGreg Roach <?= view('components/select', ['name' => 'x-axis-boundaries-ages', 'selected' => '1,5,10,20,30,40,50,60,70,80,90,100', 'options' => ['1,5,10,20,30,40,50,60,70,80,90,100' => I18N::plural('%s year', '%s years', 10, I18N::number(10)), '5,20,40,60,75,80,85,90' => I18N::plural('%s year', '%s years', 20, I18N::number(20)), '10,25,50,75,100' => I18N::plural('%s year', '%s years', 25, I18N::number(25))]]) ?> 134b6c326d8SGreg Roach </fieldset> 135b6c326d8SGreg Roach 136b6c326d8SGreg Roach <fieldset id="x_years_m" style="display:none;"> 137b6c326d8SGreg Roach <legend><?= I18N::translate('Age interval') ?></legend> 138b6c326d8SGreg Roach 139b6c326d8SGreg Roach <label for="x-axis-boundaries-ages_m" class="sr-only"> 140b6c326d8SGreg Roach <?= I18N::translate('Select the desired age interval') ?> 141b6c326d8SGreg Roach </label> 142c9e11c2aSGreg Roach <?= view('components/select', ['name' => 'x-axis-boundaries-ages_m', 'selected' => '16,18,20,22,24,26,28,30,32,35,40,50', 'options' => ['16,18,20,22,24,26,28,30,32,35,40,50' => I18N::plural('%s year', '%s years', 2, I18N::number(2)), '20,25,30,35,40,45,50' => I18N::plural('%s year', '%s years', 5, I18N::number(5))]]) ?> 143b6c326d8SGreg Roach </fieldset> 144b6c326d8SGreg Roach 145b6c326d8SGreg Roach <div id="map_opt" style="display:none;"> 146b6c326d8SGreg Roach <fieldset id="chart_type"> 147b6c326d8SGreg Roach <legend><?= I18N::translate('Chart type') ?></legend> 148b6c326d8SGreg Roach 149b6c326d8SGreg Roach <label for="chart_type" class="sr-only"><?= I18N::translate('Chart type') ?></label> 150b6c326d8SGreg Roach <select name="chart_type" class="form-control" onchange="statusShowSurname(this);"> 151b6c326d8SGreg Roach <option value="indi_distribution_chart" selected> 152b6c326d8SGreg Roach <?= I18N::translate('Individuals') ?> 153b6c326d8SGreg Roach </option> 154b6c326d8SGreg Roach <option value="surname_distribution_chart"> 155b6c326d8SGreg Roach <?= I18N::translate('Surnames') ?> 156b6c326d8SGreg Roach </option> 157b6c326d8SGreg Roach </select> 158b6c326d8SGreg Roach 159b6c326d8SGreg Roach <div id="surname_opt" class="form-group" style="display:none;"> 160b6c326d8SGreg Roach <label for="SURN"><?= I18N::translate('Surname') ?></label> 161b6c326d8SGreg Roach <input data-autocomplete-type="SURN" class="form-control" type="text" id="SURN" name="SURN"> 162b6c326d8SGreg Roach </div> 163b6c326d8SGreg Roach </fieldset> 164b6c326d8SGreg Roach 165b6c326d8SGreg Roach <fieldset> 166b6c326d8SGreg Roach <legend id="label-area"><?= I18N::translate('Geographic area') ?></legend> 167b6c326d8SGreg Roach 168b6c326d8SGreg Roach <label for="chart_shows" class="sr-only"><?= I18N::translate('Geographic area') ?></label> 169b6c326d8SGreg Roach <select id="chart_shows" class="form-control" name="chart_shows"> 170b6c326d8SGreg Roach <option value="world" selected> 171b6c326d8SGreg Roach <?= I18N::translate('World') ?> 172b6c326d8SGreg Roach </option> 173b6c326d8SGreg Roach <option value="150"> 174b6c326d8SGreg Roach <?= I18N::translate('Europe') ?> 175b6c326d8SGreg Roach </option> 176b6c326d8SGreg Roach <option value="021"> 177b6c326d8SGreg Roach <?= I18N::translate('Northern America') ?> 178b6c326d8SGreg Roach </option> 179b6c326d8SGreg Roach <option value="005"> 180b6c326d8SGreg Roach <?= I18N::translate('South America') ?> 181b6c326d8SGreg Roach </option> 182b6c326d8SGreg Roach <option value="142"> 183b6c326d8SGreg Roach <?= I18N::translate('Asia') ?> 184b6c326d8SGreg Roach </option> 185b6c326d8SGreg Roach <option value="145"> 186b6c326d8SGreg Roach <?= I18N::translate('Middle East') ?> 187b6c326d8SGreg Roach </option> 188b6c326d8SGreg Roach <option value="002"> 189b6c326d8SGreg Roach <?= I18N::translate('Africa') ?> 190b6c326d8SGreg Roach </option> 191b6c326d8SGreg Roach </select> 192b6c326d8SGreg Roach </fieldset> 193b6c326d8SGreg Roach </div> 194b6c326d8SGreg Roach </div> 195b6c326d8SGreg Roach </div> 196b6c326d8SGreg Roach 197b6c326d8SGreg Roach <p> 198b6c326d8SGreg Roach <button type="submit" class="btn btn-primary"> 199b6c326d8SGreg Roach <?= view('icons/save') ?> 200b6c326d8SGreg Roach <?= I18N::translate('show the chart') ?> 201b6c326d8SGreg Roach </button> 202b6c326d8SGreg Roach </p> 203b6c326d8SGreg Roach </form> 204b6c326d8SGreg Roach 205b6c326d8SGreg Roach <div id="custom-chart" class="wt-ajax-load"> 206b6c326d8SGreg Roach <!-- Not initially empty, to disable spinner --> 207b6c326d8SGreg Roach </div> 208b6c326d8SGreg Roach</div> 209b6c326d8SGreg Roach 210b6c326d8SGreg Roach<?php View::push('javascript') ?> 211c6266a77SGreg Roach<script> 212c6266a77SGreg Roach function statusDisable(sel) { 213c6266a77SGreg Roach var cbox = document.getElementById(sel); 214c6266a77SGreg Roach cbox.checked = false; 215c6266a77SGreg Roach cbox.disabled = true; 216c6266a77SGreg Roach } 217c6266a77SGreg Roach 218c6266a77SGreg Roach function statusEnable(sel) { 219c6266a77SGreg Roach var cbox = document.getElementById(sel); 220c6266a77SGreg Roach cbox.disabled = false; 221c6266a77SGreg Roach } 222c6266a77SGreg Roach 223c6266a77SGreg Roach function statusHide(sel) { 224c6266a77SGreg Roach var box = document.getElementById(sel); 225c6266a77SGreg Roach box.style.display = "none"; 226c6266a77SGreg Roach var box_m = document.getElementById(sel + "_m"); 227c6266a77SGreg Roach if (box_m) { 228c6266a77SGreg Roach box_m.style.display = "none"; 229c6266a77SGreg Roach } 230c6266a77SGreg Roach if (sel === "map_opt") { 231c6266a77SGreg Roach var box_axes = document.getElementById("axes"); 232c6266a77SGreg Roach if (box_axes) { 233c6266a77SGreg Roach box_axes.style.display = ""; 234c6266a77SGreg Roach } 235c6266a77SGreg Roach var box_zyaxes = document.getElementById("zyaxes"); 236c6266a77SGreg Roach if (box_zyaxes) { 237c6266a77SGreg Roach box_zyaxes.style.display = ""; 238c6266a77SGreg Roach } 239c6266a77SGreg Roach } 240c6266a77SGreg Roach } 241c6266a77SGreg Roach 242c6266a77SGreg Roach function statusShow(sel) { 243c6266a77SGreg Roach var box = document.getElementById(sel); 244c6266a77SGreg Roach box.style.display = ""; 245c6266a77SGreg Roach var box_m = document.getElementById(sel + "_m"); 246c6266a77SGreg Roach if (box_m) { 247c6266a77SGreg Roach box_m.style.display = "none"; 248c6266a77SGreg Roach } 249c6266a77SGreg Roach if (sel === "map_opt") { 250c6266a77SGreg Roach var box_axes = document.getElementById("axes"); 251c6266a77SGreg Roach if (box_axes) { 252c6266a77SGreg Roach box_axes.style.display = "none"; 253c6266a77SGreg Roach } 254c6266a77SGreg Roach var box_zyaxes = document.getElementById("zyaxes"); 255c6266a77SGreg Roach if (box_zyaxes) { 256c6266a77SGreg Roach box_zyaxes.style.display = "none"; 257c6266a77SGreg Roach } 258c6266a77SGreg Roach } 259c6266a77SGreg Roach } 260c6266a77SGreg Roach 261c6266a77SGreg Roach function statusChecked(sel) { 262c6266a77SGreg Roach var cbox = document.getElementById(sel); 263c6266a77SGreg Roach cbox.checked = true; 264c6266a77SGreg Roach } 265c6266a77SGreg Roach 266c6266a77SGreg Roach function statusShowSurname(x) { 267c6266a77SGreg Roach if (x.value === "surname_distribution_chart") { 268c6266a77SGreg Roach document.getElementById("surname_opt").style.display = ""; 269c6266a77SGreg Roach } else if (x.value !== "surname_distribution_chart") { 270c6266a77SGreg Roach document.getElementById("surname_opt").style.display = "none"; 271c6266a77SGreg Roach } 272c6266a77SGreg Roach } 273c6266a77SGreg Roach 274c6266a77SGreg Roach function loadCustomChart() { 275c6266a77SGreg Roach $("#custom-chart").html(""); 276c6266a77SGreg Roach var form = $("#own-stats-form"); 277*3aa29b97SGreg Roach jQuery.post(form.attr("action"), form.serialize()) 278c6266a77SGreg Roach .done(function (data) { 279c6266a77SGreg Roach $("#custom-chart").html(data); 280c6266a77SGreg Roach }) 281c6266a77SGreg Roach .fail(function (jqXHR, textStatus) { 282c6266a77SGreg Roach // Server error? Show something to get rid of the spinner. 283c6266a77SGreg Roach $("#custom-chart").html(textStatus); 284c6266a77SGreg Roach }); 285c6266a77SGreg Roach return false; 286c6266a77SGreg Roach } 287b6c326d8SGreg Roach 288b6c326d8SGreg Roach $("[name='x-as']").change(function () { 289b6c326d8SGreg Roach var x_axis = document.querySelector("[name='x-as']:checked").value; 290b6c326d8SGreg Roach 291b6c326d8SGreg Roach switch (x_axis) { 292b6c326d8SGreg Roach case "<?= e($module::X_AXIS_BIRTH_MONTH) ?>": 293b6c326d8SGreg Roach case "<?= e($module::X_AXIS_DEATH_MONTH) ?>": 294b6c326d8SGreg Roach case "<?= e($module::X_AXIS_FIRST_CHILD_MONTH) ?>": 295b6c326d8SGreg Roach statusEnable("z_sex"); 296b6c326d8SGreg Roach statusHide("x_years"); 297b6c326d8SGreg Roach statusHide("map_opt"); 298b6c326d8SGreg Roach break; 299b6c326d8SGreg Roach 300b6c326d8SGreg Roach case "<?= e($module::X_AXIS_AGE_AT_DEATH) ?>": 301b6c326d8SGreg Roach statusEnable("z_sex"); 302b6c326d8SGreg Roach statusShow("x_years"); 303b6c326d8SGreg Roach statusHide("map_opt"); 304b6c326d8SGreg Roach break; 305b6c326d8SGreg Roach 306b6c326d8SGreg Roach case "<?= e($module::X_AXIS_AGE_AT_MARRIAGE) ?>": 307b6c326d8SGreg Roach case "<?= e($module::X_AXIS_AGE_AT_FIRST_MARRIAGE) ?>": 308b6c326d8SGreg Roach statusEnable("z_sex"); 309b6c326d8SGreg Roach statusHide("x_years"); 310b6c326d8SGreg Roach statusShow("x_years_m"); 311b6c326d8SGreg Roach statusHide("map_opt"); 312b6c326d8SGreg Roach break; 313b6c326d8SGreg Roach 314b6c326d8SGreg Roach case "<?= e($module::X_AXIS_MARRIAGE_MONTH) ?>": 315b6c326d8SGreg Roach case "<?= e($module::X_AXIS_FIRST_MARRIAGE_MONTH) ?>": 316b6c326d8SGreg Roach statusChecked("z_none"); 317b6c326d8SGreg Roach statusDisable("z_sex"); 318b6c326d8SGreg Roach statusHide("x_years"); 319b6c326d8SGreg Roach statusHide("map_opt"); 320b6c326d8SGreg Roach break; 321b6c326d8SGreg Roach 322b6c326d8SGreg Roach case "<?= e($module::X_AXIS_INDIVIDUAL_MAP) ?>": 323b6c326d8SGreg Roach statusHide("x_years"); 324b6c326d8SGreg Roach statusShow("map_opt"); 325b6c326d8SGreg Roach statusShow("chart_type"); 326b6c326d8SGreg Roach break; 327b6c326d8SGreg Roach 328b6c326d8SGreg Roach case "<?= e($module::X_AXIS_BIRTH_MAP) ?>": 329b6c326d8SGreg Roach case "<?= e($module::X_AXIS_MARRIAGE_MAP) ?>": 330b6c326d8SGreg Roach case "<?= e($module::X_AXIS_DEATH_MAP) ?>": 33171378461SGreg Roach statusHide("x_years"); 33271378461SGreg Roach statusShow("map_opt"); 333b6c326d8SGreg Roach statusHide("chart_type"); 334b6c326d8SGreg Roach statusHide("surname_opt"); 335b6c326d8SGreg Roach break; 336b6c326d8SGreg Roach } 337b6c326d8SGreg Roach }); 338b6c326d8SGreg Roach 339b6c326d8SGreg Roach $("#own-stats-form").on("submit", loadCustomChart); 340c6266a77SGreg Roach</script> 341b6c326d8SGreg Roach<?php View::endpush() ?> 342