Skip to content

Commit

Permalink
fix: variable naming
Browse files Browse the repository at this point in the history
  • Loading branch information
nickofthyme committed Apr 28, 2020
1 parent 96784a3 commit 90fc234
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
5 changes: 3 additions & 2 deletions src/chart_types/xy_chart/annotations/annotation_tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* under the License. */

import { Dimensions } from '../../../utils/dimensions';
import { Position } from '../../../utils/commons';

/** @internal */
export function getFinalAnnotationTooltipPosition(
Expand All @@ -36,12 +37,12 @@ export function getFinalAnnotationTooltipPosition(
anchor: 'left' | 'right';
} {
let left = 0;
let anchor: 'left' | 'right' = 'left' as 'left';
let anchor: Position = Position.Left;

const annotationXOffset = window.pageXOffset + container.left + chartDimensions.left + tooltipAnchor.left;
if (chartDimensions.left + tooltipAnchor.left + portalWidth + padding >= container.width) {
left = annotationXOffset - portalWidth - padding;
anchor = 'right' as 'right';
anchor = Position.Right;
} else {
left = annotationXOffset + padding;
}
Expand Down
6 changes: 3 additions & 3 deletions src/chart_types/xy_chart/renderer/dom/annotation_tooltips.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class AnnotationTooltipComponent extends React.Component<AnnotationTooltipProps>
*
* @unit px
*/
static maxWidth = 256;
static MAX_WIDTH = 256;

constructor(props: AnnotationTooltipProps) {
super(props);
Expand All @@ -77,7 +77,7 @@ class AnnotationTooltipComponent extends React.Component<AnnotationTooltipProps>
} else {
this.portalNode = document.createElement('div');
this.portalNode.id = ANNOTATION_CONTAINER_ID;
this.portalNode.style.width = `${AnnotationTooltipComponent.maxWidth}px`;
this.portalNode.style.width = `${AnnotationTooltipComponent.MAX_WIDTH}px`;
document.body.appendChild(this.portalNode);
}
}
Expand All @@ -103,7 +103,7 @@ class AnnotationTooltipComponent extends React.Component<AnnotationTooltipProps>
}

const chartContainerBBox = chartContainerRef.current.getBoundingClientRect();
const width = Math.min(AnnotationTooltipComponent.maxWidth, chartContainerBBox.width * 0.7);
const width = Math.min(AnnotationTooltipComponent.MAX_WIDTH, chartContainerBBox.width * 0.7);
this.portalNode.style.width = `${width}px`;
const tooltipBBox = this.tooltipRef.current.getBoundingClientRect();
const tooltipStyle = getFinalAnnotationTooltipPosition(
Expand Down
6 changes: 3 additions & 3 deletions src/components/tooltip/tooltip_portal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class TooltipPortalComponent extends React.Component<TooltipPortalProps> {
*
* @unit px
*/
static maxWidth = 256;
static MAX_WIDTH = 256;
portalNode: HTMLDivElement | null = null;
tooltipRef: React.RefObject<HTMLDivElement>;

Expand All @@ -64,7 +64,7 @@ class TooltipPortalComponent extends React.Component<TooltipPortalProps> {
} else {
this.portalNode = document.createElement('div');
this.portalNode.id = 'echTooltipContainerPortal';
this.portalNode.style.width = `${TooltipPortalComponent.maxWidth}px`;
this.portalNode.style.width = `${TooltipPortalComponent.MAX_WIDTH}px`;
document.body.appendChild(this.portalNode);
}
}
Expand All @@ -83,7 +83,7 @@ class TooltipPortalComponent extends React.Component<TooltipPortalProps> {

const chartContainerBBox = chartContainerRef.current.getBoundingClientRect();
const tooltipBBox = this.tooltipRef.current.getBoundingClientRect();
const width = Math.min(TooltipPortalComponent.maxWidth, chartContainerBBox.width * 0.7);
const width = Math.min(TooltipPortalComponent.MAX_WIDTH, chartContainerBBox.width * 0.7);
this.portalNode.style.width = `${width}px`;
const tooltipStyle = getFinalTooltipPosition(chartContainerBBox, tooltipBBox, width, position);

Expand Down

0 comments on commit 90fc234

Please sign in to comment.