Skip to content

Commit

Permalink
Merge pull request #123 from hi-manshu/fix/detekt
Browse files Browse the repository at this point in the history
Fix: Detekt
  • Loading branch information
hi-manshu authored Feb 8, 2025
2 parents 5a33b37 + 1e75c1b commit 262f5ec
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 21 deletions.
6 changes: 5 additions & 1 deletion charty/detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@ naming:
functionPattern: '^[a-z][A-Za-z0-9]*$'
ignoreAnnotated: [ "Composable" ]

formatting:
Indentation:
active: false

style:
MaxLineLength:
active: false
active: true
maxLineLength: 166
MagicNumber:
active: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,8 @@ internal fun getTextYOffsetAndCornerRadius(
}
val cornerRadius = if (barChartConfig.showCurvedBar) {
CornerRadius(
barWidth / 2, barWidth / 2
x = barWidth / 2,
y = barWidth / 2
)
} else {
CornerRadius.Zero
Expand Down Expand Up @@ -422,7 +423,9 @@ internal fun BarChartCanvasScaffold(
val barWidth = (canvasWidth - gap * (data().count() - 1)) / data().count()

content(
canvasHeight, gap, barWidth
canvasHeight,
gap,
barWidth
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ private fun ComparisonBarContent(
val barWidth = groupWidth / (maxBarsCount * 2)
val cornerRadius = if (comparisonBarChartConfig.showCurvedBar) {
CornerRadius(
barWidth / 2, barWidth / 2
x = barWidth / 2,
y = barWidth / 2
)
} else {
CornerRadius.Zero
Expand All @@ -122,9 +123,9 @@ private fun ComparisonBarContent(
group.bars.fastForEachIndexed { barIndex, barValue ->
val barHeight = (barValue / maxValue) * canvasHeight

val barX =
groupStartX + (groupWidth - (group.bars.size * (barWidth + barWidth / 4))) / 2 +
barIndex * (barWidth + barWidth / 4)
val barX = groupStartX +
(groupWidth - (group.bars.size * (barWidth + barWidth / 4))) / 2 +
barIndex * (barWidth + barWidth / 4)

val brush = Brush.linearGradient(
colors = group.colors[barIndex].value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ private fun LineBarChartContent(
canvasHeight = canvasHeight,
maxHeight = maxHeight
)
val (individualBarTopLeft, individualBarRectSize) = getBarTopLeftAndRectSize(
val (singleBarTopLeft, singleBarRectSize) = getBarTopLeftAndRectSize(
index = index,
barWidth = barWidth,
barData = barData,
Expand All @@ -143,14 +143,14 @@ private fun LineBarChartContent(
)
val (textOffsetY, cornerRadius) = getTextYOffsetAndCornerRadius(
barData = barData,
individualBarTopLeft = individualBarTopLeft,
individualBarTopLeft = singleBarTopLeft,
textLayoutResult = textLayoutResult,
individualBarRectSize = individualBarRectSize,
individualBarRectSize = singleBarRectSize,
barChartConfig = barChartConfig,
barWidth = barWidth
)

if (isClickInsideBar(clickedOffset, individualBarTopLeft, individualBarRectSize)) {
if (isClickInsideBar(clickedOffset, singleBarTopLeft, singleBarRectSize)) {
clickedBarIndex = index
onBarClick(index, barData)
}
Expand All @@ -167,22 +167,25 @@ private fun LineBarChartContent(
)
}
getDrawingPath(
barTopLeft = individualBarTopLeft,
barRectSize = individualBarRectSize,
barTopLeft = singleBarTopLeft,
barRectSize = singleBarRectSize,
topLeftCornerRadius = if (barData.yValue >= 0) cornerRadius else CornerRadius.Zero,
topRightCornerRadius = if (barData.yValue >= 0) cornerRadius else CornerRadius.Zero,
bottomLeftCornerRadius = if (barData.yValue < 0) cornerRadius else CornerRadius.Zero,
bottomRightCornerRadius = if (barData.yValue < 0) cornerRadius else CornerRadius.Zero
).let {
val textOffset = Offset(
x = singleBarTopLeft.x + singleBarRectSize.width.div(2) - textLayoutResult.size.width.div(
2
),
y = textOffsetY,
)
drawPath(path = it, brush = Brush.linearGradient(color))
if (labelConfig.showXLabel) {
drawText(
textLayoutResult = textLayoutResult,
brush = Brush.linearGradient(labelConfig.textColor.value),
topLeft = Offset(
x = individualBarTopLeft.x + individualBarRectSize.width / 2 - textLayoutResult.size.width / 2,
y = textOffsetY,
),
topLeft = textOffset,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ private fun PieChartContent(
var currentStartAngle = 0f
val clickedAngle = (
atan2(
offset.y - size.height / 2,
offset.x - size.width / 2
y = offset.y - size.height / 2,
x = offset.x - size.width / 2
) * STRAIGHT_ANGLE / PI + COMPLETE_CIRCLE_DEGREE
) % COMPLETE_CIRCLE_DEGREE
angles.fastForEachIndexed { index, sweepAngle ->
Expand Down Expand Up @@ -138,4 +138,4 @@ private fun PieChartContent(
startAngle += sweepAngle
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ private fun DrawScope.drawPoints(
val animatedRadius =
if (index == clickedIndex) circleRadius.value * 1.5f else circleRadius.value


val circleCenter = Offset(x, y)

drawCircle(
Expand Down
Binary file not shown.

0 comments on commit 262f5ec

Please sign in to comment.