Difference between revisions of "FixedCrossTable class"

From Catglobe Wiki
Jump to: navigation, search
 
(14 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
{{CGscriptClass_Template
 
{{CGscriptClass_Template
|Name=FixedCrossTable
+
|Name=<nowiki>FixedCrossTable</nowiki>
|Description=A resource journal entry
+
|Description=<nowiki>A manual created cross table diagram</nowiki>
|Constructors=
+
|InheritsFrom=object|Constructors=
 
{{CGscriptConstructors_Template|Parameters=
 
{{CGscriptConstructors_Template|Parameters=
{{CGscriptParameters_Template|Type=string|Name=rowTitle|Description=Title of row.|Comma=,}}{{CGscriptParameters_Template|Type=array|Name=primaryRowAxis|Description=Axis from Axis_xxx function for the primary row axis.|Comma=,}}{{CGscriptParameters_Template|Type=FixedCrossTableRowSeries|Name=rowSeries|Description=Data for the table.|Comma=,}}{{CGscriptParameters_Template|Type=array|Name=statisticsValues|Description=Array of StatisticsItems.}}
+
{{CGscriptParameters_Template|Type=string|Name=<nowiki>rowTitle</nowiki>|Description=<nowiki>Title of row.</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=Axis|Name=<nowiki>primaryRowAxis</nowiki>|Description=<nowiki>Axis from Axis_xxx function for the primary row axis.</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=FixedCrossTableRowSeries|Name=<nowiki>rowSeries</nowiki>|Description=<nowiki>Data for the table.</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=array|Name=<nowiki>extraRows</nowiki>|Description=<nowiki>Extra data for the table.</nowiki>}}
|Description=Create new 1x0 FixedCrossTable.}}
+
|Description=<nowiki>Create new 1x0 FixedCrossTable.</nowiki>}}
 
{{CGscriptConstructors_Template|Parameters=
 
{{CGscriptConstructors_Template|Parameters=
{{CGscriptParameters_Template|Type=string|Name=rowTitle|Description=Title of row.|Comma=,}}{{CGscriptParameters_Template|Type=array|Name=primaryRowAxis|Description=Axis from Axis_xxx function for the primary row axis.|Comma=,}}{{CGscriptParameters_Template|Type=array|Name=secondaryRowAxis|Description=Axis from Axis_xxx function for the secondary row axis.|Comma=,}}{{CGscriptParameters_Template|Type=array|Name=rowSeries|Description=Data for the table.|Comma=,}}{{CGscriptParameters_Template|Type=array|Name=statisticsValues|Description=Array of StatisticsItems.}}
+
{{CGscriptParameters_Template|Type=string|Name=<nowiki>rowTitle</nowiki>|Description=<nowiki>Title of row.</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=Axis|Name=<nowiki>primaryRowAxis</nowiki>|Description=<nowiki>Axis from Axis_xxx function for the primary row axis.</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=Axis|Name=<nowiki>secondaryRowAxis</nowiki>|Description=<nowiki>Axis from Axis_xxx function for the secondary row axis.</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=array|Name=<nowiki>rowSeries</nowiki>|Description=<nowiki>Data for the table.</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=array|Name=<nowiki>extraRows</nowiki>|Description=<nowiki>Extra data for the table.</nowiki>}}
|Description=Create new 2x0 FixedCrossTable.}}
+
|Description=<nowiki>Create new 2x0 FixedCrossTable.</nowiki>}}
 
{{CGscriptConstructors_Template|Parameters=
 
{{CGscriptConstructors_Template|Parameters=
{{CGscriptParameters_Template|Type=string|Name=rowTitle|Description=Title of row.|Comma=,}}{{CGscriptParameters_Template|Type=array|Name=primaryRowAxis|Description=Axis from Axis_xxx function for the primary row axis.|Comma=,}}{{CGscriptParameters_Template|Type=string|Name=colTitle|Description=Title of column.|Comma=,}}{{CGscriptParameters_Template|Type=array|Name=primaryColAxis|Description=Axis from Axis_xxx function for the primary column axis.|Comma=,}}{{CGscriptParameters_Template|Type=array|Name=rowSeries|Description=Data for the table.|Comma=,}}{{CGscriptParameters_Template|Type=array|Name=statisticsValues|Description=Array of StatisticsItems.}}
+
{{CGscriptParameters_Template|Type=string|Name=<nowiki>rowTitle</nowiki>|Description=<nowiki>Title of row.</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=Axis|Name=<nowiki>primaryRowAxis</nowiki>|Description=<nowiki>Axis from Axis_xxx function for the primary row axis.</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=string|Name=<nowiki>colTitle</nowiki>|Description=<nowiki>Title of column.</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=Axis|Name=<nowiki>primaryColAxis</nowiki>|Description=<nowiki>Axis from Axis_xxx function for the primary column axis.</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=array|Name=<nowiki>rowSeries</nowiki>|Description=<nowiki>Data for the table.</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=array|Name=<nowiki>extraRows</nowiki>|Description=<nowiki>Extra data for the table.</nowiki>}}
|Description=Create new 1x1 FixedCrossTable.}}
+
|Description=<nowiki>Create new 1x1 FixedCrossTable.</nowiki>}}
 
{{CGscriptConstructors_Template|Parameters=
 
{{CGscriptConstructors_Template|Parameters=
{{CGscriptParameters_Template|Type=string|Name=rowTitle|Description=Title of row.|Comma=,}}{{CGscriptParameters_Template|Type=array|Name=primaryRowAxis|Description=Axis from Axis_xxx function for the primary row axis.|Comma=,}}{{CGscriptParameters_Template|Type=string|Name=colTitle|Description=Title of column.|Comma=,}}{{CGscriptParameters_Template|Type=array|Name=primaryColAxis|Description=Axis from Axis_xxx function for the primary column axis.|Comma=,}}{{CGscriptParameters_Template|Type=array|Name=secondaryColAxis|Description=Axis from Axis_xxx function for the secondary column axis.|Comma=,}}{{CGscriptParameters_Template|Type=FixedCrossTableRowSeries|Name=rowSeries|Description=Data for the table.|Comma=,}}{{CGscriptParameters_Template|Type=array|Name=statisticsValues|Description=Array of StatisticsItems.}}
+
{{CGscriptParameters_Template|Type=string|Name=<nowiki>rowTitle</nowiki>|Description=<nowiki>Title of row.</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=Axis|Name=<nowiki>primaryRowAxis</nowiki>|Description=<nowiki>Axis from Axis_xxx function for the primary row axis.</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=string|Name=<nowiki>colTitle</nowiki>|Description=<nowiki>Title of column.</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=Axis|Name=<nowiki>primaryColAxis</nowiki>|Description=<nowiki>Axis from Axis_xxx function for the primary column axis.</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=Axis|Name=<nowiki>secondaryColAxis</nowiki>|Description=<nowiki>Axis from Axis_xxx function for the secondary column axis.</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=FixedCrossTableRowSeries|Name=<nowiki>rowSeries</nowiki>|Description=<nowiki>Data for the table.</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=array|Name=<nowiki>extraRows</nowiki>|Description=<nowiki>Extra data for the table.</nowiki>}}
|Description=Create new 1x2 FixedCrossTable.}}
+
|Description=<nowiki>Create new 1x2 FixedCrossTable.</nowiki>}}
 
{{CGscriptConstructors_Template|Parameters=
 
{{CGscriptConstructors_Template|Parameters=
{{CGscriptParameters_Template|Type=string|Name=rowTitle|Description=Title of row.|Comma=,}}{{CGscriptParameters_Template|Type=array|Name=primaryRowAxis|Description=Axis from Axis_xxx function for the primary row axis.|Comma=,}}{{CGscriptParameters_Template|Type=array|Name=secondaryRowAxis|Description=Axis from Axis_xxx function for the secondary row axis.|Comma=,}}{{CGscriptParameters_Template|Type=string|Name=colTitle|Description=Title of column.|Comma=,}}{{CGscriptParameters_Template|Type=array|Name=primaryColAxis|Description=Axis from Axis_xxx function for the primary column axis.|Comma=,}}{{CGscriptParameters_Template|Type=array|Name=rowSeries|Description=Data for the table.|Comma=,}}{{CGscriptParameters_Template|Type=array|Name=statisticsValues|Description=Array of StatisticsItems.}}
+
{{CGscriptParameters_Template|Type=string|Name=<nowiki>rowTitle</nowiki>|Description=<nowiki>Title of row.</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=Axis|Name=<nowiki>primaryRowAxis</nowiki>|Description=<nowiki>Axis from Axis_xxx function for the primary row axis.</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=Axis|Name=<nowiki>secondaryRowAxis</nowiki>|Description=<nowiki>Axis from Axis_xxx function for the secondary row axis.</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=string|Name=<nowiki>colTitle</nowiki>|Description=<nowiki>Title of column.</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=Axis|Name=<nowiki>primaryColAxis</nowiki>|Description=<nowiki>Axis from Axis_xxx function for the primary column axis.</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=array|Name=<nowiki>rowSeries</nowiki>|Description=<nowiki>Data for the table.</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=array|Name=<nowiki>extraRows</nowiki>|Description=<nowiki>Extra data for the table.</nowiki>}}
|Description=Create new 2x1 FixedCrossTable.}}
+
|Description=<nowiki>Create new 2x1 FixedCrossTable.</nowiki>}}
 
{{CGscriptConstructors_Template|Parameters=
 
{{CGscriptConstructors_Template|Parameters=
{{CGscriptParameters_Template|Type=string|Name=rowTitle|Description=Title of row.|Comma=,}}{{CGscriptParameters_Template|Type=array|Name=primaryRowAxis|Description=Axis from Axis_xxx function for the primary row axis.|Comma=,}}{{CGscriptParameters_Template|Type=array|Name=secondaryRowAxis|Description=Axis from Axis_xxx function for the secondary row axis.|Comma=,}}{{CGscriptParameters_Template|Type=string|Name=colTitle|Description=Title of column.|Comma=,}}{{CGscriptParameters_Template|Type=array|Name=primaryColAxis|Description=Axis from Axis_xxx function for the primary column axis.|Comma=,}}{{CGscriptParameters_Template|Type=array|Name=secondaryColAxis|Description=Axis from Axis_xxx function for the secondary column axis.|Comma=,}}{{CGscriptParameters_Template|Type=array|Name=rowSeries|Description=Data for the table.|Comma=,}}{{CGscriptParameters_Template|Type=array|Name=statisticsValues|Description=Array of StatisticsItems.}}
+
{{CGscriptParameters_Template|Type=string|Name=<nowiki>rowTitle</nowiki>|Description=<nowiki>Title of row.</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=Axis|Name=<nowiki>primaryRowAxis</nowiki>|Description=<nowiki>Axis from Axis_xxx function for the primary row axis.</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=Axis|Name=<nowiki>secondaryRowAxis</nowiki>|Description=<nowiki>Axis from Axis_xxx function for the secondary row axis.</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=string|Name=<nowiki>colTitle</nowiki>|Description=<nowiki>Title of column.</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=Axis|Name=<nowiki>primaryColAxis</nowiki>|Description=<nowiki>Axis from Axis_xxx function for the primary column axis.</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=Axis|Name=<nowiki>secondaryColAxis</nowiki>|Description=<nowiki>Axis from Axis_xxx function for the secondary column axis.</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=array|Name=<nowiki>rowSeries</nowiki>|Description=<nowiki>Data for the table.</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=array|Name=<nowiki>extraRows</nowiki>|Description=<nowiki>Extra data for the table.</nowiki>}}
|Description=Create new 2x2 FixedCrossTable.}}
+
|Description=<nowiki>Create new 2x2 FixedCrossTable.</nowiki>}}
 
|Methods=
 
|Methods=
{{CGscriptMethods_Template|ReturnType=string|Name=ToString|Description=The string representation of the object.}}
+
{{CGscriptMethods_Template|ReturnType=string|Name=<nowiki>ToString</nowiki>|Inherited=object|Description=<nowiki>The string representation of the object.</nowiki>}}
 
|Properties=
 
|Properties=
{{CGscriptProperties_Template|ReturnType=string|Name=ObjectTypeName|HasGetter=1|Description=The name of the type of object.}}
+
{{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>ObjectTypeName</nowiki>|HasGetter=1|Description=<nowiki>The name of the type of object.</nowiki>}}
{{CGscriptProperties_Template|ReturnType=TypeInformation|Name=TypeInformation|HasGetter=1|Description=Get information about this class.}}
+
{{CGscriptProperties_Template|ReturnType=TypeInformation|Name=<nowiki>TypeInformation</nowiki>|HasGetter=1|Inherited=object|Description=<nowiki>Get information about this class.</nowiki>}}
 
}}
 
}}
  
Line 31: Line 31:
  
 
<source lang="javascript">
 
<source lang="javascript">
DCS_use(12344983);
+
DCS_use(15521068);
 
+
 
// Get Axis:
 
// Get Axis:
 
array axisNew = Axis_new("LuuTest");
 
array axisNew = Axis_new("LuuTest");
 
axisNew[AXIS_TEXT] = "Choose a D_Week";
 
axisNew[AXIS_TEXT] = "Choose a D_Week";
 
+
 
// Init:
 
// Init:
 
FixedCrossTableRowSeries rowseries;
 
FixedCrossTableRowSeries rowseries;
Line 47: Line 47:
 
dataserie = new FixedCrossTableDataSeries();
 
dataserie = new FixedCrossTableDataSeries();
 
number count;
 
number count;
number countTotal = count() where D_Week != empty;
+
number countTotal = count() where D_YearWeek != empty;
 
+
 
for(number i = 201301; i < 201305; i++)
 
for(number i = 201301; i < 201305; i++)
 
{
 
{
 
  Axis_addOption(axisNew, AxisOption_new("Week " + i.ToString(), ""));
 
  Axis_addOption(axisNew, AxisOption_new("Week " + i.ToString(), ""));
 
   
 
   
  count = count() where D_Week == i;
+
  count = count() where D_YearWeek == i;
 
  dataItemAbs = new FixedCrossTableDataItem();
 
  dataItemAbs = new FixedCrossTableDataItem();
 
  dataItemAbs.Value = count;
 
  dataItemAbs.Value = count;
Line 62: Line 62:
 
// other
 
// other
 
Axis_addOption(axisNew, AxisOption_new("Week Other", ""));
 
Axis_addOption(axisNew, AxisOption_new("Week Other", ""));
count = count() where D_Week != [201301-201304] && D_Week != empty;
+
count = count() where D_YearWeek != [201301-201304] && D_YearWeek != empty;
 +
 +
dataItemAbs = new FixedCrossTableDataItem();
 +
dataItemAbs.Value = count;
 +
dataItemPct = new FixedCrossTableDataItem();
 +
dataItemPct.Value = count*100/countTotal;
 +
dataserie.Add(dataItemAbs,dataItemPct);
 +
// add statistics Values
 +
dataserie.AddStat(dataItemAbs);
 +
dataserie.AddStat(dataItemAbs);
 +
 +
dataserie.AbsoluteTotal.Value = countTotal;
 +
dataserie.PercentageTotal.Value = countTotal*100/countTotal;
 +
 +
rowseries.Add(dataserie);
 +
FixedCrossTable table1x0 = new FixedCrossTable("Create by createFixedCrossDiagram - D_Week", axisNew , rowseries, {});
 +
setMedian(true);
 +
addPercentile(20);
 +
// genarate table:
 +
createFixedCrossDiagram(table1x0);
 +
</source> Result:<br/>[[File:Update1x0.png]]
  
 +
=== Examples For Table 1x1 ===
 +
 +
<source lang="javascript">
 +
DCS_use(15517112);
 +
 +
// Get Axis:
 +
array axisPrimary = Axis_new("LuuTest1");
 +
axisPrimary[AXIS_TEXT] = "Choose a D_Week";
 +
 +
array axisSecond = Axis_new("LuuTest2");
 +
axisSecond[AXIS_TEXT] = "Choose a Region";
 +
 +
Axis_addOption(axisPrimary, AxisOption_new("Year 2014", ""));
 +
Axis_addOption(axisPrimary, AxisOption_new("Other Year", ""));
 +
 +
Axis_addOption(axisSecond, AxisOption_new("Male", ""));
 +
Axis_addOption(axisSecond, AxisOption_new("Female", ""));
 +
// Init:
 +
array arrRowseries ={};
 +
number countTotal = count() where true;
 +
number count;
 +
FixedCrossTableRowSeries rowseries;
 +
FixedCrossTableDataItem dataItemAbs;
 +
FixedCrossTableDataItem dataItemPct;
 +
FixedCrossTableDataSeries dataserie;
 +
 +
dataserie = new FixedCrossTableDataSeries();
 +
count = count() where D_Week == [201401-201453] && Gender == [1];
 
dataItemAbs = new FixedCrossTableDataItem();
 
dataItemAbs = new FixedCrossTableDataItem();
 
dataItemAbs.Value = count;
 
dataItemAbs.Value = count;
Line 70: Line 118:
 
dataserie.Add(dataItemAbs,dataItemPct);
 
dataserie.Add(dataItemAbs,dataItemPct);
  
dataserie.AbsoluteTotal.Value = countTotal;
+
count = count() where D_Week == [201401-201453] && Gender == [2];
dataserie.PercentageTotal.Value = countTotal*100/countTotal;
+
dataItemAbs = new FixedCrossTableDataItem();
 +
dataItemAbs.Value = count;
 +
dataItemPct = new FixedCrossTableDataItem();
 +
dataItemPct.Value = count*100/countTotal;
 +
dataserie.Add(dataItemAbs,dataItemPct);
 +
 
 +
count = count() where D_Week == [201401-201453];
 +
dataserie.AbsoluteTotal.Value = count;
 +
dataserie.PercentageTotal.Value = count/count * 100;
 +
rowseries.Add(dataserie);
 +
arrRowseries = {rowseries,rowseries,rowseries};
 +
// Set up a table
 +
// table 2x0
 +
 
 +
 
 +
FixedCrossTable table1x1 = new FixedCrossTable("Create by createFixedCrossDiagram ", axisPrimary,"Col title", axisSecond, arrRowseries, {});
 +
// genarate table:
 +
createFixedCrossDiagram(table1x1);
 +
</source> Result:<br/>[[File:Tabu Table1x1.png]]
 +
 
 +
=== Examples For Table 2x1 ===
 +
 
 +
<source lang="javascript">
 +
 
 +
DCS_use(15517112);
 +
 
 +
// Get Axis:
 +
array axisRowPrimary = Axis_new("LuuTest1");
 +
axisRowPrimary[AXIS_TEXT] = "Gender test";
 +
Axis_addOption(axisRowPrimary, AxisOption_new("Mand", ""));
 +
Axis_addOption(axisRowPrimary, AxisOption_new("Kvinde", ""));
 +
array axisRowSecond = Axis_new("LuuTest2");
 +
axisRowSecond[AXIS_TEXT] = "Region test";
 +
Axis_addOption(axisRowSecond, AxisOption_new("Region Hovedstaden", ""));
 +
Axis_addOption(axisRowSecond, AxisOption_new("Other Region", ""));
 +
 
 +
array axisColPrimary = Axis_new("LuuTest3");
 +
axisColPrimary[AXIS_TEXT] = "Week test";
 +
Axis_addOption(axisColPrimary, AxisOption_new("Year 2014", ""));
 +
Axis_addOption(axisColPrimary, AxisOption_new("Year Other", ""));
 +
 
 +
 
 +
array arrRowseries ={};
 +
number count;
 +
FixedCrossTableRowSeries rowseries;
 +
FixedCrossTableDataItem dataItemAbs;
 +
FixedCrossTableDataSeries dataserie;
 +
 
 +
dataserie = new FixedCrossTableDataSeries();
 +
 
 +
dataItemAbs = new FixedCrossTableDataItem();
 +
dataItemAbs.Value = 1;
 +
dataserie.Add(dataItemAbs,dataItemAbs);
 +
dataserie.Add(dataItemAbs,dataItemAbs);
 +
dataserie.AbsoluteTotal.Value = 1;
 +
dataserie.PercentageTotal.Value = 1;
  
 
rowseries.Add(dataserie);
 
rowseries.Add(dataserie);
FixedCrossTable table1x0 = new FixedCrossTable("Create by createFixedCrossDiagram - D_Week", axisNew , rowseries, empty);
+
rowseries.Add(dataserie);
 +
 
 +
arrRowseries = {rowseries,rowseries,rowseries};
 +
 
 +
FixedCrossTable table2x1 = new FixedCrossTable("Create by createFixedCrossDiagram ", axisRowPrimary, axisRowSecond,"Column title", axisColPrimary, arrRowseries, {});
 
// genarate table:
 
// genarate table:
 +
createFixedCrossDiagram(table2x1);
 +
createCrossDiagram({"Gender","Region"},{"D_Week"});
 +
</source> Result:<br/>[[File:Table2x1.png]]
 +
 +
 +
 +
=== Examples For Table 2x2 ===
 +
 +
<source lang="javascript">
 +
DCS_use(15521068);
 +
 +
Tabulation_setSignificance(true);
 +
Tabulation_setWeightDescriptionVisibility(true);
 +
 +
// Get Axis:
 +
array axisRowPrimary = Axis_new("LuuTest1");
 +
axisRowPrimary[AXIS_TEXT] = "Gender test";
 +
Axis_addOption(axisRowPrimary, AxisOption_new("Mand", ""));
 +
Axis_addOption(axisRowPrimary, AxisOption_new("Kvinde", ""));
 +
array axisRowSecond = Axis_new("LuuTest2");
 +
axisRowSecond[AXIS_TEXT] = "Region test";
 +
Axis_addOption(axisRowSecond, AxisOption_new("Region Hovedstaden", ""));
 +
Axis_addOption(axisRowSecond, AxisOption_new("Other Region", ""));
 +
 +
array axisColPrimary = Axis_new("LuuTest3");
 +
axisColPrimary[AXIS_TEXT] = "Week test";
 +
Axis_addOption(axisColPrimary, AxisOption_new("Year 2014", ""));
 +
Axis_addOption(axisColPrimary, AxisOption_new("Year Other", ""));
 +
 +
array axisColSecond = Axis_new("LuuTest4");
 +
axisColSecond[AXIS_TEXT] = "Age Group test";
 +
Axis_addOption(axisColSecond, AxisOption_new("Year 2014", ""));
 +
Axis_addOption(axisColSecond, AxisOption_new("Year Other", ""));
 +
 +
array arrRowseries ={};
 +
number count;
 +
FixedCrossTableRowSeries rowseries;
 +
FixedCrossTableDataItem dataItemAbs;
 +
FixedCrossTableDataItem dataItemSta;
 +
FixedCrossTableDataSeries dataserie;
 +
FixedCrossTableExtraRow er = new FixedCrossTableExtraRow("header", "content");
 +
 +
dataserie = new FixedCrossTableDataSeries();
 +
 +
dataItemAbs = new FixedCrossTableDataItem();
 +
dataItemAbs.Value = 1;
 +
dataItemSta = new FixedCrossTableDataItem();
 +
dataItemSta.Value = 2;
 +
dataserie.Add(dataItemAbs,dataItemAbs);
 +
dataserie.Add(dataItemAbs,dataItemAbs);
 +
dataserie.AddStat(dataItemSta); // for Average
 +
dataserie.AddStat(dataItemSta); // for Median
 +
dataserie.AddStat(dataItemSta); // Variance
 +
dataserie.AddStat(dataItemSta); // for Percentile 20
 +
dataserie.AddStat(dataItemSta); // for Percentile 50
 +
dataserie.AbsoluteTotal.Value = 1;
 +
dataserie.PercentageTotal.Value = 1;
 +
 +
rowseries.Add(dataserie);
 +
rowseries.Add(dataserie);
 +
 +
arrRowseries = {rowseries,rowseries,rowseries,rowseries,rowseries,rowseries};
 +
setAverage(true);
 +
setMedian(true);
 +
setVariance(true);
 +
addPercentile(20);
 +
addPercentile(50);
 +
FixedCrossTable table2x2 = new FixedCrossTable("Create by createFixedCrossDiagram ", axisRowPrimary, axisRowSecond,"Column title", axisColPrimary, axisColSecond, arrRowseries, {er});
 +
 +
// genarate table:
 +
createFixedCrossDiagram(table2x2);
 +
//createCrossDiagram({"D_Gender","D_Region"},{"D_YearWeek"});
 +
</source> Result:<br/>[[File:Update2x2.png]]
 +
<span style="color:#DF8621"> Create table 1x0 using Axis and AxisOption class </span>
 +
<source lang="javascript">
 +
DataCacheSpecification dcs = new DataCacheSpecification (15636575);
 +
//rowTitle
 +
string rowTitle = "Gender";
 +
//primaryRowAxis
 +
Axis primaryRowAxis = new Axis(dcs, "Gender", "this is Gender");
 +
primaryRowAxis.AddOption(new AxisOption (dcs, "Male", "Gender == [1]") );
 +
primaryRowAxis.AddOption(new AxisOption (dcs, "Female", "Gender == [2]") );
 +
//rowSeries
 +
Dictionary expression =
 +
{
 +
"Male": "count() where Gender == [1];",
 +
"Female": "count() where Gender == [2];",
 +
"Total": "count () where true;"
 +
 +
};
 +
Dictionary Count = dcs.EvalWhere(expression);
 +
 +
FixedCrossTableRowSeries rowSeries = new FixedCrossTableRowSeries ();
 +
FixedCrossTableDataSeries series = new FixedCrossTableDataSeries ();
 +
 +
FixedCrossTableDataItem absolute1 = new FixedCrossTableDataItem ();
 +
FixedCrossTableDataItem percentage1 = new FixedCrossTableDataItem ();
 +
absolute1.Value = Count["Male"];
 +
percentage1.Value = Count["Male"]*100/Count["Total"];
 +
series.Add(absolute1 , percentage1 );
 +
 +
FixedCrossTableDataItem absolute2 = new FixedCrossTableDataItem ();
 +
FixedCrossTableDataItem percentage2 = new FixedCrossTableDataItem ();
 +
absolute2.Value = Count["Female"];
 +
percentage2.Value = Count["Female"]*100/Count["Total"];
 +
series.Add(absolute2 , percentage2 );
 +
 +
 +
series.AbsoluteTotal.Value = Count["Total"];
 +
series.PercentageTotal.Value = Count["Total"]/Count["Total"]* 100;
 +
 +
FixedCrossTableDataItem stat = new FixedCrossTableDataItem ();
 +
stat.Value = 5;
 +
series.AddStat(stat );
 +
 +
rowSeries.Add(series);
 +
//extraRows
 +
FixedCrossTableExtraRow er1 = new FixedCrossTableExtraRow("header1", "content1");
 +
FixedCrossTableExtraRow er2 = new FixedCrossTableExtraRow("header2", "content2");
 +
array extraRows = {er1, er2};
 +
//table1x0
 +
FixedCrossTable table1x0 = new FixedCrossTable (rowTitle, primaryRowAxis, rowSeries, extraRows);
 +
setAverage(true);
 +
 +
DCS_use(15636575);
 
createFixedCrossDiagram(table1x0);
 
createFixedCrossDiagram(table1x0);
</source> Result:<br/>[[File:Tabu Table1x0.png]]
+
</source>
 +
[[File:2018-07-26_15-41-59.png]]

Latest revision as of 07:55, 2 July 2020

FixedCrossTable



A manual created cross table diagram

Parent class

Inherits from object

Constructors

  • (string rowTitle "Title of row.", Axis primaryRowAxis "Axis from Axis_xxx function for the primary row axis.", FixedCrossTableRowSeries rowSeries "Data for the table.", array extraRows "Extra data for the table.") - Create new 1x0 FixedCrossTable.
  • (string rowTitle "Title of row.", Axis primaryRowAxis "Axis from Axis_xxx function for the primary row axis.", Axis secondaryRowAxis "Axis from Axis_xxx function for the secondary row axis.", array rowSeries "Data for the table.", array extraRows "Extra data for the table.") - Create new 2x0 FixedCrossTable.
  • (string rowTitle "Title of row.", Axis primaryRowAxis "Axis from Axis_xxx function for the primary row axis.", string colTitle "Title of column.", Axis primaryColAxis "Axis from Axis_xxx function for the primary column axis.", array rowSeries "Data for the table.", array extraRows "Extra data for the table.") - Create new 1x1 FixedCrossTable.
  • (string rowTitle "Title of row.", Axis primaryRowAxis "Axis from Axis_xxx function for the primary row axis.", string colTitle "Title of column.", Axis primaryColAxis "Axis from Axis_xxx function for the primary column axis.", Axis secondaryColAxis "Axis from Axis_xxx function for the secondary column axis.", FixedCrossTableRowSeries rowSeries "Data for the table.", array extraRows "Extra data for the table.") - Create new 1x2 FixedCrossTable.
  • (string rowTitle "Title of row.", Axis primaryRowAxis "Axis from Axis_xxx function for the primary row axis.", Axis secondaryRowAxis "Axis from Axis_xxx function for the secondary row axis.", string colTitle "Title of column.", Axis primaryColAxis "Axis from Axis_xxx function for the primary column axis.", array rowSeries "Data for the table.", array extraRows "Extra data for the table.") - Create new 2x1 FixedCrossTable.
  • (string rowTitle "Title of row.", Axis primaryRowAxis "Axis from Axis_xxx function for the primary row axis.", Axis secondaryRowAxis "Axis from Axis_xxx function for the secondary row axis.", string colTitle "Title of column.", Axis primaryColAxis "Axis from Axis_xxx function for the primary column axis.", Axis secondaryColAxis "Axis from Axis_xxx function for the secondary column axis.", array rowSeries "Data for the table.", array extraRows "Extra data for the table.") - Create new 2x2 FixedCrossTable.

Methods

  • (From object) string ToString() - The string representation of the object.

Properties

  • string ObjectTypeName { get; } - The name of the type of object.
  • (From object) TypeInformation TypeInformation { get; } - Get information about this class.


Examples For Table 1x0

DCS_use(15521068);
 
// Get Axis:
array axisNew = Axis_new("LuuTest");
axisNew[AXIS_TEXT] = "Choose a D_Week";
 
// Init:
FixedCrossTableRowSeries rowseries;
FixedCrossTableDataSeries dataserie;
FixedCrossTableDataItem dataItemAbs;
FixedCrossTableDataItem dataItemPct;
// Set up a table
// table 1x0
rowseries = new FixedCrossTableRowSeries();
dataserie = new FixedCrossTableDataSeries();
number count;
number countTotal = count() where D_YearWeek != empty;
 
for(number i = 201301; i < 201305; i++)
{
 Axis_addOption(axisNew, AxisOption_new("Week " + i.ToString(), ""));
 
 count = count() where D_YearWeek == i;
 dataItemAbs = new FixedCrossTableDataItem();
 dataItemAbs.Value = count;
 dataItemPct = new FixedCrossTableDataItem();
 dataItemPct.Value = count*100/countTotal;
 dataserie.Add(dataItemAbs,dataItemPct);
}
// other
Axis_addOption(axisNew, AxisOption_new("Week Other", ""));
count = count() where D_YearWeek != [201301-201304] && D_YearWeek != empty;
 
dataItemAbs = new FixedCrossTableDataItem();
dataItemAbs.Value = count;
dataItemPct = new FixedCrossTableDataItem();
dataItemPct.Value = count*100/countTotal;
dataserie.Add(dataItemAbs,dataItemPct);
// add statistics Values 
dataserie.AddStat(dataItemAbs);
dataserie.AddStat(dataItemAbs);
 
dataserie.AbsoluteTotal.Value = countTotal;
dataserie.PercentageTotal.Value = countTotal*100/countTotal;
 
rowseries.Add(dataserie);
FixedCrossTable table1x0 = new FixedCrossTable("Create by createFixedCrossDiagram - D_Week", axisNew , rowseries, {});
setMedian(true);
addPercentile(20);
// genarate table:
createFixedCrossDiagram(table1x0);

Result:
Update1x0.png

Examples For Table 1x1

DCS_use(15517112);

// Get Axis:
array axisPrimary = Axis_new("LuuTest1");
axisPrimary[AXIS_TEXT] = "Choose a D_Week";

array axisSecond = Axis_new("LuuTest2");
axisSecond[AXIS_TEXT] = "Choose a Region";

Axis_addOption(axisPrimary, AxisOption_new("Year 2014", ""));
Axis_addOption(axisPrimary, AxisOption_new("Other Year", ""));

Axis_addOption(axisSecond, AxisOption_new("Male", ""));
Axis_addOption(axisSecond, AxisOption_new("Female", ""));
// Init:
array arrRowseries ={};
number countTotal = count() where true;
number count;
FixedCrossTableRowSeries rowseries;
FixedCrossTableDataItem dataItemAbs;
FixedCrossTableDataItem dataItemPct;
FixedCrossTableDataSeries dataserie;

dataserie = new FixedCrossTableDataSeries();
count = count() where D_Week == [201401-201453] && Gender == [1];
dataItemAbs = new FixedCrossTableDataItem();
dataItemAbs.Value = count;
dataItemPct = new FixedCrossTableDataItem();
dataItemPct.Value = count*100/countTotal;
dataserie.Add(dataItemAbs,dataItemPct);

count = count() where D_Week == [201401-201453] && Gender == [2];
dataItemAbs = new FixedCrossTableDataItem();
dataItemAbs.Value = count;
dataItemPct = new FixedCrossTableDataItem();
dataItemPct.Value = count*100/countTotal;
dataserie.Add(dataItemAbs,dataItemPct);

count = count() where D_Week == [201401-201453];
dataserie.AbsoluteTotal.Value = count;
dataserie.PercentageTotal.Value = count/count * 100;
rowseries.Add(dataserie);
arrRowseries = {rowseries,rowseries,rowseries};
// Set up a table
// table 2x0


FixedCrossTable table1x1 = new FixedCrossTable("Create by createFixedCrossDiagram ", axisPrimary,"Col title", axisSecond, arrRowseries, {});
// genarate table:
createFixedCrossDiagram(table1x1);

Result:
Tabu Table1x1.png

Examples For Table 2x1

DCS_use(15517112);

// Get Axis:
array axisRowPrimary = Axis_new("LuuTest1");
axisRowPrimary[AXIS_TEXT] = "Gender test";
Axis_addOption(axisRowPrimary, AxisOption_new("Mand", ""));
Axis_addOption(axisRowPrimary, AxisOption_new("Kvinde", ""));
array axisRowSecond = Axis_new("LuuTest2");
axisRowSecond[AXIS_TEXT] = "Region test";
Axis_addOption(axisRowSecond, AxisOption_new("Region Hovedstaden", ""));
Axis_addOption(axisRowSecond, AxisOption_new("Other Region", ""));

array axisColPrimary = Axis_new("LuuTest3");
axisColPrimary[AXIS_TEXT] = "Week test";
Axis_addOption(axisColPrimary, AxisOption_new("Year 2014", ""));
Axis_addOption(axisColPrimary, AxisOption_new("Year Other", ""));


array arrRowseries ={};
number count;
FixedCrossTableRowSeries rowseries;
FixedCrossTableDataItem dataItemAbs;
FixedCrossTableDataSeries dataserie;

dataserie = new FixedCrossTableDataSeries();

dataItemAbs = new FixedCrossTableDataItem();
dataItemAbs.Value = 1;
dataserie.Add(dataItemAbs,dataItemAbs);
dataserie.Add(dataItemAbs,dataItemAbs);
dataserie.AbsoluteTotal.Value = 1;
dataserie.PercentageTotal.Value = 1;

rowseries.Add(dataserie);
rowseries.Add(dataserie);

arrRowseries = {rowseries,rowseries,rowseries};

FixedCrossTable table2x1 = new FixedCrossTable("Create by createFixedCrossDiagram ", axisRowPrimary, axisRowSecond,"Column title", axisColPrimary, arrRowseries, {});
// genarate table:
createFixedCrossDiagram(table2x1);
createCrossDiagram({"Gender","Region"},{"D_Week"});

Result:
Table2x1.png


Examples For Table 2x2

DCS_use(15521068);

Tabulation_setSignificance(true);
Tabulation_setWeightDescriptionVisibility(true);
 
// Get Axis:
array axisRowPrimary = Axis_new("LuuTest1");
axisRowPrimary[AXIS_TEXT] = "Gender test";
Axis_addOption(axisRowPrimary, AxisOption_new("Mand", ""));
Axis_addOption(axisRowPrimary, AxisOption_new("Kvinde", ""));
array axisRowSecond = Axis_new("LuuTest2");
axisRowSecond[AXIS_TEXT] = "Region test";
Axis_addOption(axisRowSecond, AxisOption_new("Region Hovedstaden", ""));
Axis_addOption(axisRowSecond, AxisOption_new("Other Region", ""));
 
array axisColPrimary = Axis_new("LuuTest3");
axisColPrimary[AXIS_TEXT] = "Week test";
Axis_addOption(axisColPrimary, AxisOption_new("Year 2014", ""));
Axis_addOption(axisColPrimary, AxisOption_new("Year Other", ""));
 
array axisColSecond = Axis_new("LuuTest4");
axisColSecond[AXIS_TEXT] = "Age Group test";
Axis_addOption(axisColSecond, AxisOption_new("Year 2014", ""));
Axis_addOption(axisColSecond, AxisOption_new("Year Other", ""));
 
array arrRowseries ={};
number count;
FixedCrossTableRowSeries rowseries;
FixedCrossTableDataItem dataItemAbs;
FixedCrossTableDataItem dataItemSta;
FixedCrossTableDataSeries dataserie;
FixedCrossTableExtraRow er = new FixedCrossTableExtraRow("header", "content");
 
dataserie = new FixedCrossTableDataSeries();
 
dataItemAbs = new FixedCrossTableDataItem();
dataItemAbs.Value = 1;
dataItemSta = new FixedCrossTableDataItem();
dataItemSta.Value = 2;
dataserie.Add(dataItemAbs,dataItemAbs);
dataserie.Add(dataItemAbs,dataItemAbs);
dataserie.AddStat(dataItemSta); // for Average
dataserie.AddStat(dataItemSta); // for Median
dataserie.AddStat(dataItemSta); // Variance
dataserie.AddStat(dataItemSta); // for Percentile 20
dataserie.AddStat(dataItemSta); // for Percentile 50
dataserie.AbsoluteTotal.Value = 1;
dataserie.PercentageTotal.Value = 1;
 
rowseries.Add(dataserie);
rowseries.Add(dataserie);
 
arrRowseries = {rowseries,rowseries,rowseries,rowseries,rowseries,rowseries};
 setAverage(true);
setMedian(true);
setVariance(true);
addPercentile(20);
addPercentile(50);
FixedCrossTable table2x2 = new FixedCrossTable("Create by createFixedCrossDiagram ", axisRowPrimary, axisRowSecond,"Column title", axisColPrimary, axisColSecond, arrRowseries, {er});

// genarate table:
createFixedCrossDiagram(table2x2);
//createCrossDiagram({"D_Gender","D_Region"},{"D_YearWeek"});

Result:
Update2x2.png

Create table 1x0 using Axis and AxisOption class

DataCacheSpecification dcs = new DataCacheSpecification (15636575);
//rowTitle
string rowTitle = "Gender";
//primaryRowAxis
Axis primaryRowAxis = new Axis(dcs, "Gender", "this is Gender");
primaryRowAxis.AddOption(new AxisOption (dcs, "Male", "Gender == [1]") );
primaryRowAxis.AddOption(new AxisOption (dcs, "Female", "Gender == [2]") );
//rowSeries
Dictionary expression =
{
"Male": "count() where Gender == [1];",
"Female": "count() where Gender == [2];",
"Total": "count () where true;"
	
};
Dictionary Count = dcs.EvalWhere(expression);

FixedCrossTableRowSeries rowSeries = new FixedCrossTableRowSeries ();
FixedCrossTableDataSeries series = new FixedCrossTableDataSeries ();

FixedCrossTableDataItem absolute1 = new FixedCrossTableDataItem ();
FixedCrossTableDataItem percentage1 = new FixedCrossTableDataItem ();
absolute1.Value = Count["Male"];
percentage1.Value = Count["Male"]*100/Count["Total"];
series.Add(absolute1 , percentage1 );

FixedCrossTableDataItem absolute2 = new FixedCrossTableDataItem ();
FixedCrossTableDataItem percentage2 = new FixedCrossTableDataItem ();
absolute2.Value = Count["Female"];
percentage2.Value = Count["Female"]*100/Count["Total"];
series.Add(absolute2 , percentage2 );


series.AbsoluteTotal.Value = Count["Total"];
series.PercentageTotal.Value = Count["Total"]/Count["Total"]* 100;

FixedCrossTableDataItem stat = new FixedCrossTableDataItem ();
stat.Value = 5;
series.AddStat(stat );

rowSeries.Add(series);
//extraRows
FixedCrossTableExtraRow er1 = new FixedCrossTableExtraRow("header1", "content1");
FixedCrossTableExtraRow er2 = new FixedCrossTableExtraRow("header2", "content2");
array extraRows = {er1, er2};
//table1x0
FixedCrossTable table1x0 = new FixedCrossTable (rowTitle, primaryRowAxis, rowSeries, extraRows);
setAverage(true);

DCS_use(15636575);
createFixedCrossDiagram(table1x0);

2018-07-26 15-41-59.png