Skip to content
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

Add tooltips for geom_curve() #1054

Merged
merged 3 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix SvgElementHelper#createLine()/createCurve() methods: return vis…
…ible geometry (after paddings applying).
  • Loading branch information
OLarionova-HORIS committed Mar 21, 2024
commit 4062d85b032a5d5ed31977dfb57478b64ceb8ae5
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import org.jetbrains.letsPlot.core.plot.base.geom.util.TargetCollectorHelper
import org.jetbrains.letsPlot.core.plot.base.render.LegendKeyElementFactory
import org.jetbrains.letsPlot.core.plot.base.render.SvgRoot
import org.jetbrains.letsPlot.datamodel.svg.dom.SvgPathDataBuilder
import kotlin.math.max

class CurveGeom : GeomBase() {

Expand Down Expand Up @@ -53,22 +52,14 @@ class CurveGeom : GeomBase() {
// Create curve geometry
// inverse angle because of using client coordinates
val (svg) = svgElementHelper.createCurve(start, end, curvature, -angle, ncp, p) ?: continue

root.add(svg)
}

// add tooltips
for (p in aesthetics.dataPoints()) {
val start = p.toLocation(Aes.X, Aes.Y) ?: continue
val end = p.toLocation(Aes.XEND, Aes.YEND) ?: continue

// Add tooltips
val (_, geometry) = svgElementHelper
.noSvg()
.createCurve(start, end, curvature, -angle, ncp = max(ncp, 15), p) ?: continue

val geometryAfterPadding = svgElementHelper.padLineString(geometry, p)
tooltipHelper.addLine(geometryAfterPadding, p)
.createCurve(start, end, curvature, -angle, ncp = 15, p) ?: continue
tooltipHelper.addLine(geometry, p)
}

}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ open class GeomHelper(
}


fun padLineString(lineString: List<DoubleVector>, p: DataPointAesthetics): List<DoubleVector> {
private fun padLineString(lineString: List<DoubleVector>, p: DataPointAesthetics): List<DoubleVector> {
val startPadding = arrowPadding(p, atStart = true) + mySpacer + AesScaling.targetStartSize(p)
val endPadding = arrowPadding(p, atStart = false) + mySpacer + AesScaling.targetEndSize(p)

Expand Down