Skip to content
Draft
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
11 changes: 0 additions & 11 deletions assets/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -270,17 +270,6 @@ iframe[hidden] {
@apply cursor-default bg-gray-100 dark:bg-gray-300 pointer-events-none;
}

#chartjs-tooltip {
background-color: rgba(25 30 56);
position: absolute;
font-size: 14px;
font-style: normal;
padding: 10px 12px;
pointer-events: none;
border-radius: 5px;
z-index: 100;
}

/* This class is used for styling embedded dashboards. Do not remove. */
/* stylelint-disable */
/* prettier-ignore */
Expand Down
12 changes: 1 addition & 11 deletions assets/js/dashboard/stats/graph/graph-tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,7 @@ let tooltipRoot
export default function GraphTooltip(graphData, metric, query) {
return (context) => {
const tooltipModel = context.tooltip
const offset = document
.getElementById('main-graph-canvas')
.getBoundingClientRect()

let tooltipEl = document.getElementById('chartjs-tooltip')

if (!tooltipEl) {
Expand All @@ -116,14 +114,6 @@ export default function GraphTooltip(graphData, metric, query) {
tooltipRoot = createRoot(tooltipEl)
}

if (tooltipEl && offset && window.innerWidth < 768) {
tooltipEl.style.top =
offset.y + offset.height + window.scrollY + 15 + 'px'
tooltipEl.style.left = offset.x + 'px'
tooltipEl.style.right = null
tooltipEl.style.opacity = 1
}

if (tooltipModel.opacity === 0) {
tooltipEl.style.display = 'none'
return
Expand Down
24 changes: 15 additions & 9 deletions assets/js/dashboard/stats/graph/line-graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class LineGraph extends React.Component {
constructor(props) {
super(props)
this.regenerateChart = this.regenerateChart.bind(this)
this.repositionTooltip = this.repositionTooltip.bind(this)
this.updateWindowDimensions = this.updateWindowDimensions.bind(this)
}

Expand Down Expand Up @@ -158,25 +159,30 @@ class LineGraph extends React.Component {

repositionTooltip(e) {
const tooltipEl = document.getElementById('chartjs-tooltip')
if (tooltipEl && window.innerWidth >= 768) {
if (e.clientX > 0.66 * window.innerWidth) {
tooltipEl.style.right =
if (tooltipEl) {
if (this.chart?.canvas?.contains(e.target)) {
if (e.clientX > 0.5 * window.innerWidth) {
tooltipEl.style.right =
window.innerWidth - e.clientX + window.pageXOffset + 'px'
tooltipEl.style.left = null
tooltipEl.style.left = null
} else {
tooltipEl.style.right = null
tooltipEl.style.left = e.clientX + window.pageXOffset + 'px'
}
tooltipEl.style.top = e.clientY + window.pageYOffset + 'px'
tooltipEl.style.opacity = 1
} else {
tooltipEl.style.right = null
tooltipEl.style.left = e.clientX + window.pageXOffset + 'px'
tooltipEl.style.opacity = 0
tooltipEl.style.display = 'none'
}
tooltipEl.style.top = e.clientY + window.pageYOffset + 'px'
tooltipEl.style.opacity = 1
}
}

componentDidMount() {
if (this.props.graphData) {
this.chart = this.regenerateChart()
window.addEventListener('mousemove', this.repositionTooltip)
}
window.addEventListener('mousemove', this.repositionTooltip)
}

componentDidUpdate(prevProps) {
Expand Down
Loading