Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ struct Settings
inline static const float PLOT_MIN_DELAY = IF_PLATFORM_WINDOWS(1.f, 0.01f);
inline static const float PLOT_MAX_DELAY = 500.f;

enum class PLOT_TYPES { BARS, LINES, HEATMAP };
enum class PLOT_TYPES { BARS, LINES, HEATMAP, PIE };
inline static PLOT_TYPES PLOT_TYPE = PLOT_TYPES::BARS;

inline static bool PLOT_SHOW_SCALE = true;
Expand Down
30 changes: 27 additions & 3 deletions src/Interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,9 @@ void Interface::draw(sf::RenderWindow& window) {
ImGui::Checkbox("Show scale", &Settings::PLOT_SHOW_SCALE);

static const std::pair<const char*, Settings::PLOT_TYPES> typeNames[] = { {"Bars", Settings::PLOT_TYPES::BARS}, {"Lines", Settings::PLOT_TYPES::LINES},
{"Heatmap", Settings::PLOT_TYPES::HEATMAP} };
{"Heatmap", Settings::PLOT_TYPES::HEATMAP}, {"Pie", Settings::PLOT_TYPES::PIE} };
static int typeChoosed = 0;
if (ImGui::SliderInt("Plot type", &typeChoosed, 0, 2, typeNames[typeChoosed].first))
if (ImGui::SliderInt("Plot type", &typeChoosed, 0, 3, typeNames[typeChoosed].first))
Settings::PLOT_TYPE = typeNames[typeChoosed].second;

ImGui::Separator();
Expand Down Expand Up @@ -374,7 +374,11 @@ void Interface::draw(sf::RenderWindow& window) {
ImGui::SameLine();
}

if (ImPlot::BeginPlot("##MainPlot", {-1, plotSizeHeight}, ImPlotFlags_NoMenus | ImPlotFlags_NoMouseText)) {
ImPlotFlags plotFlags = ImPlotFlags_NoMenus | ImPlotFlags_NoMouseText;
if (Settings::PLOT_TYPE == Settings::PLOT_TYPES::PIE)
plotFlags |= ImPlotFlags_NoLegend;

if (ImPlot::BeginPlot("##MainPlot", {-1, plotSizeHeight}, plotFlags)) {
static std::pair<unsigned, unsigned> gridSize;

if (!Settings::PLOT_SHOW_SCALE || Settings::PLOT_TYPE == Settings::PLOT_TYPES::HEATMAP)
Expand Down Expand Up @@ -408,6 +412,26 @@ void Interface::draw(sf::RenderWindow& window) {
ImPlot::PopStyleColor(); ImPlot::PopStyleColor(); ImPlot::PopStyleColor();
}
}
else if(Settings::PLOT_TYPE == Settings::PLOT_TYPES::PIE) {
ImPlot::SetupAxesLimits(0, 1, 0, 1, ImPlotCond_Always);

if(numbersSize > 0) {
static std::vector<std::string> labels(numbersSize);
static std::vector<const char*> labelsIds;

if(labelsIds.size() != numbersSize) {
labels.resize(numbersSize);
labelsIds.resize(numbersSize);

for(unsigned i = 0; i < numbersSize; ++i) {
labels[i] = std::to_string(i);
labelsIds[i] = labels[i].c_str();
}
}

ImPlot::PlotPieChart(labelsIds.data(), &numbers[0], numbersSize, 0.5, 0.5, 0.48, "%.0f");
}
}
else if(Settings::PLOT_TYPE == Settings::PLOT_TYPES::LINES) {
ImPlot::SetupAxesLimits(0, numbersSize - 1, 0, Settings::SHUFFLE_MAX_VALUE, ImPlotCond_Always);

Expand Down