Make functions of Chart member functions

This commit is contained in:
Thomas Lauf 2019-01-29 08:04:51 +01:00
parent c562f3fc81
commit 49f25ba7d7
3 changed files with 29 additions and 27 deletions

View file

@ -86,7 +86,7 @@ std::string Chart::render (
if (!with_internal_axis) if (!with_internal_axis)
{ {
out << indent out << indent
<< Chart::renderAxis ( << renderAxis (
first_hour, first_hour,
last_hour, last_hour,
color_label, color_label,
@ -114,7 +114,7 @@ std::string Chart::render (
lines[i].add (std::string (total_width, ' '), 0, Color ()); lines[i].add (std::string (total_width, ' '), 0, Color ());
} }
Chart::renderExclusionBlocks (lines, day, first_hour, last_hour, exclusions, minutes_per_char, spacing, renderExclusionBlocks (lines, day, first_hour, last_hour, exclusions, minutes_per_char, spacing,
color_exclusion, color_label, with_internal_axis); color_exclusion, color_label, with_internal_axis);
time_t work = 0; time_t work = 0;
@ -123,7 +123,7 @@ std::string Chart::render (
for (auto &track : tracked) for (auto &track : tracked)
{ {
time_t interval_work = 0; time_t interval_work = 0;
Chart::renderInterval (lines, day, track, tag_colors, first_hour, interval_work, with_ids, minutes_per_char, renderInterval (lines, day, track, tag_colors, first_hour, interval_work, with_ids, minutes_per_char,
spacing); spacing);
work += interval_work; work += interval_work;
} }
@ -132,10 +132,10 @@ std::string Chart::render (
auto now = Datetime (); auto now = Datetime ();
auto color_day = getDayColor (day, now, holidays, color_today, color_holiday); auto color_day = getDayColor (day, now, holidays, color_today, color_holiday);
auto labelMonth = with_month ? Chart::renderMonth (previous, day) : ""; auto labelMonth = with_month ? renderMonth (previous, day) : "";
auto labelWeek = with_week ? Chart::renderWeek (previous, day) : ""; auto labelWeek = with_week ? renderWeek (previous, day) : "";
auto labelWeekday = with_weekday ? Chart::renderWeekday (day, color_day) : ""; auto labelWeekday = with_weekday ? renderWeekday (day, color_day) : "";
auto labelDay = with_day ? Chart::renderDay (day, color_day) : ""; auto labelDay = with_day ? renderDay (day, color_day) : "";
out << labelMonth out << labelMonth
<< labelWeek << labelWeek
@ -153,16 +153,16 @@ std::string Chart::render (
} }
} }
out << (with_totals ? Chart::renderTotal (work) : "") out << (with_totals ? renderTotal (work) : "")
<< '\n'; << '\n';
previous = day; previous = day;
total_work += work; total_work += work;
} }
out << (with_totals ? Chart::renderSubTotal (total_work, std::string (padding_size, ' ')) : "") out << (with_totals ? renderSubTotal (total_work, std::string (padding_size, ' ')) : "")
<< (with_holidays ? Chart::renderHolidays (holidays) : "") << (with_holidays ? renderHolidays (holidays) : "")
<< (with_summary ? Chart::renderSummary (indent, filter, exclusions, tracked, show_intervals) : ""); << (with_summary ? renderSummary (indent, filter, exclusions, tracked, show_intervals) : "");
return out.str (); return out.str ();
} }

View file

@ -36,35 +36,35 @@ class Chart
public: public:
Chart() = default; Chart() = default;
static std::string render (const Interval&, const std::vector <Interval>&, const std::vector <Range>&, const std::map <Datetime, std::string>&, const std::map <std::string, Color>&, const Color&, const Color&, const Color&, const Color&, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, int, int, int); std::string render (const Interval&, const std::vector <Interval>&, const std::vector <Range>&, const std::map <Datetime, std::string>&, const std::map <std::string, Color>&, const Color&, const Color&, const Color&, const Color&, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, int, int, int);
static unsigned long getIndentSize (bool, bool, bool, bool); unsigned long getIndentSize (bool, bool, bool, bool);
static std::pair <int, int> determineHourRange (const Interval&, const std::vector <Interval>&); std::pair <int, int> determineHourRange (const Interval&, const std::vector <Interval>&);
static std::string renderAxis (int, int, const Color&, const Color&, int, bool); std::string renderAxis (int, int, const Color&, const Color&, int, bool);
static std::string renderMonth (const Datetime&, const Datetime&); std::string renderMonth (const Datetime&, const Datetime&);
static std::string renderWeek (const Datetime&, const Datetime&); std::string renderWeek (const Datetime&, const Datetime&);
static std::string renderWeekday (Datetime&, const Color&); std::string renderWeekday (Datetime&, const Color&);
static std::string renderDay (Datetime&, const Color&); std::string renderDay (Datetime&, const Color&);
static Color getDayColor (const Datetime&, const Datetime&, const std::map <Datetime, std::string>&, const Color&, const Color&); Color getDayColor (const Datetime&, const Datetime&, const std::map <Datetime, std::string>&, const Color&, const Color&);
static std::string renderTotal (time_t); std::string renderTotal (time_t);
static std::string renderSubTotal (time_t, const std::string&); std::string renderSubTotal (time_t, const std::string&);
static void renderExclusionBlocks (std::vector<Composite>&, const Datetime&, int, int, const std::vector<Range>&, int, int, const Color&, const Color&, bool); void renderExclusionBlocks (std::vector<Composite>&, const Datetime&, int, int, const std::vector<Range>&, int, int, const Color&, const Color&, bool);
static void renderInterval (std::vector<Composite>&, const Datetime&, const Interval&, const std::map<std::string, Color>&, int, time_t&, bool, int, int); void renderInterval (std::vector<Composite>&, const Datetime&, const Interval&, const std::map<std::string, Color>&, int, time_t&, bool, int, int);
static std::string renderHolidays (const std::map <Datetime, std::string>&); std::string renderHolidays (const std::map <Datetime, std::string>&);
static std::string renderSummary (const std::string&, const Interval&, const std::vector <Range>&, const std::vector <Interval>&, bool); std::string renderSummary (const std::string&, const Interval&, const std::vector <Range>&, const std::vector <Interval>&, bool);
}; };
#endif #endif

View file

@ -145,7 +145,9 @@ int renderChart (
auto axis_type = rules.get ("reports." + type + ".axis"); auto axis_type = rules.get ("reports." + type + ".axis");
const auto with_internal_axis = axis_type == "internal"; const auto with_internal_axis = axis_type == "internal";
std::cout << Chart::render (filter, tracked, exclusions, holidays, tag_colors, color_today, color_holiday, color_label, color_exclusion, show_intervals, determine_hour_range, with_ids, with_summary, with_holidays, with_totals, with_month, with_week, with_day, with_weekday, with_internal_axis, minutes_per_char, spacing, num_lines); Chart chart;
std::cout << chart.render (filter, tracked, exclusions, holidays, tag_colors, color_today, color_holiday, color_label, color_exclusion, show_intervals, determine_hour_range, with_ids, with_summary, with_holidays, with_totals, with_month, with_week, with_day, with_weekday, with_internal_axis, minutes_per_char, spacing, num_lines);
return 0; return 0;
} }