You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by kr...@apache.org on 2018/11/21 01:35:20 UTC
[incubator-superset] branch master updated: use same xaxis
formatter for line chart tooltip (#6412)
This is an automated email from the ASF dual-hosted git repository.
kristw 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 2916c48 use same xaxis formatter for line chart tooltip (#6412)
2916c48 is described below
commit 2916c4856721c0ec33c91ede2403a5ec90e2658a
Author: Krist Wongsuphasawat <kr...@gmail.com>
AuthorDate: Tue Nov 20 17:35:13 2018 -0800
use same xaxis formatter for line chart tooltip (#6412)
---
superset/assets/src/visualizations/nvd3/NVD3Vis.js | 2 +-
superset/assets/src/visualizations/nvd3/utils.js | 5 ++---
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/superset/assets/src/visualizations/nvd3/NVD3Vis.js b/superset/assets/src/visualizations/nvd3/NVD3Vis.js
index cdd938f..7f9788f 100644
--- a/superset/assets/src/visualizations/nvd3/NVD3Vis.js
+++ b/superset/assets/src/visualizations/nvd3/NVD3Vis.js
@@ -514,7 +514,7 @@ function nvd3Vis(element, props) {
chart.useInteractiveGuideline(true);
if (vizType === 'line') {
chart.interactiveLayer.tooltip.contentGenerator(d =>
- generateRichLineTooltipContent(d, yAxisFormatter));
+ generateRichLineTooltipContent(d, xAxisFormatter, yAxisFormatter));
}
}
diff --git a/superset/assets/src/visualizations/nvd3/utils.js b/superset/assets/src/visualizations/nvd3/utils.js
index 4940f7a..52e0c3e 100644
--- a/superset/assets/src/visualizations/nvd3/utils.js
+++ b/superset/assets/src/visualizations/nvd3/utils.js
@@ -1,7 +1,6 @@
import d3 from 'd3';
import d3tip from 'd3-tip';
import dompurify from 'dompurify';
-import { formatDateVerbose } from '../../modules/dates';
// Regexp for the label added to time shifted series
// (1 hour offset, 2 days offset, etc.)
@@ -50,10 +49,10 @@ export function drawBarValues(svg, data, stacked, axisFormat) {
// Custom sorted tooltip
// use a verbose formatter for times
-export function generateRichLineTooltipContent(d, valueFormatter) {
+export function generateRichLineTooltipContent(d, timeFormatter, valueFormatter) {
let tooltip = '';
tooltip += "<table><thead><tr><td colspan='3'>"
- + `<strong class='x-value'>${formatDateVerbose(d.value)}</strong>`
+ + `<strong class='x-value'>${timeFormatter(d.value)}</strong>`
+ '</td></tr></thead><tbody>';
d.series.sort((a, b) => a.value >= b.value ? -1 : 1);
d.series.forEach((series) => {