Skip to content

Commit

Permalink
Customizable height of charts
Browse files Browse the repository at this point in the history
  • Loading branch information
handstandsam committed Nov 12, 2024
1 parent c1f3ceb commit 79f6190
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.serialization.Serializable
import org.jetbrains.compose.web.css.CSSSizeValue
import org.jetbrains.compose.web.css.Color
import org.jetbrains.compose.web.css.LineStyle
import org.jetbrains.compose.web.css.border
Expand Down Expand Up @@ -62,6 +63,7 @@ object ChartsJs {
private fun ChartJsComposable(
graphDomId: String,
chartData: ChartsJs.ChartJsParam,
height: CSSSizeValue<*>,
onClick: (label: String, value: Int) -> Unit = { _, _ -> }
) {
// Good to go
Expand All @@ -73,7 +75,7 @@ private fun ChartJsComposable(
style(LineStyle.Solid)
color = Color.black
}
maxHeight(400.px)
maxHeight(height)
maxWidth(100.percent)
}
})
Expand All @@ -95,11 +97,13 @@ private val random = Random(0)
fun ChartJsChartComposable(
domId: String = "chart-${random.nextInt().absoluteValue}",
type: String = "pie",
height: CSSSizeValue<*> = 400.px,
data: ChartsJs.ChartJsData,
onClick: (String, Int) -> Unit = { _, _ -> }
) {
ChartJsComposable(
graphDomId = domId,
height = height,
chartData = ChartsJs.ChartJsParam(
type = type,
data = data,
Expand Down

0 comments on commit 79f6190

Please sign in to comment.