Skip to content

Commit

Permalink
In the combined chart, added the ability to compress data bars.
Browse files Browse the repository at this point in the history
  • Loading branch information
andrey-ananiev committed Mar 2, 2023
1 parent 0312ecb commit 4cd135b
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 25 deletions.
20 changes: 0 additions & 20 deletions YChartsLib/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,6 @@ val javadocJar = tasks.register<Jar>("javadocJar") {
from(dokkaOutputDir)
}
publishing {
// repositories {
// maven {
// name = "YCharts"
// setUrl("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2")
// credentials {
// username = project.findProperty("mavenCentralUsername")?.toString() ?: System.getenv("MAVEN_USERNAME")
// password = project.findProperty("mavenCentralPassword")?.toString() ?: System.getenv("MAVEN_PASSWORD")
// }
// }
// }
publications {
register<MavenPublication>("release") {
groupId = "co.yml"
Expand Down Expand Up @@ -134,13 +124,3 @@ publishing {
}
}
}


//signing {
// useInMemoryPgpKeys(
// project.findProperty("signing.keyId")?.toString() ?: System.getenv("SIGNINGKEY"),
// project.findProperty("signing.InMemoryKey")?.toString() ?: System.getenv("MEMORY_KEY"),
// project.findProperty("signing.password")?.toString()?:System.getenv("SIGNINGPASSWORD")
// )
// sign(publishing.publications)
//}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import co.yml.charts.common.model.LegendLabel
Expand Down Expand Up @@ -50,14 +51,16 @@ private fun Legend(config: LegendsConfig, legendLabel: LegendLabel) {
) {
Box(
modifier = Modifier
.background(legendLabel.color)
.clip(config.colorBoxShape)
.size(config.colorBoxSize)
.background(legendLabel.color)
)
Spacer(modifier = Modifier.padding(config.spaceBWLabelAndColorBox))
Text(
text = legendLabel.name,
style = config.textStyle,
overflow = TextOverflow.Ellipsis
overflow = TextOverflow.Ellipsis,
color = config.textColor
)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package co.yml.charts.common.model

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.MaterialTheme
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
Expand All @@ -22,7 +25,9 @@ data class LegendsConfig(
val gridPaddingHorizontal: Dp = 8.dp,
val gridPaddingVertical: Dp = 8.dp,
val colorBoxSize: Dp = 25.dp,
val colorBoxShape: Shape = CircleShape,
val textStyle: TextStyle = TextStyle(),
val textColor: Color = Color.Black,
val spaceBWLabelAndColorBox: Dp = 8.dp,
val legendsArrangement: Arrangement.Horizontal = Arrangement.Center
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Scaffold
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
Expand All @@ -31,6 +32,7 @@ import co.yml.charts.ui.linechart.model.SelectionHighlightPopUp
import co.yml.charts.common.components.Legends
import co.yml.charts.common.model.LegendsConfig
import co.yml.charts.common.utils.DataUtils
import co.yml.charts.ui.barchart.models.SelectionHighlightData
import co.yml.ycharts.app.R

class CombinedLineAndBarChartActivity : ComponentActivity() {
Expand Down Expand Up @@ -106,13 +108,21 @@ fun BarWithLineChart() {
val colorPaletteList = DataUtils.getColorPaletteList(3)
val legendsConfig = LegendsConfig(
legendLabelList = DataUtils.getLegendsLabelData(colorPaletteList),
gridColumnCount = 3
gridColumnCount = 3,
textColor = MaterialTheme.colors.onSurface,
colorBoxShape = MaterialTheme.shapes.small
)
val barPlotData = BarPlotData(
groupBarList = groupBarData,
barStyle = BarStyle(
barWidth = 35.dp,
barWidth = 40.dp,
squeezeCoefficient = 0.2F,
selectionHighlightData = SelectionHighlightData(
isHighlightBarRequired = true,
groupBarPopUpLabel = { _, y ->
String.format("%.0f", y)
}
)
),
barColorPaletteList = colorPaletteList,
groupingSize = 2.5F
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import android.os.Bundle
import android.widget.Toast
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.material.*
import androidx.compose.runtime.Composable
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/co/yml/ycharts/app/ui/theme/Theme.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ private val DarkColorPalette = darkColors(
background = DarkGrey,
primary = DarkGrey,
text = DarkGrey,
button = Color.White
button = Color.White,
)

private val LightColorPalette = lightColors(
Expand Down

0 comments on commit 4cd135b

Please sign in to comment.