diff --git a/implot.cpp b/implot.cpp index a165030..f074b3d 100644 --- a/implot.cpp +++ b/implot.cpp @@ -1860,12 +1860,15 @@ void PlotErrorBars(const char* label_id, ImVec4 (*getter)(void* data, int idx), PopClipRect(); } -void PlotLabel(const char* text, float x, float y, const ImVec2& pixel_offset) { +void PlotLabel(const char* text, float x, float y, bool vertical, const ImVec2& pixel_offset) { IM_ASSERT_USER_ERROR(gp.CurrentPlot != NULL, "PlotLabel() Needs to be called between BeginPlot() and EndPlot()!"); ImDrawList & DrawList = *ImGui::GetWindowDrawList(); PushClipRect(gp.BB_Grid.Min, gp.BB_Grid.Max, true); ImVec2 pos = gp.ToPixels({x,y}) + pixel_offset; - DrawList.AddText(pos, gp.Col_Txt, text); + if (vertical) + AddTextVertical(&DrawList, text, pos, gp.Col_Txt); + else + DrawList.AddText(pos, gp.Col_Txt, text); PopClipRect(); } diff --git a/implot.h b/implot.h index a60132d..b77ae56 100644 --- a/implot.h +++ b/implot.h @@ -189,7 +189,7 @@ void PlotErrorBars(const char* label_id, const float* xs, const float* ys, const void PlotErrorBars(const char* label_id, const float* xs, const float* ys, const float* neg, const float* pos, int count, int offset = 0, int stride = sizeof(float)); void PlotErrorBars(const char* label_id, ImVec4 (*getter)(void* data, int idx), void* data, int count, int offset = 0); // Plots a text label at point x,y. -void PlotLabel(const char* text, float x, float y, const ImVec2& pixel_offset = ImVec2(0,0)); +void PlotLabel(const char* text, float x, float y, bool vertical = false, const ImVec2& pixel_offset = ImVec2(0,0)); //----------------------------------------------------------------------------- // Plot Styling diff --git a/implot_demo.cpp b/implot_demo.cpp index 63354c0..2716d33 100644 --- a/implot_demo.cpp +++ b/implot_demo.cpp @@ -213,7 +213,7 @@ void ShowImPlotDemoWindow(bool* p_open) { } //------------------------------------------------------------------------- - if (ImGui::CollapsingHeader("Marker Styles")) { + if (ImGui::CollapsingHeader("Markers and Labels")) { ImGui::SetNextPlotRange(0, 10, 0, 12); if (ImGui::BeginPlot("##MarkerStyles", NULL, NULL, ImVec2(-1,300), 0, 0, 0)) { float xs[2] = {1,4}; @@ -281,6 +281,10 @@ void ShowImPlotDemoWindow(bool* p_open) { ImGui::PopPlotStyleVar(4); ImGui::PopPlotColor(3); + ImGui::PlotLabel("Filled Markers", 1.5, 11.75); + ImGui::PlotLabel("Open Markers", 6.75, 11.75); + ImGui::PlotLabel("Fancy Markers", 4.5, 4.25, true); + ImGui::EndPlot(); } }