From beeec92b835a22a515c970fe5f48630f96c82b65 Mon Sep 17 00:00:00 2001 From: Andrew Stein Date: Mon, 1 Oct 2018 07:18:16 -0400 Subject: [PATCH] Fixed hover tooltips on y_scatter charts --- .../perspective-viewer-highcharts/src/js/config.js | 11 ++++++++++- .../perspective-viewer-highcharts/src/js/tooltip.js | 8 ++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/packages/perspective-viewer-highcharts/src/js/config.js b/packages/perspective-viewer-highcharts/src/js/config.js index 613e8f4fe0..b7aa5e5e8c 100644 --- a/packages/perspective-viewer-highcharts/src/js/config.js +++ b/packages/perspective-viewer-highcharts/src/js/config.js @@ -87,25 +87,34 @@ export function set_category_axis(config, axis, type, top) { export function default_config(aggregates, mode) { let type = "scatter"; + let hover_type = "xy"; if (mode === "y_line") { + hover_type = "y"; type = "line"; } else if (mode === "y_area") { + hover_type = "y"; type = "area"; } else if (mode === "y_scatter") { + hover_type = "y"; type = "scatter"; } else if (mode.indexOf("bar") > -1) { + hover_type = "y"; type = "column"; } else if (mode == "treemap") { + hover_type = "hierarchy"; type = "treemap"; } else if (mode == "sunburst") { + hover_type = "hierarchy"; type = "sunburst"; } else if (mode === "scatter") { + hover_type = "xy"; if (aggregates.length <= 3) { type = "scatter"; } else { type = "bubble"; } } else if (mode === "heatmap") { + hover_type = "xyz"; type = "heatmap"; } @@ -217,7 +226,7 @@ export function default_config(aggregates, mode) { that._view .schema() .then(schema => { - let tooltip_text = tooltip.format_tooltip(this, type, schema, axis_titles, pivot_titles); + let tooltip_text = tooltip.format_tooltip(this, hover_type, schema, axis_titles, pivot_titles); highcharts_tooltip.label.attr({ text: tooltip_text }); diff --git a/packages/perspective-viewer-highcharts/src/js/tooltip.js b/packages/perspective-viewer-highcharts/src/js/tooltip.js index 7a7041efc5..cd48b65549 100644 --- a/packages/perspective-viewer-highcharts/src/js/tooltip.js +++ b/packages/perspective-viewer-highcharts/src/js/tooltip.js @@ -14,7 +14,7 @@ export function format_tooltip(context, type, schema, axis_titles, pivot_titles) const has_row_pivot = row_pivot_titles.length > 0, has_column_pivot = column_pivot_titles.length > 0; - if (type === "area" || type === "line" || type === "column") { + if (type === "y") { // pivots cannot be type-mapped let row_pivot_text = "", column_pivot_text = ""; @@ -35,7 +35,7 @@ export function format_tooltip(context, type, schema, axis_titles, pivot_titles) return `${row_pivot_text} ${column_pivot_text} ${axis_title}: ${format_value(context.y, axis_type)}`; - } else if (type === "scatter" || type === "bubble") { + } else if (type === "xy") { const has_x_values = value_exists(axis_titles[0]), has_y_values = value_exists(axis_titles[1]), has_z_values = value_exists(axis_titles[2]), @@ -86,9 +86,9 @@ export function format_tooltip(context, type, schema, axis_titles, pivot_titles) const tooltip_text = [row_pivot_text, column_pivot_text, x_text, y_text, z_text, w_text]; return tooltip_text.join(""); - } else if (type === "heatmap") { + } else if (type === "xyz") { return `${format_value(context.point.value)}`; - } else if (type === "treemap" || type === "sunburst") { + } else if (type === "hierarchy") { return `${context.point.id}: ${format_value(context.x)}`; }