Skip to content

Commit f9928cf

Browse files
webOnly option (#291)
* webOnly option * webOnly option
1 parent cb730f3 commit f9928cf

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

toolkit/jupyter/src/main/kotlin/org/jetbrains/letsPlot/toolkit/jupyter/Integration.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ internal class Integration(private val notebook: Notebook, options: MutableMap<S
2727
private val lpJsVersion = VersionChecker.letsPlotJsVersion
2828
private val isolatedFrame = options["isolatedFrame"] ?: ""
2929

30+
private val webOnly: Boolean = options["webOnly"].toBoolean()
3031

3132
override fun Builder.onLoaded() {
3233
import("org.jetbrains.letsPlot.*")
@@ -80,7 +81,7 @@ internal class Integration(private val notebook: Notebook, options: MutableMap<S
8081
firstFigureRendered = true
8182
host.execute { display(HTML(frontendContext.getConfigureHtml()), null) }
8283
}
83-
NotebookRenderingContext(config, frontendContext).figureToMimeResult(value)
84+
NotebookRenderingContext(config, frontendContext, webOnly).figureToMimeResult(value)
8485
}
8586
}
8687

toolkit/jupyter/src/main/kotlin/org/jetbrains/letsPlot/toolkit/jupyter/NotebookRenderingContext.kt

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import java.util.*
1515

1616
internal class NotebookRenderingContext(
1717
private val config: JupyterConfig,
18-
private val frontendContext: NotebookFrontendContext
18+
private val frontendContext: NotebookFrontendContext,
19+
private val webOnly: Boolean
1920
) {
2021
/**
2122
* Creates Mime JSON with two output options - HTML and application/plot.
@@ -27,12 +28,14 @@ internal class NotebookRenderingContext(
2728
val html = frontendContext.getDisplayHtml(figure.toSpec())
2829
return buildJsonObject {
2930
put(MimeTypes.HTML, JsonPrimitive(html))
30-
put("application/plot+json", buildJsonObject {
31-
put("output_type", JsonPrimitive("lets_plot_spec"))
32-
put("output", serializeJsonMap(spec))
33-
put("apply_color_scheme", JsonPrimitive(config.themeApplied))
34-
put("swing_enabled", JsonPrimitive(config.swingEnabled))
35-
})
31+
if (!webOnly) {
32+
put("application/plot+json", buildJsonObject {
33+
put("output_type", JsonPrimitive("lets_plot_spec"))
34+
put("output", serializeJsonMap(spec))
35+
put("apply_color_scheme", JsonPrimitive(config.themeApplied))
36+
put("swing_enabled", JsonPrimitive(config.swingEnabled))
37+
})
38+
}
3639
}
3740
}
3841

0 commit comments

Comments
 (0)