Skip to content

Commit 190a2d7

Browse files
Better text positioning for JVM export
1 parent 12b3361 commit 190a2d7

28 files changed

+153
-6
lines changed

demo/demo-and-test-shared/src/commonMain/kotlin/demoAndTestShared/ImageComparer.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
package demoAndTestShared
88

9-
import org.jetbrains.letsPlot.commons.encoding.Png
109
import org.jetbrains.letsPlot.commons.values.Bitmap
1110
import org.jetbrains.letsPlot.commons.values.Color
1211
import org.jetbrains.letsPlot.core.canvas.Canvas
@@ -51,14 +50,13 @@ class ImageComparer(
5150

5251
bitmapIO.write(visualDiffBitmap, diffFilePath)
5352
bitmapIO.write(actualBitmap, actualFilePath)
54-
val diffDataImage = Png.encodeDataImage(visualDiffBitmap)
5553

5654
error(
5755
"""Image mismatch.
5856
| Diff: $diffFilePath
5957
| Actual: $actualFilePath
6058
| Expected: $expectedFilePath
61-
| Diff DataImage: $diffDataImage""".trimMargin()
59+
|""".trimMargin()
6260
)
6361
} else {
6462
println("Image comparison passed: $expectedFilePath")

plot-image-export/src/jvmTest/kotlin/org/jetbrains/letsPlot/core/plot/export/PlotImageExportVisualTest.kt

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,56 @@ class PlotImageExportVisualTest {
7171
assertPlot("plot_latex_formula_test.png", plotSpec)
7272
}
7373

74+
@Test
75+
fun superscript() {
76+
val spec = """
77+
|{
78+
| "kind": "subplots",
79+
| "layout": { "ncol": 2.0, "nrow": 1.0, "name": "grid" },
80+
| "figures": [
81+
| {
82+
| "kind": "plot",
83+
| "ggtitle": { "text": "Default limits" },
84+
| "theme": { "name": "classic", "exponent_format": "pow", "text": { "family": "Noto Sans" }, "axis_title_y": { "blank": true } },
85+
| "scales": [ { "aesthetic": "y", "limits": [ 1e-08, 10000000.0 ], "trans": "log10" } ],
86+
| "layers": [
87+
| {
88+
| "geom": "text",
89+
| "mapping": {
90+
| "y": [ 1e-07, 1e-06, 1e-05, 0.0001, 0.001, 0.01, 0.1, 1.0, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0 ],
91+
| "label": [ 1e-07, 1e-06, 1e-05, 0.0001, 0.001, 0.01, 0.1, 1.0, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0 ]
92+
| },
93+
| "family": "Noto Sans",
94+
| "size": 10.0
95+
| }
96+
| ]
97+
| },
98+
| {
99+
| "kind": "plot",
100+
| "ggtitle": { "text": "Scientific notation for \\( x \\leq 10^{-3} \\) and \\( x \\geq 10^3 \\)" },
101+
| "theme": { "name": "classic", "exponent_format": [ "pow", -3.0, 3.0 ], "text": { "family": "Noto Sans" }, "axis_title_y": { "blank": true } },
102+
| "scales": [ { "aesthetic": "y", "limits": [ 1e-08, 10000000.0 ], "trans": "log10" } ],
103+
| "layers": [
104+
| {
105+
| "geom": "text",
106+
| "mapping": {
107+
| "y": [ 1e-07, 1e-06, 1e-05, 0.0001, 0.001, 0.01, 0.1, 1.0, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0 ],
108+
| "label": [ 1e-07, 1e-06, 1e-05, 0.0001, 0.001, 0.01, 0.1, 1.0, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0 ]
109+
| },
110+
| "family": "Noto Sans",
111+
| "size": 10.0
112+
| }
113+
| ]
114+
| }
115+
| ]
116+
|}
117+
|""".trimMargin()
118+
119+
val plotSpec = parsePlotSpec(spec)
120+
121+
assertPlot("plot_superscript_test.png", plotSpec)
122+
}
123+
74124
@Test
75125
fun `multi-level latex formula`() {
76126
val spec = """
@@ -255,6 +305,7 @@ class PlotImageExportVisualTest {
255305

256306
assertPlot("plot_markdown2Xscale_test.png", plotSpec, scale = 2)
257307
}
308+
258309
@Test
259310
fun markdown() {
260311
val spec = """
101 Bytes
Loading
-8 Bytes
Loading
14 Bytes
Loading
37 Bytes
Loading
73 Bytes
Loading
-6 Bytes
Loading
25 Bytes
Loading
74 Bytes
Loading

0 commit comments

Comments
 (0)