Skip to content
This repository was archived by the owner on Nov 3, 2023. It is now read-only.

Cherry-picks: Allow users to choose color for BigNumber #102

Merged
merged 2 commits into from
Aug 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions superset/assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"classnames": "^2.2.5",
"d3": "^3.5.17",
"d3-cloud": "^1.2.1",
"d3-color": "^1.2.0",
"d3-hierarchy": "^1.1.5",
"d3-sankey": "^0.4.2",
"d3-svg-legend": "^1.x",
Expand Down
1 change: 1 addition & 0 deletions superset/assets/src/explore/visTypes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1242,6 +1242,7 @@ export const visTypes = {
['compare_lag', 'compare_suffix'],
['y_axis_format', null],
['show_trend_line', 'start_y_axis_at_zero'],
['color_picker', null],
],
},
],
Expand Down
8 changes: 7 additions & 1 deletion superset/assets/src/visualizations/BigNumber.jsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -236,6 +237,11 @@ function adaptor(slice, payload) {
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];
let userColor;
if (formData.color_picker) {
const { r, g, b } = formData.color_picker;
userColor = color.rgb(r, g, b).hex();
}

let percentChange = 0;
let formattedSubheader = subheader;
Expand Down Expand Up @@ -271,7 +277,7 @@ function adaptor(slice, payload) {
showTrendline={showTrendline}
startYAxisAtZero={startYAxisAtZero}
trendlineData={trendlineData}
mainColor={brandColor}
mainColor={userColor}
gradientId={`big_number_${containerId}`}
renderTooltip={renderTooltipFactory(formatValue)}
/>,
Expand Down
3 changes: 2 additions & 1 deletion superset/assets/src/visualizations/HorizonChart.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
margin: 0px;
}

.horizon-row span {
.horizon-row span.title {
position: absolute;
color: #333;
font-size: 0.8em;
margin: 0;
text-shadow: 1px 1px rgba(255, 255, 255, 0.75);
}
2 changes: 1 addition & 1 deletion superset/assets/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3248,7 +3248,7 @@ d3-collection@1:
version "1.0.4"
resolved "https://registry.yarnpkg.com/d3-collection/-/d3-collection-1.0.4.tgz#342dfd12837c90974f33f1cc0a785aea570dcdc2"

d3-color@1:
d3-color@1, d3-color@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/d3-color/-/d3-color-1.2.0.tgz#d1ea19db5859c86854586276ec892cf93148459a"

Expand Down