Skip to content

Makie inspector labels don’t work with rich text #5450

@AUK1939

Description

@AUK1939

Opening a github issue as suggested on Julia discourse here

Makie version: Makie v0.24.7
Platform/GPU: Windows + NVidia 4070.
Backend: GLMakie

Minimal repro

using GLMakie
GLMakie.activate!()

labels = ["Alpha", "Beta", "Gamma", "Delta"]
values = [12.5, 8.0, 15.0, 10.5]
colors = [:skyblue, :lightgreen, :gold, :orchid]

fig = Figure(resolution=(650, 400))
ax = Axis(fig[1, 1]; ylabel="Value", xlabel="Category", title="RichText inspector")

function custom_inspector_label_rich(self, idx, pos) 
        val = round(values[idx]; digits=2)
        return Makie.rich(
            Makie.rich("$(labels[idx])"; font=:bold, color=:purple),
            "\n",
            Makie.rich("Value: $val"; color=:green)
        )
end

function custom_inspector_label_plain(self, idx, pos) 
        val = round(values[idx]; digits=2)
        return "$(labels[idx])" * "\n" * "Value: $val"
end

barplot!(ax, values;
    color=colors,
    width=0.6,
    strokewidth=0,
    inspectable=true,
    inspector_label = custom_inspector_label_rich
)

ax.xticks = (1:length(values), labels)
DataInspector(fig)
fig

Expected: hovering shows a rich-text tooltip with bold label and colored value.
Observed: the inspector stack traces and fails because the RichText value cannot be converted to String (MethodError: cannot convert Makie.RichText to String), even though the documented inspector_label hook is used.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions