Potly Graph对象可以与Azure Data Explorer一起使用吗?

hfwmuf9z  于 2023-10-22  发布在  其他
关注(0)|答案(1)|浏览(95)

我设法通过评估一个plotly片段到Azure Data Explorer(ADX)的Kusto查询中来创建散点图:

let varName = ```if 1:
        import plotly.express as px
        import pandas as pd
        fig = px.scatter(df, x='easting', y='northing')
        fig.update_layout(title=dict(text="Test, plotly 2"))
        plotly_obj = fig.to_json()
        result = pd.DataFrame(data = [plotly_obj], columns = ["plotly"])
```;

data_delivery_report
| project easting, northing
| evaluate python(typeof(plotly:string),
varName)

我更喜欢使用graph_objects而不是plotly express
唉,当我将上面的脚本替换为:

let varName = ```if 1:
        import plotly.graph_objects as go
        import pandas as pd
        fig = go.Scatter(x=df['easting'], y=df['northing'])
        fig.update_layout(title=dict(text="Test, plotly 2"))
        plotly_obj = fig.to_json()
        result = pd.DataFrame(data = [plotly_obj], columns = ["plotly"])
```;

ADX是否支持plotly graph_objects?我检查了this article,但找不到有关该主题的任何信息。

jhiyze9q

jhiyze9q1#

我在我的环境中复制,下面是我的预期结果:
Potly Graph对象可以与Azure Data Explorer一起使用吗?
是的,下面是为我工作的**KQL query**:

table1
|project Id,Name,Age,marks
| evaluate python(typeof(plotly:string),
```if 1:
    import plotly.graph_objects as go
    fig =  go.Figure(data=[go.Scatter(x=df['Id'], y=df['Name'])])
    plotly_obj = fig.to_json()
    result = pd.DataFrame(data = [plotly_obj], columns = ["plotly"])
```)

Output of Json is:

这里我使用go.Figure()来获得预期的输出,尝试将您的查询与我的查询集成以获得所需的输出。

相关问题