-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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
add annotation option and a linear color map for heatmap viz. #3634
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -202,6 +202,7 @@ export const controls = { | |
['blue_white_yellow', 'blue/white/yellow'], | ||
['white_black', 'white/black'], | ||
['black_white', 'black/white'], | ||
['dark_blue', 'light/dark blue'], | ||
], | ||
default: 'blue_white_yellow', | ||
clearable: false, | ||
|
@@ -1086,6 +1087,14 @@ export const controls = { | |
description: t('Whether to display the legend (toggles)'), | ||
}, | ||
|
||
show_annotation: { | ||
type: 'CheckboxControl', | ||
label: t('Annotation'), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
renderTrigger: true, | ||
default: false, | ||
description: t('Whether to display the annotation (toggles)'), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'Whether to display the numerical values within the cells' |
||
}, | ||
|
||
x_axis_showminmax: { | ||
type: 'CheckboxControl', | ||
label: t('X bounds'), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -130,6 +130,25 @@ function heatmapVis(slice, payload) { | |
.attr('height', height) | ||
.style('position', 'relative'); | ||
|
||
if (fd.show_annotation) { | ||
const cells = svg.selectAll('rect') | ||
.data(data) | ||
.enter() | ||
.append('g') | ||
.attr('transform', `translate(${margin.left}, ${margin.top})`); | ||
|
||
cells.append('text') | ||
.attr('transform', | ||
function (d) { return 'translate(' + xRbScale(d.x) + ',' + yRbScale(d.y) + ')'; }) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thx! using => indeed makes it neater. |
||
.attr('y', yRbScale.rangeBand() / 2) | ||
.attr('x', xRbScale.rangeBand() / 2) | ||
.attr('text-anchor', 'middle') | ||
.attr('dy', '.35em') | ||
.text(function (d) { return valueFormatter(d.v); }) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
.attr('font-size', Math.min(yRbScale.rangeBand(), xRbScale.rangeBand()) / 3 + 'px') | ||
.attr('fill', function (d) { return d.v >= payload.data.extents[1] / 2 ? 'white' : 'black'; }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. arrow function here too |
||
} | ||
|
||
if (fd.show_legend) { | ||
const legendScaler = colorScalerFactory( | ||
fd.linear_color_scheme, null, null, payload.data.extents); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The term annotation is already used for other purposes, can we just call this
show_values
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
noted