Skip to content

Commit cea80a2

Browse files
committed
Upgrade LP -> 4.7.3, update ggsave.
1 parent b136f80 commit cea80a2

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

demo/js-frontend-app/src/jsMain/resources/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</head>
1111
<body>
1212
<script type="text/javascript"
13-
src="https://cdn.jsdelivr.net/gh/JetBrains/[email protected].2/js-package/distr/lets-plot.min.js"></script>
13+
src="https://cdn.jsdelivr.net/gh/JetBrains/[email protected].3/js-package/distr/lets-plot.min.js"></script>
1414
<script src="js-frontend-app.js"></script>
1515
<div>
1616
<h2>Lets-Plot Kotlin/JS Demo.</h2>

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ nexusPublish.version=1.3.0
3535
ksp.version=1.9.25-1.0.20
3636
jupyterApi.version=0.12.0-313
3737

38-
# Also update JS version in <home>/demo/js-frontend-app/src/jsMain/resources/index.html
39-
letsPlot.version=4.7.2
38+
# Also update the JS version in <home>/demo/js-frontend-app/src/jsMain/resources/index.html
39+
letsPlot.version=4.7.3
4040

4141
# https://geotoolsnews.blogspot.com/
4242
geotools.version=33.2

plot-api/src/jvmMain/kotlin/org/jetbrains/letsPlot/export/ggsave.kt

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,22 @@ private const val DEF_EXPORT_DIR = "lets-plot-images"
2020

2121
/**
2222
* Exports plot to a file.
23-
* Supported formats: SVG, HTML, PNG, JPEG and TIFF.
23+
* Supported formats: SVG, HTML, PNG, JPEG, and TIFF.
2424
* Note: in some configurations raster formats might not be supported.
2525
*
2626
* If `path` is not specified, the output file will be saved in
2727
* `${user.dir}/lets-plot-images`.
2828
*
2929
* ## Notes
3030
*
31+
* Large plot dimensions without units require explicit unit specification.
32+
* When `w` or `h` value exceeds 20 without specifying units (e.g., `ggsave(p, 300, 400)`),
33+
* we ask to specify units explicitly:
34+
* `ggsave(p, 300, 400, unit='px')` or `ggsave(p, 3, 4, unit='in')`.
35+
*
3136
* The output format is inferred from the file extension.
3237
*
33-
* **For PNG and PDF:**
38+
* **For PNG and PDF: **
3439
*
3540
* - If `w`, `h`, `unit`, and `dpi` are all specified:
3641
*
@@ -54,14 +59,14 @@ private const val DEF_EXPORT_DIR = "lets-plot-images"
5459
* - The plot maintains its aspect ratio, preserving layout, tick labels, and other visual elements.
5560
* - Useful for generating high-resolution images suitable for publication.
5661
*
57-
* **For SVG:**
62+
* **For SVG: **
5863
*
5964
* - If `w`, `h`, and `unit` are specified:
6065
*
6166
* - The plot's pixel size (default or set via [ggsize()][org.jetbrains.letsPlot.ggsize]) is ignored.
6267
* - The output size is set from the given values.
6368
*
64-
* **For HTML:**
69+
* **For HTML: **
6570
*
6671
* - If `w` and `h` are specified:
6772
*
@@ -192,22 +197,21 @@ private fun exportRasterImage(
192197
unit: PlotExportCommon.SizeUnit? = null,
193198
targetDPI: Number? = null
194199
) {
195-
// As of lets-plot version 4.7.2
196-
// PlotImageExport calls SwingUtilities.invokeAndWait().
197-
// Check if Swing is present.
200+
// As of lets-plot version 4.7.3
201+
// PlotImageExport uses java.awt.image.BufferedImage
202+
// Check if java.awt is present.
198203
try {
199-
Class.forName("javax.swing.SwingUtilities")
204+
Class.forName("java.awt.image.BufferedImage")
200205
} catch (e: ClassNotFoundException) {
201206
throw IllegalStateException(
202207
"""
203208
204-
Can't export plot to raster formats: Swing is not available in this environment.
205-
Raster image export requires SwingUtilities which is not present in Android JRE or headless environments.
209+
Can't export plot to raster formats: 'java.awt.image.BufferedImage' is not available in this environment.
210+
Raster image export requires 'java.awt.image.BufferedImage' which is not present in Android JRE or headless environments.
206211
""".trimIndent()
207212
)
208213
}
209214

210-
211215
// lets-plot-image-export.jar might not be present in the classpath.
212216
val imageBytes: ByteArray = try {
213217

0 commit comments

Comments
 (0)