@@ -4,6 +4,7 @@ import * as d3 from 'd3';
44import Color from 'color' ;
55import _ from 'lodash' ;
66
7+ import { useCategoryStore } from '~/stores/categories' ;
78import { getCategoryColorFromString } from '~/util/color' ;
89import { seconds_to_duration } from '~/util/time' ;
910import { IEvent } from '~/util/interfaces' ;
@@ -40,8 +41,9 @@ interface Entry {
4041 hovertext : string ;
4142 duration : number ;
4243 color ?: string ;
43- colorKey ?: string ;
44+ colorKey ?: string | string [ ] ;
4445 link ?: string ;
46+ category ?: string ;
4547}
4648
4749function update ( container : HTMLElement , apps : Entry [ ] ) {
@@ -69,7 +71,15 @@ function update(container: HTMLElement, apps: Entry[]) {
6971 const width = ( app . duration / longest_duration ) * 100 + '%' ;
7072 const barHeight = 46 ;
7173 const textSize = 14 ;
72- const appcolor = app . color || getCategoryColorFromString ( app . colorKey || app . name ) ;
74+
75+ let appcolor : string ;
76+ if ( Array . isArray ( app . colorKey ) ) {
77+ const categoryStore = useCategoryStore ( ) ;
78+ appcolor = categoryStore . get_category_color ( app . colorKey ) ;
79+ } else {
80+ appcolor = app . color || getCategoryColorFromString ( app . colorKey || app . name ) ;
81+ }
82+
7383 const hovercolor = Color ( appcolor ) . darken ( 0.1 ) . hex ( ) ;
7484
7585 // Add a parent <a> element if link is set
@@ -143,6 +153,7 @@ function updateSummedEvents(
143153 color : e . data [ '$color' ] ,
144154 colorKey : colorKeyFunc ( e ) ,
145155 link : linkKeyFunc ( e ) ,
156+ category : e . data [ '$category' ] ,
146157 } as Entry ;
147158 } ) ;
148159 update ( container , apps ) ;
0 commit comments