Skip to content

feat: enhance colorisation for Top Window Titles #654

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/SelectableVisualization.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ div
div(v-if="type == 'top_titles'")
aw-summary(:fields="activityStore.window.top_titles",
:namefunc="e => e.data.title",
:colorfunc="e => e.data.title",
:colorfunc="e => e.data['$category']",
with_limit)
div(v-if="type == 'top_domains'")
aw-summary(:fields="activityStore.browser.top_domains",
Expand Down Expand Up @@ -68,7 +68,7 @@ div
div(v-if="type == 'top_categories'")
aw-summary(:fields="activityStore.category.top",
:namefunc="e => e.data['$category'].join(' > ')",
:colorfunc="e => e.data['$category'].join(' > ')",
:colorfunc="e => e.data['$category']",
:linkfunc="e => '#' + $route.path + '?category=' + encodeURIComponent(e.data['$category'].join('>'))",
with_limit)
div(v-if="type == 'category_tree'")
Expand Down
15 changes: 13 additions & 2 deletions src/visualizations/summary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as d3 from 'd3';
import Color from 'color';
import _ from 'lodash';

import { useCategoryStore } from '~/stores/categories';
import { getCategoryColorFromString } from '~/util/color';
import { seconds_to_duration } from '~/util/time';
import { IEvent } from '~/util/interfaces';
Expand Down Expand Up @@ -40,8 +41,9 @@ interface Entry {
hovertext: string;
duration: number;
color?: string;
colorKey?: string;
colorKey?: string | string[];
link?: string;
category?: string;
}

function update(container: HTMLElement, apps: Entry[]) {
Expand Down Expand Up @@ -69,7 +71,15 @@ function update(container: HTMLElement, apps: Entry[]) {
const width = (app.duration / longest_duration) * 100 + '%';
const barHeight = 46;
const textSize = 14;
const appcolor = app.color || getCategoryColorFromString(app.colorKey || app.name);

let appcolor: string;
if (Array.isArray(app.colorKey)) {
const categoryStore = useCategoryStore();
appcolor = categoryStore.get_category_color(app.colorKey);
} else {
appcolor = app.color || getCategoryColorFromString(app.colorKey || app.name);
}

const hovercolor = Color(appcolor).darken(0.1).hex();

// Add a parent <a> element if link is set
Expand Down Expand Up @@ -143,6 +153,7 @@ function updateSummedEvents(
color: e.data['$color'],
colorKey: colorKeyFunc(e),
link: linkKeyFunc(e),
category: e.data['$category'],
} as Entry;
});
update(container, apps);
Expand Down