Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Detekt #123

Merged
merged 1 commit into from
Feb 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Loading