#pragma once

#include "Widget.hpp"
#include "../HistoryStore.hpp"
#include <array>

class ChartWidget : public Widget {
public:
    explicit ChartWidget(const WidgetConfig& config);

    lv_obj_t* create(lv_obj_t* parent) override;
    void applyStyle() override;
    void onHistoryUpdate() override;

private:
    void refreshData();
    void applyAxisLabels();
    static const char** labelsForPeriod(ChartPeriod period, uint8_t* count);

    lv_obj_t* chart_ = nullptr;
    lv_obj_t* yScale_ = nullptr;
    lv_obj_t* xScale_ = nullptr;
    lv_chart_series_t* series_[CHART_MAX_SERIES] = {};
    std::array<std::array<int32_t, HistoryStore::CHART_POINT_COUNT>, CHART_MAX_SERIES> seriesData_ = {};
};
