Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Excerpt
namede Scription Dokumentaion (comments)

graphomate comments integrate seamlessly into the SAP Analytics Cloud. Scripting is also supported in the Application Designer of the SAP Analytics Cloud.

The properties shown in the property sheet can be retrieved and set by scripting from the component. There are also methods that make it easy to set contexts for comments:

createDataContext(key: string, value: string): DynamicContext;

Über diese Methode kann ein Datenkontext erstellt werden, der dann über die Methode setDynamicContexts, der ein Array aus Kontexten übergeben wird, gesetzt werden kann. Ein Datenkontext beinhaltet in der Regel eine Kombination aus Dimension und Member. Also bspw. ist der key “year” und der value “2017”A data context can be created via this method, which can then be set via the setDynamicContexts method, which is passed an array of contexts. A data context usually contains a combination of dimension and member. For example, the key is "year" and the value is "2021".

createDataContextWithText(key: string, value: string, keyText: string, valueText, string): DynamicContext;

Unterscheidet Ihre Datenquelle zwischen IDs für Dimensionen und Membern und deren Anzeigetext, so kann diese Methode wie createDataContext verwendet werden, mit der zusätzlichen Möglichkeit auch die Anzeigetexte zu setzen. Bpsw. ist hier der key “CAL_YEAR” und der keyText “Year”If your data source makes a difference between IDs for dimensions and members and their display text, this method can be used in the same way as createDataContext.
In addition, it is possible to set the display texts. For example, here the key is "CAL_YEAR" and the keyText is "Year".

createEnvironmentContext(key: string, value: string): DynamicContext;Ein

Umgebungskontext kann dazu genutzt werden um den Kommentarraum auf bspw. eine bestimmte Umgebung oder ein Dashboard einzuschränken. Hierbei könnte dann key etwas wie “Dashboard Name” sein und value dazu “Global Sales 2017”An environment context can be used to limit the comment space to, for example, a specific environment or dashboard. Here, the key could be something like "Dashboard Name" and the value could be "Global Sales 2021".

addOrReplaceDataContext(key: string, value: string): void;

Diese Methode funktioniert grundsätzliche die die createDataContext, nur dass diese den hier definierten Kontext direkt dem Widget hinzufügt oder abändert und somit der web über setDynamicContexts nicht notwendig istThis method works in the same way as createDataContext. However, it adds or changes the context defined here directly to the widget. The path through setDynamicContexts is therefore not necessary.

addOrReplaceDataContextWithText(key: string, value: string, keyText: string, valueText: string): void;

Hier definierte Werte verhalten von den Parametern wie die der Methode createDataContextWithText und werden wie in addOrReplaceDataContext direkt hinzugefügt oder abgeändertThe function parameters behave like those of the createDataContextWithText method. As in addOrReplaceDataContext, however, the context is also added or changed directly.

addOrReplaceEnvironmentContext(key: string, value: string): void;

Die Parameter verhalten sich analog zu createEnvironmentContext. Dieser wird jedoch direkt hinzugefügt oder abgeändertThe parameters work in the same way as createEnvironmentContext. However, they are added or modified directly.

removeDataContext(key: string): void;

Entfernt den Datenkontext mit dem key aus dem Kontextraum des KommentarwidgetsRemoves the data context with the key from the context space of the comment widget.

removeEnvironmentContext(key: string): void;

Entfernt den Umgebungkontext mit dem key aus dem Kontextraum des KommentarwigetsRemoves the environment context with the key from the context space of the comment widget.

setSelectedData(selectedData: SelectionContext[]): void; (ab Version 1.20224.1)

Die in einer graphomate visualisierung per klick selektierten Daten können so dem comments widget zur Generierung von Datenkontexten übergeben werdenThe data selected by click in a graphomate visualization can thus be transferred to the comments widget to create data contexts.

setDynamicContexts(dynamicContexts: DynamicContext[]): void; (ab Version 1.20231.0)

Kontexte, die über die create*Context Methoden erstellt wurden, können hier verwendet werden um die gesamten dynamischen Kontexte neu zu setzen. Der alte Zustand wird hierbei überschriebenContexts created via the create*Context methods can be used here to reset the entire dynamic contexts. The previous status is overwritten in the process.

addOrReplaceContexts(contexts: DynamicContext[]): void; (ab Version 1.20231.0)

Mehrere Kontexte gleichzeitig zu setzen führt bei Verwendung von Setting several contexts at the same time leads to inconsistencies when using addOrReplace*Context zu Unstimmigkeiten. Diese Methode schafft hier Abhilfe, denn sie ermöglicht mehrere, per create*Context erstellte Kontexte, parallel an das Widget zu übergeben. This method provides a remedy because it enables several contexts created via create*Context to be transferred to the widget in parallel.

removeContexts(contexts: DynamicContext[]): void; (ab Version 1.20231.0)

Um mehrere Kontexte gleichzeitig zu entfernen, sollte statt einzelenen Aufrufen von remove*Context, diese Methode verwendet werden um mit create*Context erstellte Kontexte dieser Methode zu übergeben. Diese werden dann aus dem Zustand des Widgets entfernt. In der create*Context Methode kann der key oder der value auch als leerer String gesetzt werden. Dann werden alle Kontexte auf die nur der definierte key oder value zutrifft entfernt.

Beispiele

Um je nach Auswahl eine Wertes in einem DropDown-Feld einen Datenkontext zu setzen, kann folgender Code angepasst werdenTo remove several contexts at the same time, this method should be used to pass contexts created with create*Context to this method instead of individual calls to remove*Context. These are then removed from the state of the widget. In the create*Context method, the key or the value can also be set as an empty string. Then all contexts to which only the defined key or value applies are removed.

Examples

To set a data context depending on the selection of a value in a drop-down field, the following code can be adjusted:

Code Block
var countryMember = Country_Dropdown.getSelectedKey();
if (countryMember === "None") {
	Chart_1.getDataSource().setDimensionFilter("Country_Region", []);
	graphomate_comments_1.removeDataContext("Country_Region");
} else {
	Chart_1.getDataSource().setDimensionFilter("Country_Region", countryMember);
	graphomate_comments_1.addOrReplaceDataContext("Country_Region", countryMember);
}

Folgender Code setzt die Informationen über einen in einem graphomate chart selektierten Datenpunkt als Kontexte für das The following code sets the information about a data point selected in a graphomate chart as contexts for the comments widget:

Code Block
graphomate_comments_1.setSelectedData(graphomate_charts_1.getSelectedData()); // ab Version 1.20224.1

Mehrere Kontexte gleichzeitig können wie folgt abgeändert oder hinzugefügt werden:Multiple contexts can be changed or added at the same time as follows

Code Block
var regionContext = graphomate_comments_1.createDataContext("region", "North");
var countryContext = graphomate_comments_1.createDataContext("country", "Germany");
graphomate_comments_1.addOrReplaceContexts([regionContext, countryContext]);

Um die oben hinzugefügten Kontexte gleichzeitig wieder zu entfernen, kann wie folgt vorgegangen werden:To remove the contexts added above at the same time, you can do the following

Code Block
var regionContext = graphomate_comments_1.createDataContext("region", "North");
var countryContext = graphomate_comments_1.createDataContext("country", "Germany");
graphomate_comments_1.removeContexts([regionContext, countryContext]);

Sollen die beiden Kontexte von oben entfernt werden, unabhängig davon auf welchen Wert sie gesetzt sind, so können Leerstrings verwendet werdenIf the two contexts above are to be removed, regardless of what value they are set to, empty strings can be used:

Code Block
var regionContext = graphomate_comments_1.createDataContext("region", "");
var countryContext = graphomate_comments_1.createDataContext("country", "");
graphomate_comments_1.addOrReplaceContexts([regionContext, countryContext]);

Um alle hinzugefügten dynamischen Kontexte neu zu setzten, als auch die bisher gesetzten zu entfernen, gehen wir wie folgt vorTo reset all the dynamic contexts that have been added and to remove the ones that were previously set, proceed as follows:

Code Block
// zunächstfirst, fügenwe wiradd nura zurcontext Verdeutlichungfor einthe Kontextyear fürjust dasfor Jahr hinzuclarification
graphomate_comments_1.addOrReplaceDataContext("year", "2023");
// danachthen setztenwe wirset dynamischedynamic Kontextecontexts fürfor Regionregion undand Landcountry
var regionContext = graphomate_comments_1.createDataContext("region", "North");
var countryContext = graphomate_comments_1.createDataContext("country", "Germany");
// durchby dieusing VerwendungsetDynamicContexts voninstead setDynamicContexts,of statt addOrReplaceContexts, istthe dercontext Kontextfor fürthe dasyear Jahris dannno nicht mehr gesetztlonger set.
graphomate_comments_1.setDynamicContexts([regionContext, countryContext]);