-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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
Changes from 3 commits
7b7285c
b6283e1
23a07ab
3a661a7
d067cee
f7d5fdb
1b3204b
4eb7eb5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you meant to use |
||
console.log(color); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oops There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can use |
||
return (color && Object.keys(color).length === 4) ? | ||
'#' + ('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) : ''; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) + | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the function in |
||
('0' + parseInt(color.g, 10).toString(16)).slice(-2) + | ||
('0' + parseInt(color.b, 10).toString(16)).slice(-2); | ||
|
||
let percentChange = 0; | ||
let formattedSubheader = subheader; | ||
|
||
|
@@ -271,7 +276,7 @@ function adaptor(slice, payload) { | |
showTrendline={showTrendline} | ||
startYAxisAtZero={startYAxisAtZero} | ||
trendlineData={trendlineData} | ||
mainColor={brandColor} | ||
mainColor={userColor} | ||
gradientId={`big_number_${containerId}`} | ||
renderTooltip={renderTooltipFactory(formatValue)} | ||
/>, | ||
|
There was a problem hiding this comment.
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 likecolor
isn't used anywhere, butcolor_picker
is and behaves as expected.There was a problem hiding this comment.
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.