|
//
|
|
// Created by mark on 6/5/25.
|
|
//
|
|
|
|
#ifndef CHARTJSDATASERIES_H
|
|
#define CHARTJSDATASERIES_H
|
|
#include <string>
|
|
#include <variant>
|
|
#include <vector>
|
|
#include <ReportsAndCharts//WChartJSLibrary.h>
|
|
#include <Wt/Json/Array.h>
|
|
#include <Wt/Json/Object.h>
|
|
#include <Wt/Json/Value.h>
|
|
|
|
// This class is designed to index a particular column in the WStandardItemModel as a
|
|
// std::set<int,std::Json::Object>, or essentially, a std::Json::Object<int,std::Json::Object>
|
|
// that holds all the Chart.js options specific to that "data" series that will eventually
|
|
// become one of the "datasets:" of the overall "data:" object.
|
|
|
|
class WChartJSDataSeries
|
|
{
|
|
public:
|
|
|
|
explicit WChartJSDataSeries(ChartJSType type);
|
|
|
|
// call this method to get the fully formed Json for this modelColumn
|
|
Wt::Json::Object getJson();
|
|
|
|
void addSeriesOption(const std::string& propertyName, const Wt::Json::Object& option); // multi-level option tree if not listed here
|
|
void disableYaxisAnimation();
|
|
|
|
// --- Common Dataset Options ---
|
|
|
|
void setLineBarCircleSeriesColor(const std::string& color) ;
|
|
// Implementation to store or process the background color
|
|
|
|
void setLineBarCircleSeriesColor(const std::vector<std::string>& colors);
|
|
// multiple colors as used in radar, pie, etc.
|
|
|
|
void setLineBarCircleSeriesBorderColor(const std::string& color) ;
|
|
// Implementation for border color
|
|
|
|
// void setLineBarCircleSeriesBorderColor(const std::vector<std::string>& colors) ;
|
|
// Implementation for border color
|
|
|
|
void setBorderWidth(int width) ;
|
|
// Implementation for a uniform border width
|
|
|
|
void setClip(int clip) ;
|
|
// Implementation for clipping
|
|
|
|
|
|
void setHidden(bool isHidden) ;
|
|
// Implementation to set dataset visibility
|
|
|
|
|
|
void setHoverBackgroundColor(const std::string& color) ;
|
|
// Implementation for hover background color
|
|
|
|
|
|
void setHoverBorderColor(const std::string& color) ;
|
|
// Implementation for hover border color
|
|
|
|
|
|
void setHoverBorderWidth(int width) ;
|
|
// Implementation for hover border width
|
|
|
|
|
|
void setIndexAxis(const std::string& axis) ; // "x" or "y"
|
|
// Implementation for setting the index axis
|
|
|
|
|
|
void setOrder(int order) ;
|
|
// Implementation for dataset drawing order
|
|
|
|
|
|
void setParsing(bool shouldParse) ;
|
|
// Implementation for enabling/disabling data parsing
|
|
|
|
|
|
void setStack(const std::string& stackId) ;
|
|
// Implementation for setting the stack group ID
|
|
|
|
|
|
void setXAxisID(const std::string& id) ;
|
|
// Implementation for associating with a specific X-axis
|
|
|
|
|
|
void setYAxisID(const std::string& id) ;
|
|
// Implementation for associating with a specific Y-axis
|
|
|
|
void setHeaderTextPosition(HeaderText);
|
|
|
|
|
|
// --- Line Chart Specific Options ---
|
|
|
|
void setBorderCapStyle(const std::string& style) ; // "butt", "round", "square"
|
|
// Implementation for line cap style
|
|
|
|
|
|
void setBorderDash(const Wt::Json::Array& dashPattern) ;
|
|
// Implementation for creating dashed lines
|
|
|
|
|
|
void setBorderDashOffset(double offset) ;
|
|
// Implementation for dash offset
|
|
|
|
|
|
void setBorderJoinStyle(const std::string& style) ; // "round", "bevel", "miter"
|
|
// Implementation for line join style
|
|
|
|
|
|
void setCubicInterpolationMode(const std::string& mode) ; // "default", "monotone"
|
|
// Implementation for interpolation mode
|
|
|
|
|
|
void setFill(bool fill) ;
|
|
// Implementation for boolean fill
|
|
|
|
|
|
void setFill(const std::string& fill) ; // e.g., "+1", "start"
|
|
// Overload for string-based fill
|
|
|
|
|
|
void setPointBackgroundColor(const std::string& color) ;
|
|
// Implementation for point background color
|
|
|
|
|
|
void setPointBorderColor(const std::string& color) ;
|
|
// Implementation for point border color
|
|
|
|
|
|
void setPointBorderWidth(int width) ;
|
|
// Implementation for point border width
|
|
|
|
|
|
void setPointHitRadius(int radius) ;
|
|
// Implementation for point hit radius
|
|
|
|
|
|
void setPointHoverBackgroundColor(const std::string& color) ;
|
|
// Implementation for point hover background color
|
|
|
|
|
|
void setPointHoverBorderColor(const std::string& color) ;
|
|
// Implementation for point hover border color
|
|
|
|
|
|
void setPointHoverBorderWidth(int width) ;
|
|
// Implementation for point hover border width
|
|
|
|
|
|
void setPointHoverRadius(int radius) ;
|
|
// Implementation for point hover radius
|
|
|
|
|
|
void setPointRadius(int radius) ;
|
|
// Implementation for point radius
|
|
|
|
|
|
void setPointRotation(int angle) ;
|
|
// Implementation for point rotation
|
|
|
|
|
|
void setPointStyle(const std::string& style) ; // "circle", "cross", etc.
|
|
// Implementation for point style
|
|
|
|
|
|
void setShowLine(bool show) ;
|
|
// Implementation to show or hide the line
|
|
|
|
|
|
void setSpanGaps(bool span) ;
|
|
// Implementation for spanning gaps
|
|
|
|
|
|
void setStepped(bool stepped) ;
|
|
// Implementation for boolean stepped line
|
|
|
|
|
|
void setStepped(const std::string& stepped) ; // "before", "after", "middle"
|
|
// Overload for string-based stepped line
|
|
|
|
|
|
void setTension(double tension) ;
|
|
// Implementation for line tension
|
|
|
|
|
|
|
|
// --- Bar Chart Specific Options ---
|
|
|
|
void setBase(double baseValue) ;
|
|
// Implementation for bar base value
|
|
|
|
|
|
void setBarPercentage(double percentage) ;
|
|
// Implementation for bar percentage
|
|
|
|
|
|
void setCategoryPercentage(double percentage) ;
|
|
// Implementation for category percentage
|
|
|
|
|
|
void setBorderRadius(int radius) ;
|
|
// Implementation for border radius
|
|
|
|
|
|
void setBorderSkipped(const std::string& edge) ; // "start", "end", etc.
|
|
// Implementation for skipping border edges
|
|
|
|
|
|
void setGrouped(bool isGrouped) ;
|
|
// Implementation for grouping bars
|
|
|
|
|
|
void setMinBarLength(int length) ;
|
|
// Implementation for minimum bar length
|
|
|
|
|
|
|
|
// --- Pie & Doughnut Chart Specific Options ---
|
|
|
|
void setBorderAlign(const std::string& alignment) ; // "center", "inner"
|
|
// Implementation for border alignment
|
|
|
|
|
|
void setHoverOffset(int offset) ;
|
|
// Implementation for hover offset
|
|
|
|
|
|
void setOffset(int offset) ;
|
|
// Implementation for arc offset
|
|
|
|
|
|
void setSpacing(int spacing) ;
|
|
// Implementation for spacing between arcs
|
|
|
|
|
|
void setWeight(double weight) ;
|
|
// Implementation for dataset weight
|
|
|
|
|
|
void setCutout(const std::string& cutout) ; // For Doughnut charts, e.g., "50%"
|
|
// Implementation for doughnut cutout
|
|
|
|
private:
|
|
[[nodiscard]] Wt::Json::Value getBackgroundColorAsJson() const;
|
|
[[nodiscard]] Wt::Json::Value getBorderColorAsJson() const;
|
|
Wt::Json::Object seriesOptions_;
|
|
int borderWidth_{};
|
|
// --- Common Dataset Properties ---
|
|
ChartJSType chartType_;
|
|
void setSeriesChartJSType(ChartJSType);
|
|
std::variant<std::string, std::vector<std::string>> lineBarCircleSeriesMainColor_;
|
|
std::variant<std::string, std::vector<std::string>> lineBarCircleSeriesBorderColor_;
|
|
int clip_{};
|
|
bool hidden_{};
|
|
std::string hoverBackgroundColor_;
|
|
std::string hoverBorderColor_;
|
|
int hoverBorderWidth_{};
|
|
std::string indexAxis_;
|
|
int order_{};
|
|
bool parsing_{};
|
|
std::string stack_;
|
|
std::string xAxisID_;
|
|
std::string yAxisID_;
|
|
char headerTextOrientation_ = 'H';
|
|
|
|
// Line Specific
|
|
std::string borderCapStyle_;
|
|
Wt::Json::Array borderDash_;
|
|
double borderDashOffset_{};
|
|
std::string borderJoinStyle_;
|
|
std::string cubicInterpolationMode_;
|
|
std::variant<bool, std::string> fill_;
|
|
std::string pointBackgroundColor_;
|
|
std::string pointBorderColor_;
|
|
int pointBorderWidth_{};
|
|
int pointHitRadius_{};
|
|
std::string pointHoverBackgroundColor_;
|
|
std::string pointHoverBorderColor_;
|
|
int pointHoverBorderWidth_{};
|
|
int pointHoverRadius_{};
|
|
int pointRadius_{};
|
|
int pointRotation_{};
|
|
std::string pointStyle_;
|
|
bool showLine_{};
|
|
bool spanGaps_{};
|
|
std::variant<bool, std::string> stepped_;
|
|
double tension_{};
|
|
|
|
// Bar Specific
|
|
double base_{};
|
|
double barPercentage_{};
|
|
double categoryPercentage_{};
|
|
int borderRadius_{};
|
|
std::string borderSkipped_;
|
|
bool grouped_{};
|
|
int minBarLength_{};
|
|
|
|
// Pie and Doughnut specific
|
|
std::string borderAlign_;
|
|
int hoverOffset_{};
|
|
int offset_{};
|
|
int spacing_{};
|
|
double weight_{};
|
|
std::string cutout_;
|
|
};
|
|
|
|
#endif //CHARTJSDATASERIES_H
|