From 28cf9887ebe6ef3ad283262b1195f0cb7f5052b5 Mon Sep 17 00:00:00 2001
From: Lucas Watkins <114666925+lucas-watkins@users.noreply.github.com>
Date: Thu, 29 Aug 2024 22:35:10 -0400
Subject: [PATCH 1/8] Add plotInset paramter to style
---
.../org/jetbrains/kotlinx/kandy/letsplot/style/CustomStyle.kt | 3 ++-
.../org/jetbrains/kotlinx/kandy/letsplot/translator/style.kt | 3 +--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/kandy-lets-plot/src/main/kotlin/org/jetbrains/kotlinx/kandy/letsplot/style/CustomStyle.kt b/kandy-lets-plot/src/main/kotlin/org/jetbrains/kotlinx/kandy/letsplot/style/CustomStyle.kt
index 35ed03bcd..71e7a8a23 100644
--- a/kandy-lets-plot/src/main/kotlin/org/jetbrains/kotlinx/kandy/letsplot/style/CustomStyle.kt
+++ b/kandy-lets-plot/src/main/kotlin/org/jetbrains/kotlinx/kandy/letsplot/style/CustomStyle.kt
@@ -355,7 +355,8 @@ public data class CustomStyle @PublishedApi internal constructor(
val panel: Panel = Panel(),
val plotCanvas: PlotCanvas = PlotCanvas(),
val strip: Strip = Strip(),
- val layerTooltips: LayerTooltips = LayerTooltips()
+ val layerTooltips: LayerTooltips = LayerTooltips(),
+ var plotInset: Any? = null
) : Style {
public fun blankAxes() {
axis.blank = true
diff --git a/kandy-lets-plot/src/main/kotlin/org/jetbrains/kotlinx/kandy/letsplot/translator/style.kt b/kandy-lets-plot/src/main/kotlin/org/jetbrains/kotlinx/kandy/letsplot/translator/style.kt
index f417f613e..ca1bea668 100644
--- a/kandy-lets-plot/src/main/kotlin/org/jetbrains/kotlinx/kandy/letsplot/translator/style.kt
+++ b/kandy-lets-plot/src/main/kotlin/org/jetbrains/kotlinx/kandy/letsplot/translator/style.kt
@@ -89,6 +89,7 @@ internal fun CustomStyle.wrap(): theme {
plotSubtitle = plotCanvas.subtitle?.wrap(),
plotTitle = plotCanvas.title?.wrap(),
plotMargin = plotCanvas.margin?.wrap(),
+ plotInset = plotInset,
stripBackground = strip.background?.wrap(),
stripText = strip.text?.wrap(),
axisTooltip = axis.tooltip.background?.wrap(),
@@ -100,8 +101,6 @@ internal fun CustomStyle.wrap(): theme {
tooltip = layerTooltips.background?.wrap(),
tooltipText = layerTooltips.text?.wrap(),
tooltipTitleText = layerTooltips.title?.wrap()
- /*
- */
)
when (val justification = this@wrap.legend.justification) {
From 8283e96440c796dc5cb084e48afdf1d23a04a680 Mon Sep 17 00:00:00 2001
From: Lucas Watkins <114666925+lucas-watkins@users.noreply.github.com>
Date: Mon, 2 Sep 2024 12:26:45 -0400
Subject: [PATCH 2/8] Refactor Inset Parameter
---
...mentalLayoutSimpleCustomStyleWithInset.svg | 536 ++++++++++++++++++
...lLayoutSimpleCustomStyleWithInset_dark.svg | 536 ++++++++++++++++++
.../kandy/letsplot/style/CustomStyle.kt | 33 +-
.../kandy/letsplot/translator/style.kt | 6 +-
.../samples/guides/quickStartGuide.kt | 22 +
5 files changed, 1129 insertions(+), 4 deletions(-)
create mode 100644 docs/images/guides/quickStartGuide/experimentalLayoutSimpleCustomStyleWithInset.svg
create mode 100644 docs/images/guides/quickStartGuide/experimentalLayoutSimpleCustomStyleWithInset_dark.svg
diff --git a/docs/images/guides/quickStartGuide/experimentalLayoutSimpleCustomStyleWithInset.svg b/docs/images/guides/quickStartGuide/experimentalLayoutSimpleCustomStyleWithInset.svg
new file mode 100644
index 000000000..6dd38a275
--- /dev/null
+++ b/docs/images/guides/quickStartGuide/experimentalLayoutSimpleCustomStyleWithInset.svg
@@ -0,0 +1,536 @@
+
\ No newline at end of file
diff --git a/docs/images/guides/quickStartGuide/experimentalLayoutSimpleCustomStyleWithInset_dark.svg b/docs/images/guides/quickStartGuide/experimentalLayoutSimpleCustomStyleWithInset_dark.svg
new file mode 100644
index 000000000..fd457d4af
--- /dev/null
+++ b/docs/images/guides/quickStartGuide/experimentalLayoutSimpleCustomStyleWithInset_dark.svg
@@ -0,0 +1,536 @@
+
\ No newline at end of file
diff --git a/kandy-lets-plot/src/main/kotlin/org/jetbrains/kotlinx/kandy/letsplot/style/CustomStyle.kt b/kandy-lets-plot/src/main/kotlin/org/jetbrains/kotlinx/kandy/letsplot/style/CustomStyle.kt
index 71e7a8a23..b5400301b 100644
--- a/kandy-lets-plot/src/main/kotlin/org/jetbrains/kotlinx/kandy/letsplot/style/CustomStyle.kt
+++ b/kandy-lets-plot/src/main/kotlin/org/jetbrains/kotlinx/kandy/letsplot/style/CustomStyle.kt
@@ -70,6 +70,33 @@ public interface WithMargin {
}
}
+public data class Inset(val top: Double, val right: Double, val bottom: Double, val left: Double) {
+ public constructor(all: Double) : this(all, all, all, all)
+
+ public constructor(vertical: Double, horizontal: Double) : this(vertical, horizontal, vertical, horizontal)
+
+ public constructor(top: Double, horizontal: Double, bottom: Double) : this(top, horizontal, bottom, horizontal)
+}
+
+public interface WithInset {
+ public var inset: Inset?
+ public fun inset(all: Double) {
+ inset = Inset(all, all, all, all)
+ }
+
+ public fun inset(vertical: Double, horizontal: Double) {
+ inset = Inset(vertical, horizontal, vertical, horizontal)
+ }
+
+ public fun inset(top: Double, horizontal: Double, bottom: Double) {
+ inset = Inset(top, horizontal, bottom, horizontal)
+ }
+
+ public fun inset(top: Double, right: Double, bottom: Double, left: Double) {
+ inset = Inset(top, right, bottom, left)
+ }
+}
+
public data class LineParameters internal constructor(
var color: Color? = null,
var width: Double? = null,
@@ -322,8 +349,9 @@ public data class PlotCanvas internal constructor(
override var title: TextParameters? = null,
var subtitle: TextParameters? = null,
var caption: TextParameters? = null,
- override var margin: Margin? = null
-) : SelfInvocationContext, WithBackground, WithTitle, WithMargin {
+ override var margin: Margin? = null,
+ override var inset: Inset? = null,
+) : SelfInvocationContext, WithBackground, WithTitle, WithMargin, WithInset {
public fun subtitle(block: TextParameters.() -> Unit) {
subtitle = TextParameters().apply(block)
}
@@ -356,7 +384,6 @@ public data class CustomStyle @PublishedApi internal constructor(
val plotCanvas: PlotCanvas = PlotCanvas(),
val strip: Strip = Strip(),
val layerTooltips: LayerTooltips = LayerTooltips(),
- var plotInset: Any? = null
) : Style {
public fun blankAxes() {
axis.blank = true
diff --git a/kandy-lets-plot/src/main/kotlin/org/jetbrains/kotlinx/kandy/letsplot/translator/style.kt b/kandy-lets-plot/src/main/kotlin/org/jetbrains/kotlinx/kandy/letsplot/translator/style.kt
index ca1bea668..33678fc35 100644
--- a/kandy-lets-plot/src/main/kotlin/org/jetbrains/kotlinx/kandy/letsplot/translator/style.kt
+++ b/kandy-lets-plot/src/main/kotlin/org/jetbrains/kotlinx/kandy/letsplot/translator/style.kt
@@ -12,6 +12,10 @@ internal fun Margin.wrap(): List {
return listOf(top, right, bottom, left)
}
+internal fun Inset.wrap(): List {
+ return listOf(top, right, bottom, left)
+}
+
internal fun LineParameters.wrap(): Map {
return elementLine(
color = color?.wrap(),
@@ -89,7 +93,7 @@ internal fun CustomStyle.wrap(): theme {
plotSubtitle = plotCanvas.subtitle?.wrap(),
plotTitle = plotCanvas.title?.wrap(),
plotMargin = plotCanvas.margin?.wrap(),
- plotInset = plotInset,
+ plotInset = plotCanvas.inset?.wrap(),
stripBackground = strip.background?.wrap(),
stripText = strip.text?.wrap(),
axisTooltip = axis.tooltip.background?.wrap(),
diff --git a/kandy-lets-plot/src/test/kotlin/org/jetbrains/kotlinx/kandy/letsplot/samples/guides/quickStartGuide.kt b/kandy-lets-plot/src/test/kotlin/org/jetbrains/kotlinx/kandy/letsplot/samples/guides/quickStartGuide.kt
index e01f4ccaa..998d1cb68 100644
--- a/kandy-lets-plot/src/test/kotlin/org/jetbrains/kotlinx/kandy/letsplot/samples/guides/quickStartGuide.kt
+++ b/kandy-lets-plot/src/test/kotlin/org/jetbrains/kotlinx/kandy/letsplot/samples/guides/quickStartGuide.kt
@@ -21,6 +21,7 @@ import org.jetbrains.kotlinx.kandy.letsplot.scales.guide.LegendType
import org.jetbrains.kotlinx.kandy.letsplot.settings.Symbol
import org.jetbrains.kotlinx.kandy.letsplot.style.LayoutParameters
import org.jetbrains.kotlinx.kandy.letsplot.style.Style
+import org.jetbrains.kotlinx.kandy.letsplot.style.Inset
import org.jetbrains.kotlinx.kandy.letsplot.tooltips.Anchor
import org.jetbrains.kotlinx.kandy.letsplot.tooltips.tooltips
import org.jetbrains.kotlinx.kandy.letsplot.tooltips.value
@@ -1011,6 +1012,27 @@ class QuickStartGuide : SampleHelper("quickStartGuide", "guides") {
.saveSample()
}
+ @Test
+ fun experimentalLayoutSimpleCustomStyleWithInset(){
+ val redLine = LayoutParameters.line(Color.RED)
+ val simpleCustomStyle = Style.createCustom {
+
+ xAxis.line(redLine)
+
+ yAxis.line {
+ color = Color.RED
+ width = 0.3
+ }
+
+ axis.ticks {
+ blank = true
+ }
+
+ plotCanvas.inset(50.0)
+ }
+ plotWithStyle(simpleCustomStyle).saveSample()
+ }
+
@Test
fun experimentalLayoutCustomStyleBlankAxes() {
// SampleStart
From 4b1e7dc911c2f70c3d1f5236d70fa851aa7b96a1 Mon Sep 17 00:00:00 2001
From: Lucas Watkins <114666925+lucas-watkins@users.noreply.github.com>
Date: Tue, 3 Sep 2024 10:03:26 -0400
Subject: [PATCH 3/8] Remove Test
---
.../samples/guides/quickStartGuide.kt | 21 -------------------
1 file changed, 21 deletions(-)
diff --git a/kandy-lets-plot/src/test/kotlin/org/jetbrains/kotlinx/kandy/letsplot/samples/guides/quickStartGuide.kt b/kandy-lets-plot/src/test/kotlin/org/jetbrains/kotlinx/kandy/letsplot/samples/guides/quickStartGuide.kt
index 998d1cb68..7c3f6009c 100644
--- a/kandy-lets-plot/src/test/kotlin/org/jetbrains/kotlinx/kandy/letsplot/samples/guides/quickStartGuide.kt
+++ b/kandy-lets-plot/src/test/kotlin/org/jetbrains/kotlinx/kandy/letsplot/samples/guides/quickStartGuide.kt
@@ -1012,27 +1012,6 @@ class QuickStartGuide : SampleHelper("quickStartGuide", "guides") {
.saveSample()
}
- @Test
- fun experimentalLayoutSimpleCustomStyleWithInset(){
- val redLine = LayoutParameters.line(Color.RED)
- val simpleCustomStyle = Style.createCustom {
-
- xAxis.line(redLine)
-
- yAxis.line {
- color = Color.RED
- width = 0.3
- }
-
- axis.ticks {
- blank = true
- }
-
- plotCanvas.inset(50.0)
- }
- plotWithStyle(simpleCustomStyle).saveSample()
- }
-
@Test
fun experimentalLayoutCustomStyleBlankAxes() {
// SampleStart
From d591296535ce41923a173d00dcac2fb0ffeda9a6 Mon Sep 17 00:00:00 2001
From: Lucas Watkins <114666925+lucas-watkins@users.noreply.github.com>
Date: Tue, 3 Sep 2024 11:31:35 -0400
Subject: [PATCH 4/8] Delete
docs/images/guides/quickStartGuide/experimentalLayoutSimpleCustomStyleWithInset.svg
---
...mentalLayoutSimpleCustomStyleWithInset.svg | 536 ------------------
1 file changed, 536 deletions(-)
delete mode 100644 docs/images/guides/quickStartGuide/experimentalLayoutSimpleCustomStyleWithInset.svg
diff --git a/docs/images/guides/quickStartGuide/experimentalLayoutSimpleCustomStyleWithInset.svg b/docs/images/guides/quickStartGuide/experimentalLayoutSimpleCustomStyleWithInset.svg
deleted file mode 100644
index 6dd38a275..000000000
--- a/docs/images/guides/quickStartGuide/experimentalLayoutSimpleCustomStyleWithInset.svg
+++ /dev/null
@@ -1,536 +0,0 @@
-
\ No newline at end of file
From a7683e85d9f532d026b570c5df5972280107ff2e Mon Sep 17 00:00:00 2001
From: Lucas Watkins <114666925+lucas-watkins@users.noreply.github.com>
Date: Tue, 3 Sep 2024 11:31:49 -0400
Subject: [PATCH 5/8] Delete
docs/images/guides/quickStartGuide/experimentalLayoutSimpleCustomStyleWithInset_dark.svg
---
...lLayoutSimpleCustomStyleWithInset_dark.svg | 536 ------------------
1 file changed, 536 deletions(-)
delete mode 100644 docs/images/guides/quickStartGuide/experimentalLayoutSimpleCustomStyleWithInset_dark.svg
diff --git a/docs/images/guides/quickStartGuide/experimentalLayoutSimpleCustomStyleWithInset_dark.svg b/docs/images/guides/quickStartGuide/experimentalLayoutSimpleCustomStyleWithInset_dark.svg
deleted file mode 100644
index fd457d4af..000000000
--- a/docs/images/guides/quickStartGuide/experimentalLayoutSimpleCustomStyleWithInset_dark.svg
+++ /dev/null
@@ -1,536 +0,0 @@
-
\ No newline at end of file
From 9c46dc136b052a28d67b67e9b9636c686512a520 Mon Sep 17 00:00:00 2001
From: Lucas Watkins <114666925+lucas-watkins@users.noreply.github.com>
Date: Tue, 3 Sep 2024 11:34:21 -0400
Subject: [PATCH 6/8] Remove unused import
---
.../org/jetbrains/kotlinx/kandy/letsplot/style/CustomStyle.kt | 2 +-
.../kotlinx/kandy/letsplot/samples/guides/quickStartGuide.kt | 1 -
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/kandy-lets-plot/src/main/kotlin/org/jetbrains/kotlinx/kandy/letsplot/style/CustomStyle.kt b/kandy-lets-plot/src/main/kotlin/org/jetbrains/kotlinx/kandy/letsplot/style/CustomStyle.kt
index b5400301b..f4c37316b 100644
--- a/kandy-lets-plot/src/main/kotlin/org/jetbrains/kotlinx/kandy/letsplot/style/CustomStyle.kt
+++ b/kandy-lets-plot/src/main/kotlin/org/jetbrains/kotlinx/kandy/letsplot/style/CustomStyle.kt
@@ -383,7 +383,7 @@ public data class CustomStyle @PublishedApi internal constructor(
val panel: Panel = Panel(),
val plotCanvas: PlotCanvas = PlotCanvas(),
val strip: Strip = Strip(),
- val layerTooltips: LayerTooltips = LayerTooltips(),
+ val layerTooltips: LayerTooltips = LayerTooltips()
) : Style {
public fun blankAxes() {
axis.blank = true
diff --git a/kandy-lets-plot/src/test/kotlin/org/jetbrains/kotlinx/kandy/letsplot/samples/guides/quickStartGuide.kt b/kandy-lets-plot/src/test/kotlin/org/jetbrains/kotlinx/kandy/letsplot/samples/guides/quickStartGuide.kt
index 7c3f6009c..e01f4ccaa 100644
--- a/kandy-lets-plot/src/test/kotlin/org/jetbrains/kotlinx/kandy/letsplot/samples/guides/quickStartGuide.kt
+++ b/kandy-lets-plot/src/test/kotlin/org/jetbrains/kotlinx/kandy/letsplot/samples/guides/quickStartGuide.kt
@@ -21,7 +21,6 @@ import org.jetbrains.kotlinx.kandy.letsplot.scales.guide.LegendType
import org.jetbrains.kotlinx.kandy.letsplot.settings.Symbol
import org.jetbrains.kotlinx.kandy.letsplot.style.LayoutParameters
import org.jetbrains.kotlinx.kandy.letsplot.style.Style
-import org.jetbrains.kotlinx.kandy.letsplot.style.Inset
import org.jetbrains.kotlinx.kandy.letsplot.tooltips.Anchor
import org.jetbrains.kotlinx.kandy.letsplot.tooltips.tooltips
import org.jetbrains.kotlinx.kandy.letsplot.tooltips.value
From affc37f3240e403ebc4b2c4133b19bced80e79ae Mon Sep 17 00:00:00 2001
From: Lucas Watkins <114666925+lucas-watkins@users.noreply.github.com>
Date: Tue, 3 Sep 2024 17:55:30 -0400
Subject: [PATCH 7/8] Refactor class
---
.../jetbrains/kotlinx/kandy/letsplot/style/CustomStyle.kt | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/kandy-lets-plot/src/main/kotlin/org/jetbrains/kotlinx/kandy/letsplot/style/CustomStyle.kt b/kandy-lets-plot/src/main/kotlin/org/jetbrains/kotlinx/kandy/letsplot/style/CustomStyle.kt
index f4c37316b..783003a8b 100644
--- a/kandy-lets-plot/src/main/kotlin/org/jetbrains/kotlinx/kandy/letsplot/style/CustomStyle.kt
+++ b/kandy-lets-plot/src/main/kotlin/org/jetbrains/kotlinx/kandy/letsplot/style/CustomStyle.kt
@@ -70,13 +70,7 @@ public interface WithMargin {
}
}
-public data class Inset(val top: Double, val right: Double, val bottom: Double, val left: Double) {
- public constructor(all: Double) : this(all, all, all, all)
-
- public constructor(vertical: Double, horizontal: Double) : this(vertical, horizontal, vertical, horizontal)
-
- public constructor(top: Double, horizontal: Double, bottom: Double) : this(top, horizontal, bottom, horizontal)
-}
+public typealias Inset = Margin
public interface WithInset {
public var inset: Inset?
From a13120c568a6057b68f13452ac0c635042d3a2d1 Mon Sep 17 00:00:00 2001
From: Lucas Watkins <114666925+lucas-watkins@users.noreply.github.com>
Date: Tue, 3 Sep 2024 18:00:38 -0400
Subject: [PATCH 8/8] Refactor class
---
.../org/jetbrains/kotlinx/kandy/letsplot/translator/style.kt | 4 ----
1 file changed, 4 deletions(-)
diff --git a/kandy-lets-plot/src/main/kotlin/org/jetbrains/kotlinx/kandy/letsplot/translator/style.kt b/kandy-lets-plot/src/main/kotlin/org/jetbrains/kotlinx/kandy/letsplot/translator/style.kt
index 33678fc35..eb5dcd7e3 100644
--- a/kandy-lets-plot/src/main/kotlin/org/jetbrains/kotlinx/kandy/letsplot/translator/style.kt
+++ b/kandy-lets-plot/src/main/kotlin/org/jetbrains/kotlinx/kandy/letsplot/translator/style.kt
@@ -12,10 +12,6 @@ internal fun Margin.wrap(): List {
return listOf(top, right, bottom, left)
}
-internal fun Inset.wrap(): List {
- return listOf(top, right, bottom, left)
-}
-
internal fun LineParameters.wrap(): Map {
return elementLine(
color = color?.wrap(),