Kotlin wrapper for Recharts library.
This project is WIP.
Groovy DSL
repositories {
maven { url 'https://gitlab.com/api/v4/projects/21457223/packages/maven' }
}
dependencies {
implementation "space.gm666q:kotlin-recharts:${version}"
}
Kotlin DSL
repositories {
maven("https://gitlab.com/api/v4/projects/21457223/packages/maven")
}
dependencies {
implementation("space.gm666q:kotlin-recharts:${version}")
}
data class Data(val amt: Int, val name: String, val pv: Int, val uv: Int)
val d = arrayOf<Any>(
Data(2400, "Page A", 2400, 400),
Data(2400, "Page B", 4567, 300),
Data(2400, "Page C", 1398, 300),
Data(2400, "Page D", 9800, 200),
Data(2400, "Page E", 3908, 278),
Data(2400, "Page F", 4800, 189)
)
fun main() {
render(document.getElementById("root")) {
lineChart {
attrs {
data = d
height = 300
margin = createMargin(5, 0, 20, 5)
width = 600
}
cartesianGrid {
attrs.asDynamic()["stroke"] = "#ccc"
attrs.asDynamic()["strokeDasharray"] = "5 5"
}
line {
attrs {
dataKey = DataKey.String(Data::uv.name)
type = CurveType.monotone
}
attrs.asDynamic()["stroke"] = "#8884d8"
}
xAxis {
attrs {
dataKey = DataKey.String(Data::name.name)
}
}
yAxis {
}
tooltip {
}
}
}
}