Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ internal class Integration(private val notebook: Notebook, options: MutableMap<S
private val lpJsVersion = VersionChecker.letsPlotJsVersion
private val isolatedFrame = options["isolatedFrame"] ?: ""

private val webOnly: Boolean = options["webOnly"].toBoolean()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest tolerating missing value here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean (options["webOnly"] ?: "false").toBoolean()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact this is the same, isn't it?


override fun Builder.onLoaded() {
import("org.jetbrains.letsPlot.*")
Expand Down Expand Up @@ -80,7 +81,7 @@ internal class Integration(private val notebook: Notebook, options: MutableMap<S
firstFigureRendered = true
host.execute { display(HTML(frontendContext.getConfigureHtml()), null) }
}
NotebookRenderingContext(config, frontendContext).figureToMimeResult(value)
NotebookRenderingContext(config, frontendContext, webOnly).figureToMimeResult(value)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import java.util.*

internal class NotebookRenderingContext(
private val config: JupyterConfig,
private val frontendContext: NotebookFrontendContext
private val frontendContext: NotebookFrontendContext,
private val webOnly: Boolean
) {
/**
* Creates Mime JSON with two output options - HTML and application/plot.
Expand All @@ -27,12 +28,14 @@ internal class NotebookRenderingContext(
val html = frontendContext.getDisplayHtml(figure.toSpec())
return buildJsonObject {
put(MimeTypes.HTML, JsonPrimitive(html))
put("application/plot+json", buildJsonObject {
put("output_type", JsonPrimitive("lets_plot_spec"))
put("output", serializeJsonMap(spec))
put("apply_color_scheme", JsonPrimitive(config.themeApplied))
put("swing_enabled", JsonPrimitive(config.swingEnabled))
})
if (!webOnly) {
put("application/plot+json", buildJsonObject {
put("output_type", JsonPrimitive("lets_plot_spec"))
put("output", serializeJsonMap(spec))
put("apply_color_scheme", JsonPrimitive(config.themeApplied))
put("swing_enabled", JsonPrimitive(config.swingEnabled))
})
}
}
}

Expand Down