plotly_scatter3d_fl()
Gilt für: ✅Microsoft Fabric✅Azure Data Explorer✅Azure Monitor✅Microsoft Sentinel
Die Funktion plotly_scatter3d_fl()
ist eine benutzerdefinierte Funktion (UDF), mit der Sie eine Zeichnungsvorlage anpassen können, um ein interaktives 3D-Punktdiagramm zu erstellen.
Die Funktion akzeptiert eine Tabelle mit den zu rendernden Datensätzen, den Namen der X-, Y-, Z- und Aggregationsspalten und der Diagrammtitelzeichenfolge. Die Funktion gibt eine einzelne Zellentabelle zurück, die JSON-Zeichnung enthält. Optional können Sie die Daten in einer Azure Data Explorer-Dashboardkachel rendern. Weitere Informationen finden Sie unter Plotly (Vorschau).
Die Funktion akzeptiert eine Tabelle mit den zu rendernden Datensätzen, den Namen der X-, Y-, Z- und Aggregationsspalten und der Diagrammtitelzeichenfolge. Die Funktion gibt eine einzelne Zellentabelle zurück, die JSON-Zeichnung enthält. Optional können Sie die Daten in einer Echtzeit-Dashboardkachel rendern. Weitere Informationen finden Sie unter Plotly (Vorschau).
Voraussetzungen
Extrahieren Sie die erforderliche Punkt3d-Vorlage aus der öffentlich verfügbaren PlotlyTemplate
Tabelle. Kopieren Sie diese Tabelle aus der Beispieldatenbank in Ihre Datenbank, indem Sie den folgenden KQL-Befehl aus der Zieldatenbank ausführen:
.set PlotlyTemplate <| cluster('help.kusto.windows.net').database('Samples').PlotlyTemplate
Syntax
T | invoke plotly_scatter3d_fl(
,
x_col y_col,
z_col aggr_col ,
[,
chart_title ])
Erfahren Sie mehr über Syntaxkonventionen.
Parameter
Name | Type | Erforderlich | Beschreibung |
---|---|---|---|
x_col | string |
✔️ | Der Name der Spalte für die X koordinierte 3D-Zeichnung. |
y_col | string |
✔️ | Der Name der Spalte für die Y koordinierte 3D-Zeichnung. |
z_col | string |
✔️ | Der Name der Spalte für die Z koordinierte 3D-Zeichnung. |
aggr_col | string |
✔️ | Der Name der Gruppierungsspalte. Datensätze in derselben Gruppe werden in unterschiedlicher Farbe gerendert. |
chart_title | string |
Der Diagrammtitel. Der Standardwert ist "3D Punktdiagramm". |
Funktionsdefinition
Sie können die Funktion definieren, indem Sie den Code entweder als abfragedefinierte Funktion einbetten oder wie folgt als gespeicherte Funktion in Ihrer Datenbank erstellen:
Definieren Sie die Funktion mithilfe der folgenden Let-Anweisung. Es sind keine Berechtigungen erforderlich.
Wichtig
Eine Let-Anweisung kann nicht alleine ausgeführt werden. Auf sie muss eine tabellarische Ausdrucksanweisung folgen. Informationen zum Ausführen eines funktionierenden Beispiels plotly_scatter3d_fl()
finden Sie unter Beispiel.
let plotly_scatter3d_fl=(tbl:(*), x_col:string, y_col:string, z_col:string, aggr_col:string='', chart_title:string='3D Scatter chart')
{
let scatter3d_chart = toscalar(PlotlyTemplate | where name == "scatter3d" | project plotly);
let tbl_ex = tbl | extend _x = column_ifexists(x_col, 0.0), _y = column_ifexists(y_col, 0.0), _z = column_ifexists(z_col, 0.0), _aggr = column_ifexists(aggr_col, 'ALL');
tbl_ex
| serialize
| summarize _x=pack_array(make_list(_x)), _y=pack_array(make_list(_y)), _z=pack_array(make_list(_z)) by _aggr
| summarize _aggr=make_list(_aggr), _x=make_list(_x), _y=make_list(_y), _z=make_list(_z)
| extend plotly = scatter3d_chart
| extend plotly=replace_string(plotly, '$CLASS1$', tostring(_aggr[0]))
| extend plotly=replace_string(plotly, '$CLASS2$', tostring(_aggr[1]))
| extend plotly=replace_string(plotly, '$CLASS3$', tostring(_aggr[2]))
| extend plotly=replace_string(plotly, '$X_NAME$', x_col)
| extend plotly=replace_string(plotly, '$Y_NAME$', y_col)
| extend plotly=replace_string(plotly, '$Z_NAME$', z_col)
| extend plotly=replace_string(plotly, '$CLASS1_X$', tostring(_x[0]))
| extend plotly=replace_string(plotly, '$CLASS1_Y$', tostring(_y[0]))
| extend plotly=replace_string(plotly, '$CLASS1_Z$', tostring(_z[0]))
| extend plotly=replace_string(plotly, '$CLASS2_X$', tostring(_x[1]))
| extend plotly=replace_string(plotly, '$CLASS2_Y$', tostring(_y[1]))
| extend plotly=replace_string(plotly, '$CLASS2_Z$', tostring(_z[1]))
| extend plotly=replace_string(plotly, '$CLASS3_X$', tostring(_x[2]))
| extend plotly=replace_string(plotly, '$CLASS3_Y$', tostring(_y[2]))
| extend plotly=replace_string(plotly, '$CLASS3_Z$', tostring(_z[2]))
| extend plotly=replace_string(plotly, '$TITLE$', chart_title)
| project plotly
};
// Write your query to use your function here.
Beispiel
Im folgenden Beispiel wird der Aufrufoperator verwendet, um die Funktion auszuführen.
Um eine abfragedefinierte Funktion zu verwenden, rufen Sie sie nach der definition der eingebetteten Funktion auf.
let plotly_scatter3d_fl=(tbl:(*), x_col:string, y_col:string, z_col:string, aggr_col:string='', chart_title:string='3D Scatter chart')
{
let scatter3d_chart = toscalar(PlotlyTemplate | where name == "scatter3d" | project plotly);
let tbl_ex = tbl | extend _x = column_ifexists(x_col, 0.0), _y = column_ifexists(y_col, 0.0), _z = column_ifexists(z_col, 0.0), _aggr = column_ifexists(aggr_col, 'ALL');
tbl_ex
| serialize
| summarize _x=pack_array(make_list(_x)), _y=pack_array(make_list(_y)), _z=pack_array(make_list(_z)) by _aggr
| summarize _aggr=make_list(_aggr), _x=make_list(_x), _y=make_list(_y), _z=make_list(_z)
| extend plotly = scatter3d_chart
| extend plotly=replace_string(plotly, '$CLASS1$', tostring(_aggr[0]))
| extend plotly=replace_string(plotly, '$CLASS2$', tostring(_aggr[1]))
| extend plotly=replace_string(plotly, '$CLASS3$', tostring(_aggr[2]))
| extend plotly=replace_string(plotly, '$X_NAME$', x_col)
| extend plotly=replace_string(plotly, '$Y_NAME$', y_col)
| extend plotly=replace_string(plotly, '$Z_NAME$', z_col)
| extend plotly=replace_string(plotly, '$CLASS1_X$', tostring(_x[0]))
| extend plotly=replace_string(plotly, '$CLASS1_Y$', tostring(_y[0]))
| extend plotly=replace_string(plotly, '$CLASS1_Z$', tostring(_z[0]))
| extend plotly=replace_string(plotly, '$CLASS2_X$', tostring(_x[1]))
| extend plotly=replace_string(plotly, '$CLASS2_Y$', tostring(_y[1]))
| extend plotly=replace_string(plotly, '$CLASS2_Z$', tostring(_z[1]))
| extend plotly=replace_string(plotly, '$CLASS3_X$', tostring(_x[2]))
| extend plotly=replace_string(plotly, '$CLASS3_Y$', tostring(_y[2]))
| extend plotly=replace_string(plotly, '$CLASS3_Z$', tostring(_z[2]))
| extend plotly=replace_string(plotly, '$TITLE$', chart_title)
| project plotly
};
Iris
| invoke plotly_scatter3d_fl(x_col='SepalLength', y_col='PetalLength', z_col='SepalWidth', aggr_col='Class', chart_title='3D scatter chart using plotly_scatter3d_fl()')
| render plotly
Output
Die Ausgabe ist eine plotly JSON-Zeichenfolge, die in einer Azure Data Explorer-Dashboardkachel gerendert werden kann. Weitere Informationen zum Erstellen von Dashboardkacheln finden Sie unter Visualisieren von Daten mit Azure Data Explorer-Dashboards.
Die Ausgabe ist eine Plotly JSON-Zeichenfolge, die in einer Echtzeit-Dashboardkachel gerendert werden kann. Weitere Informationen zum Erstellen von Dashboardkacheln finden Sie unter Echtzeit-Dashboards.
Sie können bestimmte Datensätze drehen, zoomen und darauf zeigen: