#include "viz/bar_chart.h"
#include "implot.h"

#include <vector>

void bar_chart(const char* title, const char* const* labels, const float* values, int count, float bar_width) {
    if (ImPlot::BeginPlot(title, ImVec2(-1, 0))) {
        std::vector<double> positions(count);
        for (int i = 0; i < count; i++) positions[i] = i;

        ImPlot::SetupAxisTicks(ImAxis_X1, positions.data(), count, labels);
        ImPlot::PlotBars("##data", values, count, bar_width);
        ImPlot::EndPlot();
    }
}

void bar_chart(const char* title, const char* const* labels, const double* values, int count, double bar_width) {
    if (ImPlot::BeginPlot(title, ImVec2(-1, 0))) {
        std::vector<double> positions(count);
        for (int i = 0; i < count; i++) positions[i] = i;

        ImPlot::SetupAxisTicks(ImAxis_X1, positions.data(), count, labels);
        ImPlot::PlotBars("##data", values, count, bar_width);
        ImPlot::EndPlot();
    }
}
