From 7158fb1e9d4883416c0c56bb2cff2ba560174bdb Mon Sep 17 00:00:00 2001 From: Yu Xiao Date: Fri, 6 Jul 2018 23:09:25 +0900 Subject: [PATCH] added a 'no_trend_line' option (#5356) * added a 'no_trend_line' option * added missing comma --- superset/assets/src/explore/controls.jsx | 8 +++++ superset/assets/src/explore/visTypes.js | 1 + .../assets/src/visualizations/big_number.js | 31 ++++++++++--------- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/superset/assets/src/explore/controls.jsx b/superset/assets/src/explore/controls.jsx index 0281fe10b..310a0b605 100644 --- a/superset/assets/src/explore/controls.jsx +++ b/superset/assets/src/explore/controls.jsx @@ -1462,6 +1462,14 @@ export const controls = { description: t('Whether to display the metric name as a title'), }, + show_trend_line: { + type: 'CheckboxControl', + label: t('Show Trend Line'), + renderTrigger: true, + default: true, + description: t('Whether to display the trend line'), + }, + x_axis_showminmax: { type: 'CheckboxControl', label: t('X bounds'), diff --git a/superset/assets/src/explore/visTypes.js b/superset/assets/src/explore/visTypes.js index b0037ec5f..e3b34e94d 100644 --- a/superset/assets/src/explore/visTypes.js +++ b/superset/assets/src/explore/visTypes.js @@ -1239,6 +1239,7 @@ export const visTypes = { controlSetRows: [ ['compare_lag', 'compare_suffix'], ['y_axis_format', null], + ['show_trend_line', null], ], }, ], diff --git a/superset/assets/src/visualizations/big_number.js b/superset/assets/src/visualizations/big_number.js index 54d87fafd..3d81c5545 100644 --- a/superset/assets/src/visualizations/big_number.js +++ b/superset/assets/src/visualizations/big_number.js @@ -93,23 +93,24 @@ function bigNumberVis(slice, payload) { if (fd.viz_type === 'big_number') { // Drawing trend line + if (fd.show_trend_line) { + g.append('path') + .attr('d', function () { + return line(data); + }) + .attr('stroke-width', 5) + .attr('opacity', 0.5) + .attr('fill', 'none') + .attr('stroke-linecap', 'round') + .attr('stroke', 'grey'); - g.append('path') - .attr('d', function () { - return line(data); - }) - .attr('stroke-width', 5) - .attr('opacity', 0.5) - .attr('fill', 'none') - .attr('stroke-linecap', 'round') - .attr('stroke', 'grey'); + g = svg.append('g') + .attr('class', 'digits') + .attr('opacity', 1); - g = svg.append('g') - .attr('class', 'digits') - .attr('opacity', 1); - - if (vCompare !== null) { - y = (height / 8) * 3; + if (vCompare !== null) { + y = (height / 8) * 3; + } } const c = scaleColor(vCompare);