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

fix: invalid margin breaking chart #102

Merged
merged 1 commit into from
May 17, 2019
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
2 changes: 1 addition & 1 deletion packages/superset-ui-preset-chart-xy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"vega-lite": "^3.1.0"
},
"peerDependencies": {
"@superset-ui/chart": "^0.10.2 || ^0.11.6",
"@superset-ui/chart": "^0.11.6",
"@superset-ui/color": "^0.10.0 || ^0.11.0",
"@superset-ui/core": "^0.10.0 || ^0.11.0",
"@superset-ui/dimension": "^0.10.4 || ^0.11.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,16 @@ export default class AxisAgent<Def extends ChannelDef<Output>, Output extends Va
gapBetweenAxisLabelAndBorder = 8,
gapBetweenTickAndTickLabel = 4,
labelAngle = this.config.labelAngle,
tickLength,
tickTextStyle,
tickLength = 8,
tickTextStyle = {},
}: {
axisTitleHeight?: number;
axisWidth: number;
gapBetweenAxisLabelAndBorder?: number;
gapBetweenTickAndTickLabel?: number;
labelAngle?: number;
tickLength: number;
tickTextStyle: CSSProperties;
tickLength?: number;
tickTextStyle?: CSSProperties;
}): {
labelAngle: number;
labelOffset: number;
Expand All @@ -127,7 +127,7 @@ export default class AxisAgent<Def extends ChannelDef<Output>, Output extends Va

const { labelOverlap, labelPadding, orient } = this.config;

const maxWidth = Math.max(...labelDimensions.map(d => d.width));
const maxWidth = Math.max(...labelDimensions.map(d => d.width), 0);

// TODO: Add other strategies: stagger, chop, wrap.
let strategyForLabelOverlap = labelOverlap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ export default class XYChartLayout {
if (typeof yEncoder.axis !== 'undefined') {
this.yLayout = yEncoder.axis.computeLayout({
axisWidth: Math.max(height - margin.top - margin.bottom),
tickLength: theme.yTickStyles.length,
// @ts-ignore
tickLength: theme.yTickStyles.length || theme.yTickStyles.tickLength,
tickTextStyle: theme.yTickStyles.label.right,
});
}
Expand All @@ -98,14 +99,16 @@ export default class XYChartLayout {
this.xLayout = xEncoder.axis.computeLayout({
axisWidth: innerWidth,
labelAngle: this.recommendXLabelAngle(xEncoder.axis.config.orient as 'top' | 'bottom'),
tickLength: theme.xTickStyles.length,
// @ts-ignore
tickLength: theme.xTickStyles.length || theme.xTickStyles.tickLength,
tickTextStyle: theme.xTickStyles.label.bottom,
});
}

const finalMargin = this.xLayout
? mergeMargin(secondMargin, this.xLayout.minMargin)
: secondMargin;

const innerHeight = Math.max(height - finalMargin.top - finalMargin.bottom, minContentHeight);

const chartWidth = Math.round(innerWidth + finalMargin.left + finalMargin.right);
Expand Down