You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2018/08/06 21:32:31 UTC

[GitHub] williaster closed pull request #5552: Add option for BigNumber to not start y-axis at 0

williaster closed pull request #5552: Add option for BigNumber to not start y-axis at 0
URL: https://github.com/apache/incubator-superset/pull/5552
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/superset/assets/src/explore/controls.jsx b/superset/assets/src/explore/controls.jsx
index 42678fb876..024846a6f0 100644
--- a/superset/assets/src/explore/controls.jsx
+++ b/superset/assets/src/explore/controls.jsx
@@ -1479,6 +1479,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 df8dfbb654..f9cc723eeb 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 6b3e5b79ce..9976579adb 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}`}


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org