-
Notifications
You must be signed in to change notification settings - Fork 4
Fix/minor bugs #1938
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
base: main
Are you sure you want to change the base?
Fix/minor bugs #1938
Changes from all commits
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 |
---|---|---|
|
@@ -10,7 +10,7 @@ import { useChartState } from "@/charts/shared/chart-state"; | |
import { useChartTheme } from "@/charts/shared/use-chart-theme"; | ||
import { OpenMetadataPanelWrapper } from "@/components/metadata-panel"; | ||
import { theme } from "@/themes/federal"; | ||
import { getTextWidth } from "@/utils/get-text-width"; | ||
import { getTextHeight, getTextWidth } from "@/utils/get-text-width"; | ||
import { useAxisTitleAdjustments } from "@/utils/use-axis-title-adjustments"; | ||
|
||
import { TITLE_VPADDING } from "./combo-line-container"; | ||
|
@@ -65,6 +65,9 @@ export const AxisHeightLinearDual = (props: AxisHeightLinearDualProps) => { | |
TITLE_HPADDING * (isOverlapping ? Math.floor(overlapAmount) : 2); | ||
|
||
const titleWidth = isOverlapping ? axisTitleWidth / overlapAmount : "auto"; | ||
const axisLabelHeight = getTextHeight(axisTitle, { | ||
fontSize: axisLabelFontSize, | ||
}); | ||
|
||
return ( | ||
<> | ||
|
@@ -73,8 +76,8 @@ export const AxisHeightLinearDual = (props: AxisHeightLinearDualProps) => { | |
width={axisTitleWidth + TITLE_HPADDING * 2} | ||
height={ | ||
(isOverlapping | ||
? axisLabelFontSize * Math.ceil(overlapAmount) + TITLE_VPADDING | ||
: axisLabelFontSize + TITLE_VPADDING) * | ||
? axisLabelHeight * Math.ceil(overlapAmount) + TITLE_VPADDING | ||
: axisLabelHeight + TITLE_VPADDING) * | ||
2 + | ||
TOP_MARGIN | ||
Comment on lines
78
to
82
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. If we add 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. @bprusinowski I will try to refactor it, I have an Idea... 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. 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. But with this we don't need to know the number of lines, as the text would naturally wrap inside the measurement container so we get correct height back, right? 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. the text is within a 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. Yes, but here I was thinking about getTextHeight method - the flow would be:
I don't see a reason to get number of lines of the text, did I misunderstand something? 🥹 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. aha yeah, no I meant that yes the getTextHeight returns the wrong number, if its 4 lines it returns f.e 45 instead of f.e 60, or in the image specifically it returns 45 for the one on the right while the one on the left is 30 even tho it should technically be 60, it always takes the max height of both labels and then uses the largest one, however this doesn't seem to work properly. @bprusinowski here is the main logic: export const useDualAxisTitleAdjustments = ({
leftAxisTitle,
rightAxisTitle,
containerWidth,
fontSize = TICK_FONT_SIZE,
}: useDualAxisTitleAdjustmentsProps): AxisTitleAdjustments => {
const axisTitleWidthLeft =
getTextWidth(leftAxisTitle, { fontSize }) + TICK_PADDING;
const axisTitleWidthRight =
getTextWidth(rightAxisTitle, { fontSize }) + TICK_PADDING;
const axisTitleHeightLeft = getTextHeight(leftAxisTitle, {
fontSize,
width: containerWidth / 2,
lineHeight: "15px",
});
const axisTitleHeightRight = getTextHeight(rightAxisTitle, {
fontSize,
width: containerWidth / 2,
lineHeight: "15px",
});
const maxAxisLabelHeight = Math.max(
axisTitleHeightRight,
axisTitleHeightLeft
);
const isOverlapping =
axisTitleWidthLeft + axisTitleWidthRight > containerWidth;
const overlapAmount =
(axisTitleWidthLeft + axisTitleWidthRight) / containerWidth;
const axisTitleAdjustment = maxAxisLabelHeight + TITLE_VPADDING * 2;
console.log(axisTitleHeightLeft, axisTitleHeightRight);
const topMarginAxisTitleAdjustment = 60 + axisTitleAdjustment;
return {
axisLabelHeight: maxAxisLabelHeight,
axisTitleAdjustment,
topMarginAxisTitleAdjustment,
isOverlapping,
overlapAmount,
};
}; |
||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.