superset-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From h...@apache.org
Subject [incubator-superset] branch big-number-color updated: use d3-colors
Date Wed, 22 Aug 2018 05:29:38 GMT
This is an automated email from the ASF dual-hosted git repository.

hugh pushed a commit to branch big-number-color
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git


The following commit(s) were added to refs/heads/big-number-color by this push:
     new 1b3204b  use d3-colors
1b3204b is described below

commit 1b3204b1157832669ed5eaac80bdba6c3ceb4ded
Author: Hugh Miles <hmiles@lyft.com>
AuthorDate: Tue Aug 21 22:29:30 2018 -0700

    use d3-colors
---
 superset/assets/src/visualizations/BigNumber.jsx | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/superset/assets/src/visualizations/BigNumber.jsx b/superset/assets/src/visualizations/BigNumber.jsx
index 3b777ff..0e36e52 100644
--- a/superset/assets/src/visualizations/BigNumber.jsx
+++ b/superset/assets/src/visualizations/BigNumber.jsx
@@ -1,6 +1,7 @@
 import React from 'react';
 import PropTypes from 'prop-types';
 import ReactDOM from 'react-dom';
+import * as color from 'd3-color'
 import { XYChart, AreaSeries, CrossHair, LinearGradient } from '@data-ui/xy-chart';
 
 import { brandColor } from '../modules/colors';
@@ -230,17 +231,14 @@ BigNumberVis.defaultProps = defaultProps;
 function adaptor(slice, payload) {
   const { formData, containerId } = slice;
   const { data, subheader, compare_suffix: compareSuffix } = payload.data;
+  const { r, g, b } = formData.color_picker;
   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];
-
-  const { color } = formData;
-  const userColor = '#' + ('0' + parseInt(color.r, 10).toString(16)).slice(-2) +
-            ('0' + parseInt(color.g, 10).toString(16)).slice(-2) +
-            ('0' + parseInt(color.b, 10).toString(16)).slice(-2);
+  const userColor = color.rgb(r, g, b).hex();
 
   let percentChange = 0;
   let formattedSubheader = subheader;


Mime
View raw message