superset-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ccwilli...@apache.org
Subject [incubator-superset] branch master updated: Add option for BigNumber to not start y-axis at 0 (#5552)
Date Mon, 06 Aug 2018 21:32:34 GMT
This is an automated email from the ASF dual-hosted git repository.

ccwilliams 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 aa14bac  Add option for BigNumber to not start y-axis at 0 (#5552)
aa14bac is described below

commit aa14bac5c7619e80a8a7af1b5fe1d09691b16c35
Author: Krist Wongsuphasawat <krist.wongz@gmail.com>
AuthorDate: Mon Aug 6 14:32:29 2018 -0700

    Add option for BigNumber to not start y-axis at 0 (#5552)
    
    * Add option to not start y-axis at 0
    
    * Update language to positive.
---
 superset/assets/src/explore/controls.jsx         |  8 ++++++++
 superset/assets/src/explore/visTypes.jsx         |  2 +-
 superset/assets/src/visualizations/BigNumber.jsx | 10 +++++++++-
 3 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/superset/assets/src/explore/controls.jsx b/superset/assets/src/explore/controls.jsx
index 9afba58..6405c46 100644
--- a/superset/assets/src/explore/controls.jsx
+++ b/superset/assets/src/explore/controls.jsx
@@ -1480,6 +1480,14 @@ export const controls = {
     description: t('Whether to display the trend line'),
   },
 
+  start_y_axis_at_zero: {
+    type: 'CheckboxControl',
+    label: t('Start y-axis at 0'),
+    renderTrigger: true,
+    default: true,
+    description: t('Start y-axis at zero. Uncheck to start y-axis at minimum value in the
data.'),
+  },
+
   x_axis_showminmax: {
     type: 'CheckboxControl',
     label: t('X bounds'),
diff --git a/superset/assets/src/explore/visTypes.jsx b/superset/assets/src/explore/visTypes.jsx
index df8dfbb..f9cc723 100644
--- a/superset/assets/src/explore/visTypes.jsx
+++ b/superset/assets/src/explore/visTypes.jsx
@@ -1251,7 +1251,7 @@ export const visTypes = {
         controlSetRows: [
           ['compare_lag', 'compare_suffix'],
           ['y_axis_format', null],
-          ['show_trend_line', null],
+          ['show_trend_line', 'start_y_axis_at_zero'],
         ],
       },
     ],
diff --git a/superset/assets/src/visualizations/BigNumber.jsx b/superset/assets/src/visualizations/BigNumber.jsx
index 6b3e5b7..9976579 100644
--- a/superset/assets/src/visualizations/BigNumber.jsx
+++ b/superset/assets/src/visualizations/BigNumber.jsx
@@ -53,6 +53,7 @@ const propTypes = {
   formatBigNumber: PropTypes.func,
   subheader: PropTypes.string,
   showTrendline: PropTypes.bool,
+  startYAxisAtZero: PropTypes.bool,
   trendlineData: PropTypes.array,
   mainColor: PropTypes.string,
   gradientId: PropTypes.string,
@@ -63,6 +64,7 @@ const defaultProps = {
   formatBigNumber: identity,
   subheader: '',
   showTrendline: false,
+  startYAxisAtZero: true,
   trendlineData: null,
   mainColor: brandColor,
   gradientId: '',
@@ -152,12 +154,16 @@ class BigNumberVis extends React.Component {
       subheader,
       renderTooltip,
       gradientId,
+      startYAxisAtZero,
     } = this.props;
     return (
       <XYChart
         ariaLabel={`Big number visualization ${subheader}`}
         xScale={{ type: 'timeUtc' }}
-        yScale={{ type: 'linear' }}
+        yScale={{
+          type: 'linear',
+          includeZero: startYAxisAtZero,
+        }}
         width={width}
         height={maxHeight}
         margin={CHART_MARGIN}
@@ -227,6 +233,7 @@ function adaptor(slice, payload) {
   const compareLag = Number(payload.data.compare_lag);
   const supportTrendline = formData.viz_type === 'big_number';
   const showTrendline = supportTrendline && formData.show_trend_line;
+  const startYAxisAtZero = formData.start_y_axis_at_zero;
   const formatValue = d3FormatPreset(formData.y_axis_format);
   const bigNumber = supportTrendline ? data[data.length - 1][1] : data[0][0];
 
@@ -262,6 +269,7 @@ function adaptor(slice, payload) {
       formatBigNumber={formatValue}
       subheader={formattedSubheader}
       showTrendline={showTrendline}
+      startYAxisAtZero={startYAxisAtZero}
       trendlineData={trendlineData}
       mainColor={brandColor}
       gradientId={`big_number_${containerId}`}


Mime
View raw message