Skip to content

Commit 84c9f11

Browse files
committed
add force rotation feature
1 parent 55ebcec commit 84c9f11

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

compose-charts/src/commonMain/kotlin/ir/ehsannarmani/compose_charts/ColumnChart.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ fun ColumnChart(
370370
val minLabelWidth = labelWidths.min()
371371

372372
var textModifier: Modifier = Modifier
373-
var shouldRotate = false
373+
var shouldRotate = labelProperties.forceRotation
374374
if ((maxLabelWidth / minLabelWidth.toDouble()) >= 1.5) {
375375
textModifier = textModifier.width((minLabelWidth / density.density).dp)
376376
shouldRotate = true
@@ -391,7 +391,7 @@ fun ColumnChart(
391391
-(labelMeasures[index].size.width - minLabelWidth.toFloat()) - minLabelWidth / 2
392392
} else textModifier,
393393
text = bar.label,
394-
style = labelProperties.textStyle.copy(),
394+
style = labelProperties.textStyle,
395395
overflow = TextOverflow.Visible,
396396
softWrap = false,
397397
)

compose-charts/src/commonMain/kotlin/ir/ehsannarmani/compose_charts/models/LabelProperties.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ data class LabelProperties(
1212
val padding:Dp = 12.dp,
1313
val labels: List<String> = listOf(),
1414
val rotationDegreeOnSizeConflict: Float = -45f,
15+
val forceRotation: Boolean = false,
1516
)

0 commit comments

Comments
 (0)