How to Add text to point(s) in Kusto Chart

jwinnd 0 Reputation points
2024-07-21T17:23:17.6866667+00:00

I have a kql script that creates the table here and the line chart below the table. Is it possible to display text on one or more points, as where it says "Champion" in the line chart at bottom?:

table

chart-original

chart-champion

Query

myquery
| render linechart with ( 
    legend = hidden, title = myracer,
    ymin=0, ymax=4,
    xcolumn=Place, xaxis=linear, xtitle="Location",
    ycolumns=Stage_Num,  ytitle="Stage"
)
;
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.
519 questions
{count} votes

1 answer

Sort by: Most helpful
  1. phemanth 9,760 Reputation points Microsoft Vendor
    2024-07-22T10:57:32.49+00:00

    @jwinnd

    Thanks for reaching out to Microsoft Q&A.

    Yes, you can add text annotations to points in a Kusto line chart using extend operator to add a label column and then use the render operator to create a line chart with annotations. Here’s an example:

    let data = datatable(Date: datetime, Stage_Num: int, Place: string)
    [
        datetime(2023-01-29), 1, "Place1",
        datetime(2023-02-02), 5, "Place2",
        datetime(2023-02-04), 5, "Place3",
        datetime(2023-02-08), 5, "Place4"
    ];
    data
    | extend Label = case(Date == datetime(2023-02-02) and Stage_Num == 5, "Champion", "")
    | project Date, Stage_Num, Label
    | render linechart with (title="Stages Over Time", xtitle="Date", ytitle="Stage Number", series=Label)
    
    

    In this example:

    • The extend operator adds a Label column with the text “Champion” for the specified point.
    • The project operator selects the columns to display.
    • The render operator creates the line chart and uses the Label column to annotate the point.

    I have checked by creating the chart

    Screenshot 2024-07-22 151931

    and i have applied the query
    Screenshot 2024-07-22 155709

    Feel free to adjust the x and y values in the annotate operator to match the points you want to label.

    For more details, refer to Azure Data Exploere - render operator.

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


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.