Code:OLAP Radar: Różnice pomiędzy wersjami

Z Motława
Linia 1: Linia 1:
Procedury do [[HierCube]] i [[RadarCube]] =
+
Procedury do [[HierCube]] i [[RadarCube]]
 +
 
 
== HierCube ==
 
== HierCube ==
 
Dla komponentu '''HierCube'''.<br>
 
Dla komponentu '''HierCube'''.<br>

Wersja z 15:08, 20 mar 2009

Procedury do HierCube i RadarCube

HierCube

Dla komponentu HierCube.
W celu dodania własnej procedury wyliczeniowej należy wykonać następujące czynności:

  • kliknąć w komponent Grid (THierCubeGrid);
  • we własności FunctionDefs wybrać zakładkę Sub-function settings;
  • kliknąć w ikonkę Create custom sub-function i w pole Display name wpisać nazwę wyświetlaną, która pojawi się w menu;
  • przechodzimy do zakładki Summary settings, w drzewie wybieramy Distinct Count;
  • wybieramy nowo założoną procedurę i w polu Format mask wybieramy właściwą maskę dla wyświetlanych wartości;


function CalcTrendByCol(Args: TSubFunctionCalculatorArgs; out Res: Double; TrendVer: Integer): Boolean;
var
  Node: TLabelNode;
  Nodes: TLabelNodes;
  i: Integer;
  CurrCell, PrevCell: PDataCell;
  x0, x1: Double;
begin
  { by default return empty cell }
  Result := False;
  with Args do
  begin
    CurrCell := FunctionData[ColTreeIndex, RowTreeIndex];
    if CurrCell.NotEmpty then
    begin
      x1 := CurrCell.Data;
      if x1 = 0.0 then Exit;
    end
    else
      Exit;
    if RowLabelNode = nil then Exit;
    { find the parent node of RowLabelNode }
    Node := RowLabelNode;
    { for the most total node return empty value }
    if Node = nil then Exit;
    { the list of all nodes from the area of adequate comparisons including the given one }
    if Node.IsSubTotal then Exit;
    if (Node.Parent <> nil) and Node.Parent.IsSubTotal then Exit;
    Nodes := Node.LabelNodes;
    { find previous cells from the area of adequate comparisons }
    i := Node.Index - 1;
    if i >= 0 then
    begin
      Node := Nodes[i];
      if not Node.IsSubTotal then
      begin
        PrevCell := FunctionData[ColTreeIndex, Node.TreeIndex]; // RowTreeIndex
        if PrevCell.NotEmpty then
        begin
          Result := True;
          x0 := PrevCell.Data;
          case TrendVer of
            1: Res := (1 - x0/x1) * 100;
            2: Res := x0/x1 * 100;
          end;
        end;
      end;
    end;
  end;
end;

RadarCube

Dla komponentu RadarCube.