Playground and DEMO space

This is a playground and demo space for ConfiForms and ConfiDoc addons developed and supported by Vertuna LLC

Most pages provide a storage format for the demo, so you can use the free add-on from Atlassian Confluence Source Editor (or through the bundled in ConfiForms storage editor) to import this configuration into your Confluence and see it in action

To import examples from the storage format on Confluence Cloud please see this page

Please note, all the examples here are provided without any obligation and may or may not be incomplete or may have bugs, and we provide NO SUPPORT for these examples and demos.

This page demonstrates how to calculate totals, average and sums, and standard deviation (by use of ConfiForms REST API)




All rows

(ID of d)

d

1 one
2 two


Rows: 2

Total: 3

Average: 1.5

Standard deviation: 

Code for the demo is here: 

<ac:structured-macro ac:macro-id="c221d30d-8349-441f-8d7a-1f42c9a6112f" ac:name="confiform-entry-register" ac:schema-version="1">
  <ac:parameter ac:name="embedded">true</ac:parameter>
  <ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
  <ac:rich-text-body>
    <p>
      <br/>
    </p>
  </ac:rich-text-body>
</ac:structured-macro>
<ac:structured-macro ac:macro-id="bb37bde6-f2ce-4953-b852-33f215a4d5d7" ac:name="confiform" ac:schema-version="1">
  <ac:parameter ac:name="formName">f1</ac:parameter>
  <ac:parameter ac:name="allowReads">true</ac:parameter>
  <ac:parameter ac:name="export">true</ac:parameter>
  <ac:rich-text-body>
    <p>
      <br/>
    </p>
    <p>
      <ac:structured-macro ac:macro-id="c7d16d0d-29b9-4eea-8dfc-f83e3b80c7af" ac:name="confiform-field-definition" ac:schema-version="1">
        <ac:parameter ac:name="fieldName">d</ac:parameter>
        <ac:parameter ac:name="fieldLabel">d</ac:parameter>
        <ac:parameter ac:name="values">false[1=one|2=two|3=tre|4=four|]</ac:parameter>
        <ac:parameter ac:name="type">select</ac:parameter>
        <ac:parameter ac:name="required">true</ac:parameter>
      </ac:structured-macro>
    </p>
  </ac:rich-text-body>
</ac:structured-macro>
<p>
  <br/>
</p>
<p>All rows</p>
<ac:structured-macro ac:macro-id="114580e2-3c29-4bc2-a822-a491540201d8" ac:name="confiform-table" ac:schema-version="1">
  <ac:parameter ac:name="formName">f1</ac:parameter>
  <ac:rich-text-body>
    <p>
      <ac:structured-macro ac:macro-id="755e0e54-fef2-416e-9591-3852d18c9cfc" ac:name="confiform-field" ac:schema-version="1">
        <ac:parameter ac:name="overrideLabel">(ID of d)</ac:parameter>
        <ac:parameter ac:name="fieldName">d.id</ac:parameter>
      </ac:structured-macro>
    </p>
    <p>
      <ac:structured-macro ac:macro-id="a921da18-107a-42f8-a6fc-32311c625749" ac:name="confiform-field" ac:schema-version="1">
        <ac:parameter ac:name="fieldName">d</ac:parameter>
      </ac:structured-macro>
    </p>
  </ac:rich-text-body>
</ac:structured-macro>
<p>
  <br/>
</p>
<p>Rows: <ac:structured-macro ac:macro-id="d0323d13-c6d6-4bf9-93c2-8e25eb47e57a" ac:name="confiform-value" ac:schema-version="1">
    <ac:parameter ac:name="fieldName">Rows:([total])</ac:parameter>
    <ac:parameter ac:name="formName">f1</ac:parameter>
  </ac:structured-macro>
</p>
<p>Total: <ac:structured-macro ac:macro-id="e139194f-9ae6-4eea-bf09-d59acdb3eb69" ac:name="confiform-value" ac:schema-version="1">
    <ac:parameter ac:name="fieldName">Total:([entry.d])</ac:parameter>
    <ac:parameter ac:name="formName">f1</ac:parameter>
  </ac:structured-macro>
</p>
<p>Average: <ac:structured-macro ac:macro-id="e536712c-00cf-4da8-a66a-0bc49addbac0" ac:name="confiform-value" ac:schema-version="1">
    <ac:parameter ac:name="fieldName">Average:([entry.d]/[total])</ac:parameter>
    <ac:parameter ac:name="formName">f1</ac:parameter>
  </ac:structured-macro>
</p>
<ac:structured-macro ac:macro-id="0fb8923e-370d-46db-bfab-2f50d025f487" ac:name="html" ac:schema-version="1">
  <ac:plain-text-body><![CDATA[<p>Standard deviation: <span id="confiReport"></span></p>

<script type="application/javascript">
  function calculateStandardDeviation(array) {
   const n = array.length;
   const mean = array.reduce((a,b) => a+b)/n;
   return Math.sqrt(array.map(x => Math.pow(x-mean,2)).reduce((a,b) => a+b)/n);
  }

  AJS.toInit(function() {
	var isPageEdit = AJS.$('#content').hasClass('page edit');	

    if (!isPageEdit) {
      var url = 'https://wiki.vertuna.com/ajax/confiforms/rest/filter.action?pageId=52625840&f=f1&q=';
	  var xhr = AJS.$.ajax({
  		url: url,
  		timeout: 10000, // 10 sec
  		success: function (data) {
            var arr = [];
            var rows = data.list.entry;
			for (i=0;i<rows.length;i++) {
				arr[i] = rows[i].fields.d;
            }
            AJS.$('#confiReport').append(calculateStandardDeviation(arr));
    		
  		},
  		error: function (jqXHR, textStatus, errorThrown) {
    		console.log('request to get data from ConfiForms has failed... ' + textStatus);
  		}
	});
   }

  });
</script>

]]></ac:plain-text-body>
</ac:structured-macro>
  • No labels