mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
CmdChart: Switched to use intervalColor
- This should reduce color palette rotation speed
This commit is contained in:
parent
cf8b1aa1d4
commit
225494d360
3 changed files with 13 additions and 13 deletions
|
@ -46,7 +46,7 @@ static std::string renderDayName (const std::string&, const Rules&, Date
|
|||
static std::string renderTotal (const std::string&, const Rules&, time_t);
|
||||
static std::string renderSubTotal (const std::string&, const Rules&, int, int, time_t);
|
||||
static void renderExclusionBlocks (const std::string&, const Rules&, std::vector <Composite>&, Palette&, const Datetime&, int, int, const std::vector <Range>&);
|
||||
static void renderInterval (const std::string&, const Rules&, std::vector <Composite>&, const Datetime&, const Interval&, Palette&, std::map <std::string, Color>&, int, time_t&, bool);
|
||||
static void renderInterval (const std::string&, const Rules&, std::vector <Composite>&, const Datetime&, const Interval&, std::map <std::string, Color>&, int, time_t&, bool);
|
||||
std::string renderHolidays (const std::string&, const Rules&, const Interval&);
|
||||
static std::string renderSummary (const std::string&, const Rules&, const std::string&, const Interval&, const std::vector <Range>&, const std::vector <Interval>&, bool);
|
||||
|
||||
|
@ -189,7 +189,7 @@ int renderChart (
|
|||
for (auto& track : tracked)
|
||||
{
|
||||
time_t interval_work = 0;
|
||||
renderInterval (type, rules, lines, day, track, palette, tag_colors, first_hour, interval_work, ids);
|
||||
renderInterval (type, rules, lines, day, track, tag_colors, first_hour, interval_work, ids);
|
||||
work += interval_work;
|
||||
}
|
||||
}
|
||||
|
@ -497,7 +497,6 @@ static void renderInterval (
|
|||
std::vector <Composite>& lines,
|
||||
const Datetime& day,
|
||||
const Interval& track,
|
||||
Palette& palette,
|
||||
std::map <std::string, Color>& tag_colors,
|
||||
int first_hour,
|
||||
time_t& work,
|
||||
|
@ -540,13 +539,7 @@ static void renderInterval (
|
|||
if (end_offset > start_offset)
|
||||
{
|
||||
// Determine color of interval.
|
||||
Color colorTrack;
|
||||
if (track.tags ().size ())
|
||||
// TODO Instead of using the first tag, look at them all, and choose one
|
||||
// that has a color defined over any other.
|
||||
colorTrack = tag_colors [*(track.tags ().begin ())];
|
||||
else
|
||||
colorTrack = palette.next ();
|
||||
Color colorTrack = intervalColor (track, rules, tag_colors);
|
||||
|
||||
// Properly format the tags within the space.
|
||||
std::string label;
|
||||
|
|
|
@ -41,11 +41,15 @@
|
|||
Color intervalColor (
|
||||
const Interval& interval,
|
||||
const Rules& rules,
|
||||
Palette& palette)
|
||||
std::map <std::string, Color>& tag_colors)
|
||||
{
|
||||
Color c;
|
||||
std::string first_tag;
|
||||
for (auto& tag : interval.tags ())
|
||||
{
|
||||
if (first_tag == "")
|
||||
first_tag = tag;
|
||||
|
||||
std::string name = std::string ("tags.") + tag + ".color";
|
||||
if (rules.has (name))
|
||||
c.blend (Color (rules.get (name)));
|
||||
|
@ -54,7 +58,10 @@ Color intervalColor (
|
|||
if (c.nontrivial ())
|
||||
return c;
|
||||
|
||||
return palette.next ();
|
||||
if (interval.tags ().size ())
|
||||
return tag_colors[first_tag];
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -64,7 +64,7 @@ void initializeExtensions (CLI&, const Rules&, Extensions&);
|
|||
int dispatchCommand (const CLI&, Database&, Rules&, const Extensions&);
|
||||
|
||||
// helper.cpp
|
||||
Color intervalColor (const Interval&, const Rules&, Palette&);
|
||||
Color intervalColor (const Interval&, const Rules&, std::map <std::string, Color>&);
|
||||
Color tagColor (const Rules&, const std::string&);
|
||||
std::string intervalSummarize (Database&, const Rules&, const Interval&);
|
||||
bool expandIntervalHint (const std::string&, Range&);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue