Can you provide an example code for a plotly boxplot in an azure query?

Dario Cairoli 25 Reputation points
2023-06-23T13:59:33.48+00:00

Dear Microsoft Q&A Team,

I have trouble integrating a plotly boxplot in my azure data explorer dashboard.

Can you please share an example code to show how to create a box plot on the azure data explorer dashboard?

Thank you very much!

Best regards

Azure Data Explorer
Azure Data Explorer
An Azure data analytics service for real-time analysis on large volumes of data streaming from sources including applications, websites, and internet of things devices.
576 questions
0 comments No comments
{count} votes

Accepted answer
  1. PRADEEPCHEEKATLA 90,641 Reputation points Moderator
    2023-06-26T08:13:17.8466667+00:00

    @Dario Cairoli - Thanks for the question and using MS Q&A platform.

    You can create plotly visual using the python() plugin, see Customize Azure Data Explorer dashboard visuals | Microsoft Learn.

    To render a Plotly visual, the query must generate a table with a single string cell containing Plotly JSON. This Plotly JSON string can be generated by one of the following methods:

    • Dynamically create the string in Python using the Plotly package. This process uses the python() plugin.
    • Retrieve the string from a table that stores pre-cooked Plotly JSON templates. Update the required data fields using KQL string manipulation functions.

    The following KQL query uses inline Python to create the 3D scatter chart:

    OccupancyDetection
    | project Temperature, Humidity, CO2, Occupancy
    | where rand() < 0.1
    | evaluate python(typeof(plotly:string),
    ```if 1:
        import plotly.express as px
        fig = px.scatter_3d(df, x='Temperature', y='Humidity', z='CO2', color='Occupancy')
        fig.update_layout(title=dict(text="Occupancy detection, plotly 5.11.0"))
        plotly_obj = fig.to_json()
        result = pd.DataFrame(data = [plotly_obj], columns = ["plotly"])
    ```)
    

    Screenshot of plotly visual type.

    Hope this helps. Do let us know if you any further queries.


    If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.