I wonder if there is any chance some bindings could be written for Kotlin/React.
I managed to get a basic example working, but this seems really hacky:
external interface DotChartProps : Props {
var data: List<Pair<Double, Double>>
var size: Size?
var config: ChartConfig?
}
val DotChart = FC<DotChartProps>("DotChart") { props ->
useEffect(props.size, props.data, props.config) {
document.getElementById("my-chart")
.unsafeCast<org.w3c.dom.HTMLDivElement>()
.newVizContainer().apply {
size = props.size ?: Size(300.0, 300.0)
chart(data = props.data, config = props.config ?: configuration {}) {
val x = quantitative({ domain.first })
val y = quantitative({ domain.second })
dot(x, y)
}
}
}
ReactHTML.div {
id = "my-chart"
}
}
Given that react props (external interfaces) cannot have properties of functional types with receivers, I didn’t manage yet to write a more generic react component wrapper that would allow the pure ChartsKt DSL to be used out-of-the-box.