| 2539 | } |
| 2540 | |
| 2541 | void Demo_TickLabels() { |
| 2542 | IMGUI_DEMO_MARKER("Axes/Tick Labels"); |
| 2543 | static bool custom_fmt = true; |
| 2544 | static bool custom_ticks = false; |
| 2545 | static bool custom_labels = true; |
| 2546 | ImGui::Checkbox("Show Custom Format", &custom_fmt); |
| 2547 | ImGui::SameLine(); |
| 2548 | ImGui::Checkbox("Show Custom Ticks", &custom_ticks); |
| 2549 | if (custom_ticks) { |
| 2550 | ImGui::SameLine(); |
| 2551 | ImGui::Checkbox("Show Custom Labels", &custom_labels); |
| 2552 | } |
| 2553 | const double pi = 3.14; |
| 2554 | const char* pi_str[] = {"PI"}; |
| 2555 | static double yticks[] = {100,300,700,900}; |
| 2556 | static const char* ylabels[] = {"One","Three","Seven","Nine"}; |
| 2557 | static double yticks_aux[] = {0.2,0.4,0.6}; |
| 2558 | static const char* ylabels_aux[] = {"A","B","C","D","E","F"}; |
| 2559 | if (ImPlot::BeginPlot("##Ticks")) { |
| 2560 | ImPlot::SetupAxesLimits(2.5,5,0,1000); |
| 2561 | ImPlot::SetupAxis(ImAxis_Y2, nullptr, ImPlotAxisFlags_AuxDefault); |
| 2562 | ImPlot::SetupAxis(ImAxis_Y3, nullptr, ImPlotAxisFlags_AuxDefault); |
| 2563 | if (custom_fmt) { |
| 2564 | ImPlot::SetupAxisFormat(ImAxis_X1, "%g ms"); |
| 2565 | ImPlot::SetupAxisFormat(ImAxis_Y1, MetricFormatter, (void*)"Hz"); |
| 2566 | ImPlot::SetupAxisFormat(ImAxis_Y2, "%g dB"); |
| 2567 | ImPlot::SetupAxisFormat(ImAxis_Y3, MetricFormatter, (void*)"m"); |
| 2568 | } |
| 2569 | if (custom_ticks) { |
| 2570 | ImPlot::SetupAxisTicks(ImAxis_X1, &pi,1,custom_labels ? pi_str : nullptr, true); |
| 2571 | ImPlot::SetupAxisTicks(ImAxis_Y1, yticks, 4, custom_labels ? ylabels : nullptr, false); |
| 2572 | ImPlot::SetupAxisTicks(ImAxis_Y2, yticks_aux, 3, custom_labels ? ylabels_aux : nullptr, false); |
| 2573 | ImPlot::SetupAxisTicks(ImAxis_Y3, 0, 1, 6, custom_labels ? ylabels_aux : nullptr, false); |
| 2574 | } |
| 2575 | ImPlot::EndPlot(); |
| 2576 | } |
| 2577 | } |
| 2578 | |
| 2579 | //----------------------------------------------------------------------------- |
| 2580 |
nothing calls this directly
no test coverage detected