mirror of
https://github.com/gwm17/implot.git
synced 2024-11-26 20:28:50 -05:00
make pie chart labels const, remove unused vars
This commit is contained in:
parent
f31ffaae9e
commit
3bc08a946c
|
@ -1171,12 +1171,10 @@ void EndPlot() {
|
|||
|
||||
// AXIS STATES ------------------------------------------------------------
|
||||
|
||||
const bool flip_x = HasFlag(plot.XAxis.Flags, ImAxisFlags_Invert);
|
||||
const bool lock_x_min = HasFlag(plot.XAxis.Flags, ImAxisFlags_LockMin);
|
||||
const bool lock_x_max = HasFlag(plot.XAxis.Flags, ImAxisFlags_LockMax);
|
||||
const bool lock_x = (lock_x_min && lock_x_max) || (gp.NextPlotData.HasXRange && gp.NextPlotData.XRangeCond == ImGuiCond_Always);
|
||||
|
||||
const bool flip_y = HasFlag(plot.YAxis.Flags, ImAxisFlags_Invert);
|
||||
const bool lock_y_min = HasFlag(plot.YAxis.Flags, ImAxisFlags_LockMin);
|
||||
const bool lock_y_max = HasFlag(plot.YAxis.Flags, ImAxisFlags_LockMax);
|
||||
const bool lock_y = (lock_y_min && lock_y_max) || (gp.NextPlotData.HasYRange && gp.NextPlotData.YRangeCond == ImGuiCond_Always);
|
||||
|
@ -2151,7 +2149,7 @@ inline void DrawPieSlice(ImDrawList& DrawList, const ImVec2& center, float radiu
|
|||
}
|
||||
|
||||
|
||||
void PlotPieChart(char** label_ids, float* values, int count, const ImVec2& center, float radius, bool show_percents, float angle0) {
|
||||
void PlotPieChart(const char** label_ids, float* values, int count, const ImVec2& center, float radius, bool show_percents, float angle0) {
|
||||
IM_ASSERT_USER_ERROR(gp.CurrentPlot != NULL, "PlotPieChart() Needs to be called between BeginPlot() and EndPlot()!");
|
||||
ImDrawList & DrawList = *GetWindowDrawList();
|
||||
|
||||
|
|
2
implot.h
2
implot.h
|
@ -170,7 +170,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 pie chart. If the sum of values > 1, each value will be normalized. Center and radius are in plot coordinates.
|
||||
void PlotPieChart(char** label_ids, float* values, int count, const ImVec2& center, float radius, bool show_percents = true, float angle0 = 90);
|
||||
void PlotPieChart(const char** label_ids, float* values, int count, const ImVec2& center, float radius, bool show_percents = true, float angle0 = 90);
|
||||
// Plots a text label at point x,y.
|
||||
void PlotLabel(const char* text, float x, float y, bool vertical = false, const ImVec2& pixel_offset = ImVec2(0,0));
|
||||
|
||||
|
|
|
@ -212,7 +212,7 @@ void ShowImPlotDemoWindow(bool* p_open) {
|
|||
}
|
||||
//-------------------------------------------------------------------------
|
||||
if (ImGui::CollapsingHeader("Pie Charts")) {
|
||||
static char* labels1[] = {"Frogs","Hogs","Dogs","Logs"};
|
||||
static const char* labels1[] = {"Frogs","Hogs","Dogs","Logs"};
|
||||
static float pre_normalized[] = {0.15f, 0.30f, 0.45f, 0.10f};
|
||||
ImVec2 center(0.5f,0.5f); // in plot units, not pixels
|
||||
float radius = 0.4f; // in plot units, not pixels
|
||||
|
@ -233,7 +233,7 @@ void ShowImPlotDemoWindow(bool* p_open) {
|
|||
};
|
||||
ImGui::SetPlotPalette(YlOrRd, 5);
|
||||
SetNextPlotRange(0,1,0,1,ImGuiCond_Always);
|
||||
static char* labels2[] = {"One","Two","Three","Four","Five"};
|
||||
static const char* labels2[] = {"One","Two","Three","Four","Five"};
|
||||
static float not_normalized[] = {1,2,3,4,5};
|
||||
if (ImGui::BeginPlot("##Pie2", NULL, NULL, ImVec2(250,250), ImPlotFlags_Legend, 0, 0)) {
|
||||
ImGui::PlotPieChart(labels2, not_normalized, 5, center, radius);
|
||||
|
|
Loading…
Reference in New Issue
Block a user