turtlestitch/libraries/bar-charts.xml

1 wiersz
19 KiB
XML

<blocks app="Snap! 7, https://snap.berkeley.edu" version="2"><block-definition s="bar chart of table %&apos;data&apos; grouped by field: %&apos;field&apos; from: %&apos;floor&apos; to: %&apos;ceiling&apos; interval: %&apos;interval&apos;" type="reporter" category="lists"><comment x="0" y="0" w="344.6666666666667" collapsed="false">Takes a table (typically from a CSV data set) as input and reports a summary of the table grouped by the field in the specified column number. The remaining three inputs are used only if the field values are numbers, in which case they can be grouped into buckets (e.g., decades, centuries, etc.). Those three inputs specify the smallest and largest values of interest and, most importantly, the width of a bucket (10 for decades, 100 for centuries). If the field isn&apos;t numeric, leave these three inputs empty or set them to zero. In that case, each string value of the field is its own bucket, and they appear sorted alphabetically.&#xD;&#xD;The block reports a new table with three columns. The first column contains the bucket name or smallest number. The second column contains a nonnegative integer that says how many records in the input table fall into this bucket. The third column is a subtable containing the actual records from the original table that fall into the bucket.&#xD;&#xD;If your buckets aren&apos;t of constant width, or you want to group by some function of more than one field, load the &quot;Frequency Distribution Analysis&quot; library instead. </comment><header></header><code></code><translations>ca:gràfica de la taula _ agrupada pel camp: _ des de: _ fins: _ interval: _&#xD;</translations><inputs><input type="%l"></input><input type="%n"></input><input type="%n"></input><input type="%n"></input><input type="%n"></input></inputs><script><block s="doDeclareVariables"><list><l>sorted</l></list></block><block s="doSetVar"><l>sorted</l><custom-block s="sort table %l on field %n in %s order"><custom-block s="group table %l by field %n by intervals of: %n"><block var="data"/><block var="field"/><block var="interval"/></custom-block><l>1</l><l>ascending</l></custom-block></block><block s="doIf"><block s="reportEquals"><block var="interval"/><l>0</l></block><script><block s="doReport"><block var="sorted"/></block></script></block><block s="doReport"><block s="reportMap"><block s="reifyReporter"><autolambda><block s="reportCONS"><block s="reportProduct"><block s="reportListItem"><l>1</l><l/></block><block var="interval"/></block><block s="reportCDR"><l/></block></block></autolambda><list></list></block><custom-block s="bar chart helper function to fill %l key: %repRing from: %n to: %n interval: %repRing with: %repRing"><block var="sorted"/><block s="reifyReporter"><autolambda><block s="reportListItem"><l>1</l><l/></block></autolambda><list></list></block><block s="reportMonadic"><l><option>ceiling</option></l><block s="reportQuotient"><block var="floor"/><block var="interval"/></block></block><block s="reportMonadic"><l><option>ceiling</option></l><block s="reportQuotient"><block var="ceiling"/><block var="interval"/></block></block><block s="reifyReporter"><autolambda><block s="reportSum"><l></l><l>1</l></block></autolambda><list></list></block><block s="reifyReporter"><autolambda><block s="reportNewList"><list><l></l><l>0</l><block s="reportNewList"><list></list></block></list></block></autolambda><list></list></block></custom-block></block></block></script></block-definition><block-definition s="bar chart helper function to fill %&apos;data&apos; key: %&apos;key&apos; from: %&apos;floor&apos; to: %&apos;ceiling&apos; interval: %&apos;interval&apos; with: %&apos;generator&apos;" type="reporter" category="lists"><comment x="0" y="0" w="103" collapsed="false">add missing entries to a sorted list. Used for histograms</comment><header></header><code></code><translations>pt:os itens de _ com a chave _ entre _ e _ com passo _ completados por _&#xD;ca:gràfica omplint _ amb clau: _ des de: _ fins: _ interval: _ amb _&#xD;</translations><inputs><input type="%l"></input><input type="%r