mirror of
https://github.com/gwm17/implot.git
synced 2024-11-26 20:28:50 -05:00
internal refactors and misc improvements
This commit is contained in:
parent
a70bbe5cff
commit
2a5a78565b
494
implot.cpp
494
implot.cpp
File diff suppressed because it is too large
Load Diff
26
implot.h
26
implot.h
|
@ -160,15 +160,15 @@ struct ImPlotLimits {
|
||||||
|
|
||||||
// Plot style structure
|
// Plot style structure
|
||||||
struct ImPlotStyle {
|
struct ImPlotStyle {
|
||||||
float LineWeight; // = 1, line weight in pixels
|
float LineWeight; // = 1, line weight in pixels
|
||||||
ImPlotMarker Marker; // = ImPlotMarker_None, marker specification
|
ImPlotMarker Marker; // = ImPlotMarker_None, marker specification
|
||||||
float MarkerSize; // = 4, marker size in pixels (roughly the marker's "radius")
|
float MarkerSize; // = 4, marker size in pixels (roughly the marker's "radius")
|
||||||
float MarkerWeight; // = 1, outline weight of markers in pixels
|
float MarkerWeight; // = 1, outline weight of markers in pixels
|
||||||
float ErrorBarSize; // = 5, error bar whisker width in pixels
|
float ErrorBarSize; // = 5, error bar whisker width in pixels
|
||||||
float ErrorBarWeight; // = 1.5, error bar whisker weight in pixels
|
float ErrorBarWeight; // = 1.5, error bar whisker weight in pixels
|
||||||
float DigitalBitHeight; // = 8, digital channels bit height (at y = 1.0f) in pixels
|
float DigitalBitHeight; // = 8, digital channels bit height (at y = 1.0f) in pixels
|
||||||
float DigitalBitGap; // = 4, digital channels bit padding gap in pixels
|
float DigitalBitGap; // = 4, digital channels bit padding gap in pixels
|
||||||
ImVec4 Colors[ImPlotCol_COUNT]; // array of plot specific colors
|
ImVec4 Colors[ImPlotCol_COUNT]; // array of plot specific colors
|
||||||
ImPlotStyle();
|
ImPlotStyle();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -238,9 +238,9 @@ void PlotErrorBars(const char* label_id, const double* xs, const double* ys, con
|
||||||
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, 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, const double* xs, const double* ys, const double* neg, const double* pos, int count, int offset = 0, int stride = sizeof(double));
|
void PlotErrorBars(const char* label_id, const double* xs, const double* ys, const double* neg, const double* pos, int count, int offset = 0, int stride = sizeof(double));
|
||||||
|
|
||||||
// Plots a pie chart. If the sum of values > 1, each value will be normalized. Center and radius are in plot coordinates.
|
// Plots a pie chart. If the sum of values > 1 or normalize is true, each value will be normalized. Center and radius are in plot coordinates.
|
||||||
void PlotPieChart(const char** label_ids, float* values, int count, float x, float y, float radius, const char* label_fmt = "%.1f%%", float angle0 = 90);
|
void PlotPieChart(const char** label_ids, const float* values, int count, float x, float y, float radius, bool normalize = false, const char* label_fmt = "%.1f", float angle0 = 90);
|
||||||
void PlotPieChart(const char** label_ids, double* values, int count, double x, double y, double radius, const char* label_fmt = "%.1f%%", double angle0 = 90);
|
void PlotPieChart(const char** label_ids, const double* values, int count, double x, double y, double radius, bool normalize = false, const char* label_fmt = "%.1f", double angle0 = 90);
|
||||||
|
|
||||||
// Plots a 2D heatmap chart. Values are expected to be in row-major order. label_fmt can be set to NULL for no labels.
|
// Plots a 2D heatmap chart. Values are expected to be in row-major order. label_fmt can be set to NULL for no labels.
|
||||||
void PlotHeatmap(const char* label_id, const float* values, int rows, int cols, float scale_min, float scale_max, const char* label_fmt = "%.1f", const ImPlotPoint& bounds_min = ImPlotPoint(0,0), const ImPlotPoint& bounds_max = ImPlotPoint(1,1));
|
void PlotHeatmap(const char* label_id, const float* values, int rows, int cols, float scale_min, float scale_max, const char* label_fmt = "%.1f", const ImPlotPoint& bounds_min = ImPlotPoint(0,0), const ImPlotPoint& bounds_max = ImPlotPoint(1,1));
|
||||||
|
@ -297,7 +297,7 @@ void SetColormap(ImPlotColormap colormap, int samples = 0);
|
||||||
void SetColormap(const ImVec4* colors, int num_colors);
|
void SetColormap(const ImVec4* colors, int num_colors);
|
||||||
// Returns the size of the current colormap
|
// Returns the size of the current colormap
|
||||||
int GetColormapSize();
|
int GetColormapSize();
|
||||||
/// Returns a color from the Color map given an index > 0 (modulo will be performed)
|
// Returns a color from the Color map given an index > 0 (modulo will be performed)
|
||||||
ImVec4 GetColormapColor(int index);
|
ImVec4 GetColormapColor(int index);
|
||||||
// Linearly interpolates a color from the current colormap given t between 0 and 1.
|
// Linearly interpolates a color from the current colormap given t between 0 and 1.
|
||||||
ImVec4 LerpColormap(float t);
|
ImVec4 LerpColormap(float t);
|
||||||
|
|
|
@ -295,20 +295,26 @@ void ShowDemoWindow(bool* p_open) {
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
if (ImGui::CollapsingHeader("Pie Charts")) {
|
if (ImGui::CollapsingHeader("Pie Charts")) {
|
||||||
static const char* labels1[] = {"Frogs","Hogs","Dogs","Logs"};
|
static const char* labels1[] = {"Frogs","Hogs","Dogs","Logs"};
|
||||||
static t_float pre_normalized[] = {0.15f, 0.30f, 0.45f, 0.10f};
|
static float data1[] = {0.15f, 0.30f, 0.2f, 0.05f};
|
||||||
|
static bool normalize = false;
|
||||||
|
ImGui::SetNextItemWidth(250);
|
||||||
|
ImGui::DragFloat4("Values", data1, 0.01f, 0, 1);
|
||||||
|
if ((data1[0] + data1[1] + data1[2] + data1[3]) < 1) {
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::Checkbox("Normalize", &normalize);
|
||||||
|
}
|
||||||
SetNextPlotLimits(0,1,0,1,ImGuiCond_Always);
|
SetNextPlotLimits(0,1,0,1,ImGuiCond_Always);
|
||||||
if (ImPlot::BeginPlot("##Pie1", NULL, NULL, ImVec2(250,250), ImPlotFlags_Legend, 0, 0)) {
|
if (ImPlot::BeginPlot("##Pie1", NULL, NULL, ImVec2(250,250), ImPlotFlags_Legend, 0, 0)) {
|
||||||
ImPlot::PlotPieChart(labels1, pre_normalized, 4, 0.5f, 0.5f, 0.4f);
|
ImPlot::PlotPieChart(labels1, data1, 4, 0.5f, 0.5f, 0.4f, normalize, "%.2f");
|
||||||
ImPlot::EndPlot();
|
ImPlot::EndPlot();
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImPlot::SetColormap(ImPlotColormap_Cool, 5);
|
ImPlot::SetColormap(ImPlotColormap_Cool, 5);
|
||||||
SetNextPlotLimits(0,1,0,1,ImGuiCond_Always);
|
SetNextPlotLimits(0,1,0,1,ImGuiCond_Always);
|
||||||
static const char* labels2[] = {"One##1","One##2","Two","Three","Five"};
|
static const char* labels2[] = {"A","B","C","D","E"};
|
||||||
static t_float not_normalized[] = {1,1,2,3,5};
|
static t_float data2[] = {1,1,2,3,5};
|
||||||
if (ImPlot::BeginPlot("##Pie2", NULL, NULL, ImVec2(250,250), ImPlotFlags_Legend, 0, 0)) {
|
if (ImPlot::BeginPlot("##Pie2", NULL, NULL, ImVec2(250,250), ImPlotFlags_Legend, 0, 0)) {
|
||||||
ImPlot::PlotPieChart(labels2, not_normalized, 5, 0.5f, 0.5f, 0.4f, NULL, 0);
|
ImPlot::PlotPieChart(labels2, data2, 5, 0.5f, 0.5f, 0.4f, true, "%.0f", 180);
|
||||||
ImPlot::EndPlot();
|
ImPlot::EndPlot();
|
||||||
}
|
}
|
||||||
ImPlot::SetColormap(ImPlotColormap_Default);
|
ImPlot::SetColormap(ImPlotColormap_Default);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user