Question: how to add a text label on plot canvas
Hi! I'd like to add a label on the plot canvas, is it possible?
ok, I'm looking on how does ImPlot do it for PieChart, here is the code
for (int i = 0; i < count; ++i) {
ImPlotItem* item = GetItem(label_ids[i]);
double percent = normalize ? (double)values[i] / sum : (double)values[i];
a1 = a0 + 2 * IM_PI * percent;
if (item->Show) {
sprintf(buffer, fmt, (double)values[i]);
ImVec2 size = ImGui::CalcTextSize(buffer);
double angle = a0 + (a1 - a0) * 0.5;
ImVec2 pos = PlotToPixels(center.x + 0.5 * radius * cos(angle), center.y + 0.5 * radius * sin(an
ImU32 col = CalcTextColor(ImGui::ColorConvertU32ToFloat4(item->Color));
DrawList.AddText(pos - size * 0.5f, col, buffer);
}
a0 = a1;
}
so it just uses low-level ImGui's API to add this text
is DrawList.AddText the same as giu.Canvas().AddText(...)?
Yes, DrawList.AddText is the same as Canvas().AddText
ok, I've opened a PR on imgui-go to export ImPlot:GetPlotDrawList()
Off-Topic
btw, looking forward to see cimgui-go working, since work with imgui-go is becoming harder after seeing how cimgui-go is simple :smile:let me know if I can help with implementing something on docking branch
@gucio321 Maybe migrate giu.Styler() stuff? There are lot's of migration is pending because the lack of time of mine...
sure, I can try with it @AllenDang could I migrate CSS stuff as well? It is only related to StyleSetter IMO :smile:
@gucio321 Yes, go ahead.
Ok so done
@AllenDang could you please merge imgui-go https://github.com/AllenDang/imgui-go/pull/15
meh, its really complex :smile:
@AllenDang could you help me :pray:
@gucio321 How can I help? What's the issue now?
well, so first of all, plots in cimgui-go are broken (https://github.com/AllenDang/cimgui-go/issues/36)
and imgui-go (in my opinion) lacks some methods...
However, I can be wrong, and just cannot find appropiate way to get position of last plot and add a label.
I don't need it anymore but it should be possible now, with cigui-go