plot-api/src/jvmTest/kotlin/org/jetbrains/letsPlot/GGBunchThemeTest.kt [277:328]: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - assertThemeSpec( p, featureCount = 2, expected = mapOf( "name" to "light", "flavor" to "darcula", // Keep flavor ) ) // Global theme should be stripped from the figure spec in grid val fig = (p.toSpec()["figures"] as List)[0] as Map<*, *> assertEquals("plot", fig["kind"]) // Make sure it's a plot assertTrue(fig.containsKey("theme")) assertEquals( mapOf( "name" to "bw", "flavor" to "darcula", // Add flavor // "legend_position" to "bottom" // and theme option ), fig["theme"] ) } finally { // Clear global setting LetsPlot.theme = null } } private companion object { fun assertThemeSpec( figure: SubPlotsFigure, featureCount: Int, expected: Map<*, *> ) { assertThat(figure).features().length(featureCount) if (featureCount == 1) { val theme = assertThat(figure).features().get(0) val options = theme.isOptionsMap() .kind(Option.Plot.THEME) .options assertEquals( expected, options ) } // test 'toSpec()' val spec = figure.toSpec() assertEquals( expected, spec[Option.Plot.THEME] ) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - plot-api/src/jvmTest/kotlin/org/jetbrains/letsPlot/GGGridThemeTest.kt [264:315]: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - assertThemeSpec( p, featureCount = 2, expected = mapOf( "name" to "light", "flavor" to "darcula", // Keep flavor ) ) // Global theme should be stripped from the figure spec in grid val fig = (p.toSpec()["figures"] as List)[0] as Map<*, *> assertEquals("plot", fig["kind"]) // Make sure it's a plot assertTrue(fig.containsKey("theme")) assertEquals( mapOf( "name" to "bw", "flavor" to "darcula", // Add flavor // "legend_position" to "bottom" // and theme option ), fig["theme"] ) } finally { // Clear global setting LetsPlot.theme = null } } private companion object { fun assertThemeSpec( figure: SubPlotsFigure, featureCount: Int, expected: Map<*, *> ) { assertThat(figure).features().length(featureCount) if (featureCount == 1) { val theme = assertThat(figure).features().get(0) val options = theme.isOptionsMap() .kind(Option.Plot.THEME) .options assertEquals( expected, options ) } // test 'toSpec()' val spec = figure.toSpec() assertEquals( expected, spec[Option.Plot.THEME] ) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -