Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow users to select color for big number #5694

Merged
merged 8 commits into from
Aug 22, 2018
Merged

Conversation

hughhhh
Copy link
Member

@hughhhh hughhhh commented Aug 22, 2018

Added color picker control to BigNumber Viz

big_number_colors

@kristw @williaster @mistercrunch @betodealmeida

@hughhhh hughhhh changed the title [WIP] Allow users to select color for big number Allow users to select color for big number Aug 22, 2018


export const rgbToHex = function (color) {
console.log(color);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can use d3-color instead of writing a new module

@@ -1247,6 +1247,7 @@ export const visTypes = {
['compare_lag', 'compare_suffix'],
['y_axis_format', null],
['show_trend_line', 'start_y_axis_at_zero'],
['color', null],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was surprised to see that color isn't renderTrigger: true, looks like color isn't used anywhere, but color_picker is and behaves as expected.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it has the right default of brandPrimary too.

@@ -593,3 +593,12 @@ export function hexToRGB(hex, alpha = 255) {
const b = parseInt(hex.slice(5, 7), 16);
return [r, g, b, alpha];
}


export const rgbToHex = function (color) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you meant to use rgbToHex in BigNumber.jsx

@@ -237,6 +237,11 @@ function adaptor(slice, payload) {
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) +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the function in colors.js

@codecov-io
Copy link

codecov-io commented Aug 22, 2018

Codecov Report

Merging #5694 into master will decrease coverage by 0.69%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #5694     +/-   ##
=========================================
- Coverage   63.49%   62.79%   -0.7%     
=========================================
  Files         360      361      +1     
  Lines       22934    23535    +601     
  Branches     2555     2700    +145     
=========================================
+ Hits        14562    14779    +217     
- Misses       8357     8741    +384     
  Partials       15       15
Impacted Files Coverage Δ
superset/assets/src/explore/visTypes.jsx 55.81% <ø> (-1.33%) ⬇️
superset/assets/src/visualizations/BigNumber.jsx 0% <0%> (ø) ⬆️
superset/assets/src/explore/controls.jsx 44.63% <0%> (-1.3%) ⬇️
superset/assets/src/visualizations/nvd3_vis.js 7.66% <0%> (-1.28%) ⬇️
...perset/assets/src/visualizations/directed_force.js 0% <0%> (ø) ⬆️
...et/assets/src/visualizations/deckgl/layers/arc.jsx 0% <0%> (ø) ⬆️
superset/assets/src/visualizations/Legend.jsx 0% <0%> (ø) ⬆️
...ts/src/visualizations/deckgl/layers/screengrid.jsx 0% <0%> (ø) ⬆️
...isualizations/deckgl/AnimatableDeckGLContainer.jsx 0% <0%> (ø) ⬆️
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 80e7778...4eb7eb5. Read the comment docs.

@kristw
Copy link
Contributor

kristw commented Aug 22, 2018

@hughhhh Code looks good. One question is what is the default color then? If user did not set userColor, can it default to brandColor?

@mistercrunch
Copy link
Member

@kristw it comes from color_picker, which has its default set to brand color, so we're good. https://github.com/apache/incubator-superset/blob/master/superset/assets/src/explore/controls.jsx#L241

@mistercrunch mistercrunch merged commit b92e730 into master Aug 22, 2018
@mistercrunch mistercrunch deleted the big-number-color branch August 22, 2018 17:27
kristw pushed a commit to kristw/incubator-superset that referenced this pull request Aug 27, 2018
* allow user to choose color

* add color control

* remove rgbToHex reference

* change to color picker control

* add d3-color

* remove module

* use d3-colors

* add semicolon

(cherry picked from commit b92e730)
kristw pushed a commit to kristw/incubator-superset that referenced this pull request Aug 27, 2018
* allow user to choose color

* add color control

* remove rgbToHex reference

* change to color picker control

* add d3-color

* remove module

* use d3-colors

* add semicolon

(cherry picked from commit b92e730)
wenchma pushed a commit to wenchma/incubator-superset that referenced this pull request Nov 16, 2018
* allow user to choose color

* add color control

* remove rgbToHex reference

* change to color picker control

* add d3-color

* remove module

* use d3-colors

* add semicolon
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.28.0 labels Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.28.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants