Skip to content
This repository has been archived by the owner on Jun 25, 2020. It is now read-only.

feat: add properties for font sizing #10

Merged
merged 4 commits into from
Mar 12, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@superset-ui/legacy-preset-chart-big-number",
"version": "0.10.0",
khtruong marked this conversation as resolved.
Show resolved Hide resolved
"version": "0.11.0",
"description": "Superset Legacy Chart - Big Number",
"sideEffects": false,
"main": "lib/index.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,8 @@ const CHART_MARGIN = {
};

const PROPORTION = {
HEADER: 0.4,
SUBHEADER: 0.14,
HEADER_WITH_TRENDLINE: 0.3,
SUBHEADER_WITH_TRENDLINE: 0.125,
HEADER: 0.3,
SUBHEADER: 0.125,
TRENDLINE: 0.3,
};

Expand Down Expand Up @@ -78,7 +76,9 @@ const propTypes = {
height: PropTypes.number.isRequired,
bigNumber: PropTypes.number.isRequired,
formatBigNumber: PropTypes.func,
bigNumFontSize: PropTypes.number,
subheader: PropTypes.string,
subheaderFontSize: PropTypes.number,
showTrendLine: PropTypes.bool,
startYAxisAtZero: PropTypes.bool,
trendLineData: PropTypes.array,
Expand All @@ -88,7 +88,9 @@ const propTypes = {
const defaultProps = {
className: '',
formatBigNumber: identity,
bigNumFontSize: PROPORTION.HEADER,
subheader: '',
subheaderFontSize: PROPORTION.SUBHEADER,
showTrendLine: false,
startYAxisAtZero: true,
trendLineData: null,
Expand Down Expand Up @@ -217,7 +219,7 @@ class BigNumberVis extends React.PureComponent {
}

render() {
const { showTrendLine, height } = this.props;
const { showTrendLine, height, bigNumFontSize, subheaderFontSize } = this.props;
const className = this.getClassName();

if (showTrendLine) {
Expand All @@ -227,8 +229,8 @@ class BigNumberVis extends React.PureComponent {
return (
<div className={className}>
<div className="text-container" style={{ height: allTextHeight }}>
{this.renderHeader(Math.ceil(PROPORTION.HEADER_WITH_TRENDLINE * height))}
{this.renderSubheader(Math.ceil(PROPORTION.SUBHEADER_WITH_TRENDLINE * height))}
{this.renderHeader(Math.ceil(bigNumFontSize * height))}
{this.renderSubheader(Math.ceil(subheaderFontSize * height))}
</div>
{this.renderTrendline(chartHeight)}
</div>
Expand All @@ -237,8 +239,8 @@ class BigNumberVis extends React.PureComponent {

return (
<div className={className} style={{ height }}>
{this.renderHeader(Math.ceil(PROPORTION.HEADER * height))}
{this.renderSubheader(Math.ceil(PROPORTION.SUBHEADER * height))}
{this.renderHeader(Math.ceil(bigNumFontSize * height))}
{this.renderSubheader(Math.ceil(subheaderFontSize * height))}
</div>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export default function transformProps(chartProps) {
colorPicker,
compareLag: compareLagInput,
compareSuffix = '',
bigNumFontSize,
subheaderFontSize,
metric,
showTrendLine,
startYAxisAtZero,
Expand Down Expand Up @@ -88,6 +90,8 @@ export default function transformProps(chartProps) {
bigNumber,
className,
formatBigNumber: formatValue,
bigNumFontSize,
subheaderFontSize,
mainColor,
renderTooltip: renderTooltipFactory(formatValue),
showTrendLine: supportAndShowTrendLine,
Expand Down