You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ma...@apache.org on 2017/08/01 17:25:54 UTC
[incubator-superset] branch master updated: [explore] nvd3 sort
values in rich tooltip (#3197)
This is an automated email from the ASF dual-hosted git repository.
maximebeauchemin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
The following commit(s) were added to refs/heads/master by this push:
new 3b12925 [explore] nvd3 sort values in rich tooltip (#3197)
3b12925 is described below
commit 3b129253a322ea8749a296bc7a3b3c75b93d060c
Author: Maxime Beauchemin <ma...@gmail.com>
AuthorDate: Tue Aug 1 10:25:52 2017 -0700
[explore] nvd3 sort values in rich tooltip (#3197)
---
superset/assets/stylesheets/superset.css | 2 +-
superset/assets/visualizations/nvd3_vis.js | 31 +++++++++++++++++++++++++++---
2 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/superset/assets/stylesheets/superset.css b/superset/assets/stylesheets/superset.css
index 2cbe27f..ef12c7e 100644
--- a/superset/assets/stylesheets/superset.css
+++ b/superset/assets/stylesheets/superset.css
@@ -13,7 +13,7 @@ body {
}
.emph {
- font-weight: bold;
+ font-weight: bold !important;
}
.alert.alert-danger > .debugger {
diff --git a/superset/assets/visualizations/nvd3_vis.js b/superset/assets/visualizations/nvd3_vis.js
index 1f34d9b..2134294 100644
--- a/superset/assets/visualizations/nvd3_vis.js
+++ b/superset/assets/visualizations/nvd3_vis.js
@@ -298,9 +298,6 @@ function nvd3Vis(slice, payload) {
chart.height(height);
slice.container.css('height', height + 'px');
- if ((vizType === 'line' || vizType === 'area') && fd.rich_tooltip) {
- chart.useInteractiveGuideline(true);
- }
if (chart.forceY &&
fd.y_axis_bounds &&
(fd.y_axis_bounds[0] !== null || fd.y_axis_bounds[1] !== null)) {
@@ -342,6 +339,34 @@ function nvd3Vis(slice, payload) {
if (vizType !== 'bullet') {
chart.color(d => category21(d[colorKey]));
}
+ if ((vizType === 'line' || vizType === 'area') && fd.rich_tooltip) {
+ chart.useInteractiveGuideline(true);
+ if (vizType === 'line') {
+ // Custom sorted tooltip
+ chart.interactiveLayer.tooltip.contentGenerator((d) => {
+ let tooltip = '';
+ tooltip += "<table><thead><tr><td colspan='3'>"
+ + `<strong class='x-value'>${xAxisFormatter(d.value)}</strong>`
+ + '</td></tr></thead><tbody>';
+ d.series.sort((a, b) => a.value >= b.value ? -1 : 1);
+ d.series.forEach((series) => {
+ tooltip += (
+ `<tr class="${series.highlight ? 'emph' : ''}">` +
+ `<td class='legend-color-guide' style="opacity: ${series.highlight ? '1' : '0.75'};"">` +
+ '<div ' +
+ `style="border: 2px solid ${series.highlight ? 'black' : 'transparent'}; background-color: ${series.color};"` +
+ '></div>' +
+ '</td>' +
+ `<td>${series.key}</td>` +
+ `<td>${yAxisFormatter(series.value)}</td>` +
+ '</tr>'
+ );
+ });
+ tooltip += '</tbody></table>';
+ return tooltip;
+ });
+ }
+ }
if (fd.x_axis_label && fd.x_axis_label !== '' && chart.xAxis) {
let distance = 0;
--
To stop receiving notification emails like this one, please contact
['"commits@superset.apache.org" <co...@superset.apache.org>'].