Skip to content

Commit 437a882

Browse files
feat: Add custom hovertext for editor summary and project
1 parent ebfedf7 commit 437a882

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed

src/components/SelectableVisualization.vue

+6
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ div
3131
div(v-if="type == 'top_editor_files'")
3232
aw-summary(:fields="$store.state.activity.editor.top_files",
3333
:namefunc="top_editor_files_namefunc",
34+
:hoverfunc="top_editor_files_hoverfunc",
3435
:colorfunc="e => e.data.language",
3536
with_limit)
3637
div(v-if="type == 'top_editor_languages'")
@@ -41,6 +42,7 @@ div
4142
div(v-if="type == 'top_editor_projects'")
4243
aw-summary(:fields="$store.state.activity.editor.top_projects",
4344
:namefunc="top_editor_projects_namefunc",
45+
:hoverfunc="top_editor_projects_hoverfunc",
4446
:colorfunc="e => e.data.language",
4547
with_limit)
4648
div(v-if="type == 'top_categories'")
@@ -103,13 +105,17 @@ export default {
103105
f = f[f.length - 1];
104106
return f;
105107
},
108+
top_editor_files_hoverfunc: e => {
109+
return 'file: ' + e.data.file + '\n' + 'project: ' + e.data.project;
110+
},
106111
// TODO: Move this function somewhere else
107112
top_editor_projects_namefunc: e => {
108113
let f = e.data.project || '';
109114
f = f.split('/');
110115
f = f[f.length - 1];
111116
return f;
112117
},
118+
top_editor_projects_hoverfunc: e => e.data.project,
113119
};
114120
},
115121
computed: {

src/views/activity/ActivityEditor.vue

+6
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ div.mt-3
1414
h5 Top file activity
1515
aw-summary(:fields="$store.state.activity.editor.top_files",
1616
:namefunc="top_editor_files_namefunc",
17+
:hoverfunc="top_editor_files_hoverfunc",
1718
:colorfunc="top_editor_files_colorfunc", with_limit)
1819

1920
div.col-md-4
@@ -26,6 +27,7 @@ div.mt-3
2627
h5 Top project activity
2728
aw-summary(:fields="$store.state.activity.editor.top_projects",
2829
:namefunc="top_editor_projects_namefunc",
30+
:hoverfunc="top_editor_projects_hoverfunc",
2931
:colorfunc="top_editor_projects_colorfunc", with_limit)
3032
br
3133
</template>
@@ -49,6 +51,9 @@ export default {
4951
f = f[f.length - 1];
5052
return f;
5153
},
54+
top_editor_files_hoverfunc: e => {
55+
return 'file: ' + e.data.file + '\n' + 'project: ' + e.data.project;
56+
},
5257
top_editor_files_colorfunc: e => e.data.language,
5358
5459
top_editor_languages_namefunc: e => e.data.language,
@@ -60,6 +65,7 @@ export default {
6065
f = f[f.length - 1];
6166
return f;
6267
},
68+
top_editor_projects_hoverfunc: e => e.data.project,
6369
top_editor_projects_colorfunc: e => e.data.project,
6470
};
6571
},

src/visualizations/Summary.vue

+5
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ export default {
2525
props: {
2626
fields: Array,
2727
namefunc: Function,
28+
hoverfunc: {
29+
type: Function,
30+
default: null, // If not set we will default to namefunc
31+
},
2832
colorfunc: Function,
2933
limit: {
3034
type: Number,
@@ -59,6 +63,7 @@ export default {
5963
el,
6064
this.fields.slice(0, this.limit_),
6165
this.namefunc,
66+
this.hoverfunc,
6267
this.colorfunc
6368
);
6469
} else {

src/visualizations/summary.js

+11-3
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ function update(container, apps) {
7979
eg.select('rect').style('fill', appcolor);
8080
});
8181

82-
eg.append('title').text(app.name + '\n' + seconds_to_duration(app.duration));
82+
eg.append('title').text(app.hovertext + '\n' + seconds_to_duration(app.duration));
8383

8484
// Color box background
8585
eg.append('rect')
@@ -118,9 +118,17 @@ function update(container, apps) {
118118
return container;
119119
}
120120

121-
function updateSummedEvents(container, summedEvents, titleKeyFunc, colorKeyFunc) {
121+
function updateSummedEvents(container, summedEvents, titleKeyFunc, hoverKeyFunc, colorKeyFunc) {
122+
if (hoverKeyFunc == null) {
123+
hoverKeyFunc = titleKeyFunc;
124+
}
122125
const apps = _.map(summedEvents, e => {
123-
return { name: titleKeyFunc(e), duration: e.duration, colorKey: colorKeyFunc(e) };
126+
return {
127+
name: titleKeyFunc(e),
128+
hovertext: hoverKeyFunc(e),
129+
duration: e.duration,
130+
colorKey: colorKeyFunc(e),
131+
};
124132
});
125133
update(container, apps);
126134
}

0 commit comments

Comments
 (0)