執行包含內嵌內容的資料動作

依照此處所描述的資訊,瞭解如何在外部容器 (例如 HTML 頁面或應用程式網頁) 內的視覺化中內嵌和執行資料動作。

註:

當內嵌的應用程式沒有使用 Oracle JET 技術時,本節中的範例就適用於內嵌的資料動作。請參閱:

執行資料動作

當您按一下「發布事件」資料動作時,它會判斷視覺化的相關資訊環境資訊,然後將該資訊傳送給導覽動作服務來處理。導覽動作的服務處理作業會以相關資訊環境有效負載資訊引發名為 "oracle.bitech.dataaction" 的事件。您可以訂閱此事件,如此便可在事件回呼中收到有效負載,然後視需要進一步利用此有效負載。

下列視覺化顯示各組織 (例如 Franchises Org、Inbound Org、International Org) 各業務別 (例如 Communication、Digital、Electronics) 的收益 (以美元為單位)。

以下為 GUID-B6F00C33-0D8C-4AB2-B8F5-59E8D12E4B30-default.gif 的說明
.gif

事件和有效負載格式與相關資訊環境

下列範例示範在使用者於一或多個資料儲存格上按一下滑鼠右鍵來呼叫內嵌資料動作,並從內嵌工作簿所顯示功能表中選取資料動作時,發布事件。

下列範例來自 JSON 檔案,例如 obitech-cca/cca/component.json

事件格式

"events": {
   "oracle.bitech.dataaction": {
      "description": "Generic DV Event published from an embedded data visualization.",
      "bubbles": true,
      "cancelable": false,
      "detail": {
         "eventName": {
         "description": "The name of the published BI Event",
         "type": "string"
      },
      "payload": {
         "description": "The payload contains context and related information to the event published",
         "type": "object"
      }
   }
}

有效負載格式

{"context":[
   "or": [
      "and":[
         {"contextParamValues":[...],
          "contextParamValuesKeys":[...],
          "colFormula":"...",
          "displayName":"...",
          "isDoubleColumn":true/false,
          "dataType":"..."
         }
      ]
   ]
 ]
}

在「依相關資訊環境傳送」中傳送單一資料欄的單一值

在此範例中,當您按一下資料欄儲存格時,會將含有與該資料欄相關之相關資訊環境資訊的物件傳送至外部容器。在此案例中,將傳送組織名稱。

{
   "context": [
      {
         "contextParamValues": [
            "Inbound Org."
         ],
         "contextParamValuesKeys": [
            "Inbound Org."
         ],
         "colFormula": "\"A - Sample Sales\".\"Offices\".\"D3  Organization\"",
         "displayName": "D3  Organization",
         "isDoubleColumn": false,
         "dataType": "varchar"
      }
   ]
}

在「依相關資訊環境傳送」中傳送每個資料欄的單一值

在此範例中,當您按一下資料欄儲存格 (例如 Inbound Org 和 Digital 產品),然後按一下「內嵌 DA1」功能表選項來選取內嵌動作時,會傳送所選業務別和組織的收益值 (以美元為單位)。例如,傳送 Inbound Org 的 Digital 產品收益,在此範例中為 $1, 458,738.42。

以下為 GUID-277630C2-D839-48E9-B965-333BE8D9D7DF-default.gif 的說明
.gif
{
   "context": [
      {
         "contextParamValues": [
            "Digital"
         ],
         "contextParamValuesKeys": [
            "Digital"
         ],
         "colFormula": "\"A - Sample Sales\".\"Products\".\"P3  LOB\"",
         "displayName": "P3  LOB",
         "isDoubleColumn": false,
         "dataType": "varchar"
      },
      {
         "contextParamValues": [
            "Inbound Org."
         ],
         "contextParamValuesKeys": [
            "Inbound Org."
         ],
         "colFormula": "\"A - Sample Sales\".\"Offices\".\"D3  Organization\"",
         "displayName": "D3  Organization",
         "isDoubleColumn": false,
         "dataType": "varchar"
      }
   ]
}

在「依相關資訊環境傳送」中傳送多個值

在此範例中,當您按一下兩個資料列儲存格 (例如 Digital 產品的 Inbound Org 和 International Org),然後按一下「內嵌 DA1」功能表選項來選取內嵌動作時,會傳送兩個所選組織和業務別儲存格的收益值 (以美元為單位)。例如,按一下兩個所選組織 (Inbound Org 和 International Org) 的 Digital 產品收益時,會傳送 $1, 458,738.42 和 $915,528.97 值。

以下為 GUID-FB843F63-4CDC-41E5-A1D6-B640A73981E9-default.gif 的說明
.gif
{
   "context": [
      {
         "or": [
            {
               "and": [
                  {
                     "contextParamValues": [
                        "Digital"
                     ],
                     "contextParamValuesKeys": [
                        "Digital"
                     ],
                     "colFormula": "\"A - Sample Sales\".\"Products\".\"P3  LOB\"",
                     "displayName": "P3  LOB",
                     "isDoubleColumn": false,
                     "dataType": "varchar"
                  },
                  {
                     "contextParamValues": [
                        "Inbound Org."
                     ],
                     "contextParamValuesKeys": [
                        "Inbound Org."
                     ],
                     "colFormula": "\"A - Sample Sales\".\"Offices\".\"D3  Organization\"",
                     "displayName": "D3  Organization",
                     "isDoubleColumn": false,
                     "dataType": "varchar"
                  }
               ]
            },
            {
               "and": [
                  {
                     "contextParamValues": [
                        "Digital"
                     ],
                     "contextParamValuesKeys": [
                        "Digital"
                     ],
                     "colFormula": "\"A - Sample Sales\".\"Products\".\"P3  LOB\"",
                     "displayName": "P3  LOB",
                     "isDoubleColumn": false,
                     "dataType": "varchar"
                  },
                  {
                     "contextParamValues": [
                        "International Org."
                     ],
                     "contextParamValuesKeys": [
                        "International Org."
                     ],
                     "colFormula": "\"A - Sample Sales\".\"Offices\".\"D3  Organization\"",
                     "displayName": "D3  Organization",
                     "isDoubleColumn": false,
                     "dataType": "varchar"
                  }
               ]
            }
         ]
      }
   ]
}

請使用以下步驟設定下方顯示的範例 HTML 頁面。

  1. 新增或修改工作簿的路徑位置。

    請參閱下方的 <======== 1

  2. 訂閱名為 ‘oracle.bitech.dataaction' 的已發布事件。

    請參閱下方的 <======== 2

  3. 定義事件監聽器和事件回呼。

    請參閱下方的 <======== 3

範例 - HTML 頁面中含有可接收事件的視覺化

下列 HTML 頁面含有內嵌的視覺化,且可接收事件。此 HTML 頁面已設定為監聽 "oracle.bitech.dataaction" 事件。

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"><html>
   <head>
      <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
      <title>Standalone DV CCA Demo</title>
      <script src="http://hostname:port/bali/ui/api/v1/plugins/embedding/standalone/embedding.js" type="text/javascript"></script>
   </head>
   <body>
      <h1>Standalone DV CCA Embedded Data Action Demo</h1>
      <div id="mydiv" style="position: absolute; width: calc(100% - 40px); height: calc(100% - 120px)" >
         <oracle-dv project-path="/Shared Folders/RR/sample"></oracle-dv>         <=============== 1
      </div>
      <script>
         requirejs(['knockout', 'ojs/ojcore', 'ojs/ojknockout', 'ojs/ojcomposite', 'jet-composites/oracle-dv/loader'], function(ko) {
          ko.applyBindings();
         });
           
      </script>
      <script>
         var eventName = 'oracle.bitech.dataaction'; <========== 2
         var element = document.getElementById("mydiv");
         if (element) {
         var oEventListener = element.addEventListener(eventName, function (e) { <================= 3
         console.log("***** Payload from DV ***** ");
         console.log("eventName = " + e.detail.eventName);
         console.log("payload = " + JSON.stringify(e.detail.payload));
         console.log("***** Payload from DV end ***** ");
         }, true);
         }
      </script>
   </body>
</html>