Skip to content

Commit 2fbddba

Browse files
committed
saveDfHtmlSample() for FormattedFrame
1 parent d8123b0 commit 2fbddba

File tree

1 file changed

+15
-0
lines changed
  • util/kandy-samples-utils/src/main/kotlin/org/jetbrains/kotlinx/kandy/letsplot/samples

1 file changed

+15
-0
lines changed

util/kandy-samples-utils/src/main/kotlin/org/jetbrains/kotlinx/kandy/letsplot/samples/SampleHelper.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
package org.jetbrains.kotlinx.kandy.letsplot.samples
44

55
import org.jetbrains.kotlinx.dataframe.DataFrame
6+
import org.jetbrains.kotlinx.dataframe.api.FormattedFrame
67
import org.jetbrains.kotlinx.dataframe.api.GroupBy
78
import org.jetbrains.kotlinx.dataframe.io.toStandaloneHtml
89
import org.jetbrains.kotlinx.kandy.ir.Plot
@@ -127,6 +128,20 @@ public abstract class SampleHelper(
127128
saveAsSVG("${name}_dark")
128129
}
129130

131+
/**
132+
* Saves this [FormattedFrame] as HTML.
133+
*/
134+
public fun FormattedFrame<*>.saveDfHtmlSample() {
135+
val name = testName.methodName.replace("_dataframe", "")
136+
val dfHtml = df.toStandaloneHtml(
137+
configuration = getDisplayConfiguration(SamplesDisplayConfiguration),
138+
getFooter = WritersideFooter
139+
) + WritersideStyle
140+
// TODO fix static ids
141+
val htmlWithStaticIDs = dfHtml.toString() // replaceIdsWithStatic(dfHtml.toString())
142+
File(pathToResourceFolder, "$name.html").writeText(htmlWithStaticIDs)
143+
}
144+
130145
/**
131146
* Saves this [DataFrame] as HTML.
132147
*/

0 commit comments

Comments
 (0)