Skip to content

Commit

Permalink
fix: removed the tooltip feature for the IO chart (#2080)
Browse files Browse the repository at this point in the history
  • Loading branch information
exelban committed Sep 6, 2024
1 parent c44f089 commit 1667879
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
14 changes: 13 additions & 1 deletion Kit/plugins/Charts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ public class LineChartView: NSView {
public var color: NSColor
public var suffix: String
public var toolTipFunc: ((DoubleValue) -> String)?
public var isTooltipEnabled: Bool = true

private var scale: Scale
private var fixedScale: Double
Expand Down Expand Up @@ -255,7 +256,7 @@ public class LineChartView: NSView {
NSAttributedString.init(string: str, attributes: stringAttributes).draw(with: rect)
}

if let p = self.cursor, let over = list.first(where: { $0.point.x >= p.x }), let under = list.last(where: { $0.point.x <= p.x }) {
if self.isTooltipEnabled, let p = self.cursor, let over = list.first(where: { $0.point.x >= p.x }), let under = list.last(where: { $0.point.x <= p.x }) {
guard p.y <= height else { return }

let diffOver = over.point.x - p.x
Expand Down Expand Up @@ -349,30 +350,36 @@ public class LineChartView: NSView {
}

public override func mouseEntered(with event: NSEvent) {
guard self.isTooltipEnabled else { return }
self.cursor = convert(event.locationInWindow, from: nil)
self.needsDisplay = true
}

public override func mouseMoved(with event: NSEvent) {
guard self.isTooltipEnabled else { return }
self.cursor = convert(event.locationInWindow, from: nil)
self.needsDisplay = true
}

public override func mouseDragged(with event: NSEvent) {
guard self.isTooltipEnabled else { return }
self.cursor = convert(event.locationInWindow, from: nil)
self.needsDisplay = true
}

public override func mouseExited(with event: NSEvent) {
guard self.isTooltipEnabled else { return }
self.cursor = nil
self.needsDisplay = true
}

public override func mouseDown(with: NSEvent) {
guard self.isTooltipEnabled else { return }
self.shadowPoints = self.points
self.stop = true
}
public override func mouseUp(with: NSEvent) {
guard self.isTooltipEnabled else { return }
self.stop = false
}
}
Expand Down Expand Up @@ -458,6 +465,11 @@ public class NetworkChartView: NSView {
self.outChart.color = outColor
}
}

public func setTooltipState(_ newState: Bool) {
self.inChart.isTooltipEnabled = newState
self.outChart.isTooltipEnabled = newState
}
}

public class PieChartView: NSView {
Expand Down
1 change: 1 addition & 0 deletions Modules/Disk/popup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,7 @@ internal class ChartView: NSStackView {
width: self.frame.width,
height: self.frame.height - 2
), num: 120, reversedOrder: self.reverseOrder, outColor: self.writeColor, inColor: self.readColor)
chart.setTooltipState(false)
self.chart = chart

self.addArrangedSubview(chart)
Expand Down

0 comments on commit 1667879

Please sign in to comment.