<commit_before><?xml version="1.0" encoding="UTF-8"?>

<!--
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->

<xwikidoc>
  <web>PhenoTips</web>
  <name>ChartGenerator</name>
  <language/>
  <defaultLanguage/>
  <translation>0</translation>
  <parent>PhenoTips.ChartService</parent>
  <creator>xwiki:XWiki.Admin</creator>
  <author>xwiki:XWiki.Admin</author>
  <customClass/>
  <contentAuthor>xwiki:XWiki.Admin</contentAuthor>
  <creationDate>1332741005000</creationDate>
  <date>1332773099000</date>
  <contentUpdateDate>1332773099000</contentUpdateDate>
  <version>1.1</version>
  <title/>
  <template/>
  <defaultTemplate/>
  <validationScript/>
  <comment/>
  <minorEdit>false</minorEdit>
  <syntaxId>xwiki/2.1</syntaxId>
  <hidden>false</hidden>
  <content>#macro (getPercentileValue $age $p)
  #set ($v = $services.measurements.get($chartConfiguration.measurementType).percentileToValue($sex, $age, $p))
#end
#macro (getSDValue $age $d)
  #set ($v = $services.measurements.get($chartConfiguration.measurementType).standardDeviationToValue($sex, $age, $d))
#end
#macro (getValuePercentile $age $v)
  #set ($p = $services.measurements.get($chartConfiguration.measurementType).valueToPercentile($sex, $age, $v))
#end
#macro (getValueSD $age $v)
  #set ($d = $services.measurements.get($chartConfiguration.measurementType).valueToStandardDeviation($sex, $age, $v))
#end
#macro (getPercentileColor $p)
  #set ($h = $mathtool.mul(110, $mathtool.pow($mathtool.div($mathtool.sub(50, $mathtool.abs($mathtool.sub($p, 50))), 50.0), 0.5)))
  #set ($s = 1)
  #set ($l = 0.5)
  #set ($r = $l)
  #set ($g = $l)
  #set ($b = $l)
  #if ($l &lt;= 0.5)
    #set ($v = ($l * (1.0 + $s)))
  #else
    #set ($v = ($l + $s - $l * $s))
  #end
  #if ($v &gt; 0)
    #set ($m = $l + $l - $v)
    #set ($sv = ($v - $m) / $v)
    #set ($h = $h / 60.0)
    #set ($sextant = $mathtool.floor($h))
    #set ($fract = $h - $sextant)
    #set ($vsf = $v * $sv * $fract)
    #set ($mid1 = $m + $vsf)
    #set ($mid2 = $v - $vsf)
    #if ($sextant == 0)
      #set ($r = $v)
      #set ($g = $mid1)
      #set ($b = $m)
    #elseif ($sextant == 1)
      #set ($r = $mid2)
      #set ($g = $v)
      #set ($b = $m)
    #elseif ($sextant == 2)
      #set ($r = $m)
      #set ($g = $v)
      #set ($b = $mid1)
    #elseif ($sextant == 3)
      #set ($r = $m)
      #set ($g = $mid2)
      #set ($b = $v)
    #elseif ($sextant == 4)
      #set ($r = $mid1)
      #set ($g = $m)
      #set ($b = $v)
    #else
      #set ($r = $v)
      #set ($g = $m)
      #set ($b = $mid2)
    #end
  #end
  #set ($r = $mathtool.toInteger($mathtool.mul($r, 255)))
  #set ($g = $mathtool.toInteger($mathtool.mul($g, 255)))
  #set ($b = $mathtool.toInteger($mathtool.mul($b, 255)))
  #set ($r = $r.toHexString($r))
  #if ($r.length() == 1)
    #set ($r = "0$r")
  #end
  #set ($g = $g.toHexString($g))
  #if ($g.length() == 1)
    #set ($g = "0$g")
  #end
  #set ($b = $b.toHexString($b))
  #if ($b.length() == 1)
    #set ($b = "0$b")
  #end
  ${escapetool.h}$r$g$b##
#end
#set ($xlines = $mathtool.toInteger($mathtool.div($mathtool.sub($chartConfiguration.upperAgeLimit, $chartConfiguration.lowerAgeLimit), $chartConfiguration.ageTickStep)))
#set ($ylines = $mathtool.toInteger($mathtool.div($mathtool.sub($chartConfiguration.upperValueLimit, $chartConfiguration.lowerValueLimit), $chartConfiguration.valueTickStep)))
#set ($graphWidth = 828)
#set ($graphHeight = 1080)
#set ($chartWidth = $mathtool.add($graphWidth, 125))
#set ($chartHeight = $mathtool.add($graphHeight, 146))
#set ($xstep = $mathtool.div($graphWidth, $xlines))
#set ($ystep = $mathtool.div($graphHeight, $ylines))
#set ($yscale = $mathtool.div($ystep, $chartConfiguration.valueTickStep))<commit_msg>[misc] Prevent variable leaks<commit_after><?xml version="1.0" encoding="UTF-8"?>

<!--
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->

<xwikidoc>
  <web>PhenoTips</web>
  <name>ChartGenerator</name>
  <language/>
  <defaultLanguage/>
  <translation>0</translation>
  <parent>PhenoTips.ChartService</parent>
  <creator>xwiki:XWiki.Admin</creator>
  <author>xwiki:XWiki.Admin</author>
  <customClass/>
  <contentAuthor>xwiki:XWiki.Admin</contentAuthor>
  <creationDate>1332741005000</creationDate>
  <date>1332773099000</date>
  <contentUpdateDate>1332773099000</contentUpdateDate>
  <version>1.1</version>
  <title/>
  <template/>
  <defaultTemplate/>
  <validationScript/>
  <comment/>
  <minorEdit>false</minorEdit>
  <syntaxId>xwiki/2.1</syntaxId>
  <hidden>false</hidden>
  <content>#macro (getPercentileValue $age $p)
  #set ($v = $services.measurements.get($chartConfiguration.measurementType).percentileToValue($sex, $age, $p))
#end
#macro (getSDValue $age $d)
  #set ($v = $services.measurements.get($chartConfiguration.measurementType).standardDeviationToValue($sex, $age, $d))
#end
#macro (getValuePercentile $age $v)
  #set ($p = $services.measurements.get($chartConfiguration.measurementType).valueToPercentile($sex, $age, $v))
#end
#macro (getValueSD $age $v)
  #set ($d = $services.measurements.get($chartConfiguration.measurementType).valueToStandardDeviation($sex, $age, $v))
#end
#macro (getPercentileColor $p)
  #set ($macro.h = $mathtool.mul(110, $mathtool.pow($mathtool.div($mathtool.sub(50, $mathtool.abs($mathtool.sub($p, 50))), 50.0), 0.5)))
  #set ($macro.s = 1)
  #set ($macro.l = 0.5)
  #set ($macro.r = $macro.l)
  #set ($macro.g = $macro.l)
  #set ($macro.b = $macro.l)
  #if ($macro.l &lt;= 0.5)
    #set ($macro.v = ($macro.l * (1.0 + $macro.s)))
  #else
    #set ($macro.v = ($macro.l + $macro.s - $macro.l * $macro.s))
  #end
  #if ($macro.v &gt; 0)
    #set ($macro.m = $macro.l + $macro.l - $macro.v)
    #set ($macro.sv = ($macro.v - $macro.m) / $macro.v)
    #set ($macro.h = $macro.h / 60.0)
    #set ($macro.sextant = $mathtool.floor($macro.h))
    #set ($macro.fract = $macro.h - $macro.sextant)
    #set ($macro.vsf = $macro.v * $macro.sv * $macro.fract)
    #set ($macro.mid1 = $macro.m + $macro.vsf)
    #set ($macro.mid2 = $macro.v - $macro.vsf)
    #if ($macro.sextant == 0)
      #set ($macro.r = $macro.v)
      #set ($macro.g = $macro.mid1)
      #set ($macro.b = $macro.m)
    #elseif ($macro.sextant == 1)
      #set ($macro.r = $macro.mid2)
      #set ($macro.g = $macro.v)
      #set ($macro.b = $macro.m)
    #elseif ($macro.sextant == 2)
      #set ($macro.r = $macro.m)
      #set ($macro.g = $macro.v)
      #set ($macro.b = $macro.mid1)
    #elseif ($macro.sextant == 3)
      #set ($macro.r = $macro.m)
      #set ($macro.g = $macro.mid2)
      #set ($macro.b = $macro.v)
    #elseif ($macro.sextant == 4)
      #set ($macro.r = $macro.mid1)
      #set ($macro.g = $macro.m)
      #set ($macro.b = $macro.v)
    #else
      #set ($macro.r = $macro.v)
      #set ($macro.g = $macro.m)
      #set ($macro.b = $macro.mid2)
    #end
  #end
  #set ($macro.r = $mathtool.toInteger($mathtool.mul($macro.r, 255)))
  #set ($macro.g = $mathtool.toInteger($mathtool.mul($macro.g, 255)))
  #set ($macro.b = $mathtool.toInteger($mathtool.mul($macro.b, 255)))
  #set ($macro.r = $macro.r.toHexString($macro.r))
  #if ($macro.r.length() == 1)
    #set ($macro.r = "0$macro.r")
  #end
  #set ($macro.g = $macro.g.toHexString($macro.g))
  #if ($macro.g.length() == 1)
    #set ($macro.g = "0$macro.g")
  #end
  #set ($macro.b = $macro.b.toHexString($macro.b))
  #if ($macro.b.length() == 1)
    #set ($macro.b = "0$macro.b")
  #end
  ${escapetool.h}${macro.r}${macro.g}${macro.b}##
#end
#set ($xlines = $mathtool.toInteger($mathtool.div($mathtool.sub($chartConfiguration.upperAgeLimit, $chartConfiguration.lowerAgeLimit), $chartConfiguration.ageTickStep)))
#set ($ylines = $mathtool.toInteger($mathtool.div($mathtool.sub($chartConfiguration.upperValueLimit, $chartConfiguration.lowerValueLimit), $chartConfiguration.valueTickStep)))
#set ($graphWidth = 828)
#set ($graphHeight = 1080)
#set ($chartWidth = $mathtool.add($graphWidth, 125))
#set ($chartHeight = $mathtool.add($graphHeight, 146))
#set ($xstep = $mathtool.div($graphWidth, $xlines))
#set ($ystep = $mathtool.div($graphHeight, $ylines))
#set ($yscale = $mathtool.div($ystep, $chartConfiguration.valueTickStep))
{'fraction_non_alphanumeric': 0.189079054604727, 'fraction_numerical': 0.02526487367563162, 'mean_word_length': 3.845508390918065, 'pattern_counts': {'":': 0, '<': 83, '<?xml version=': 2, '>': 83, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5525485', 'n_tokens_mistral': 3945, 'n_tokens_neox': 3658, 'n_words': 870}