diff --git a/YChartsLib/src/main/java/co/yml/charts/common/components/accessibility/BarInfo.kt b/YChartsLib/src/main/java/co/yml/charts/common/components/accessibility/BarInfo.kt index d633fca6..4754d1bb 100644 --- a/YChartsLib/src/main/java/co/yml/charts/common/components/accessibility/BarInfo.kt +++ b/YChartsLib/src/main/java/co/yml/charts/common/components/accessibility/BarInfo.kt @@ -15,6 +15,7 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.semantics.semantics +import androidx.compose.ui.unit.TextUnit import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp @@ -22,11 +23,15 @@ import androidx.compose.ui.unit.sp * Composable to display each bar item for given bar chart * @param axisLabelDescription: Axis label description * @param barDescription: Bar description + * @param titleTextSize: TextUnit title font size + * @param descriptionTextSize: TextUnit description font size */ @Composable fun BarInfo( axisLabelDescription: String, - barDescription: String, barColor: Color + barDescription: String, barColor: Color, + titleTextSize:TextUnit, + descriptionTextSize:TextUnit ) { // Merge elements below for accessibility purposes Row(modifier = Modifier @@ -34,7 +39,7 @@ fun BarInfo( .clickable { } .semantics(mergeDescendants = true) {}, verticalAlignment = Alignment.CenterVertically ) { - Text(axisLabelDescription, fontSize = 12.sp) + Text(axisLabelDescription, fontSize = titleTextSize) Spacer(modifier = Modifier.width(10.dp)) Column( modifier = Modifier @@ -48,7 +53,7 @@ fun BarInfo( .background(barColor) .size(20.dp) ) - Text(barDescription, fontSize = 12.sp) + Text(barDescription, fontSize = descriptionTextSize) } } } diff --git a/YChartsLib/src/main/java/co/yml/charts/common/components/accessibility/BubblePointInfo.kt b/YChartsLib/src/main/java/co/yml/charts/common/components/accessibility/BubblePointInfo.kt index 0a436811..a2476636 100644 --- a/YChartsLib/src/main/java/co/yml/charts/common/components/accessibility/BubblePointInfo.kt +++ b/YChartsLib/src/main/java/co/yml/charts/common/components/accessibility/BubblePointInfo.kt @@ -15,6 +15,7 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.semantics.semantics +import androidx.compose.ui.unit.TextUnit import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp @@ -23,12 +24,16 @@ import androidx.compose.ui.unit.sp * @param axisLabelDescription: Axis label description. * @param pointDescription: Details of each point on the line. * @param bubbleColor: Color of each bubble. + * @param titleTextSize: TextUnit title font size + * @param descriptionTextSize: TextUnit description font size */ @Composable fun BubblePointInfo( axisLabelDescription: String, pointDescription: String, - bubbleColor: Color + bubbleColor: Color, + titleTextSize: TextUnit, + descriptionTextSize: TextUnit ) { // Merge elements below for accessibility purposes Row(modifier = Modifier @@ -36,7 +41,7 @@ fun BubblePointInfo( .clickable { } .semantics(mergeDescendants = true) {}, verticalAlignment = Alignment.CenterVertically ) { - Text(axisLabelDescription, fontSize = 12.sp) + Text(axisLabelDescription, fontSize = titleTextSize) Spacer(modifier = Modifier.width(5.dp)) Column( modifier = Modifier @@ -50,7 +55,7 @@ fun BubblePointInfo( .background(bubbleColor) .size(20.dp) ) - Text(pointDescription, fontSize = 12.sp) + Text(pointDescription, fontSize = descriptionTextSize) } } } diff --git a/YChartsLib/src/main/java/co/yml/charts/common/components/accessibility/CombinedChartInfo.kt b/YChartsLib/src/main/java/co/yml/charts/common/components/accessibility/CombinedChartInfo.kt index d0cb0242..bf5c54f8 100644 --- a/YChartsLib/src/main/java/co/yml/charts/common/components/accessibility/CombinedChartInfo.kt +++ b/YChartsLib/src/main/java/co/yml/charts/common/components/accessibility/CombinedChartInfo.kt @@ -18,6 +18,7 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.semantics.semantics +import androidx.compose.ui.unit.TextUnit import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import co.yml.charts.ui.barchart.models.GroupBar @@ -32,6 +33,8 @@ import co.yml.charts.common.model.Point * @param axisLabelDescription: Axis label description. * @param barColorPaletteList: List of each bar colors for a given group bar. * @param dividerColor: Divider color between each point items. + * @param titleTextSize: TextUnit title font size + * @param descriptionTextSize: TextUnit description font size */ @Composable fun CombinedChartInfo( @@ -40,7 +43,9 @@ fun CombinedChartInfo( groupBar: GroupBar?, axisLabelDescription: String, barColorPaletteList: List, - dividerColor: Color + dividerColor: Color, + titleTextSize: TextUnit, + descriptionTextSize: TextUnit ) { // Merge elements below for accessibility purposes Row(modifier = Modifier @@ -48,7 +53,7 @@ fun CombinedChartInfo( .clickable { } .semantics(mergeDescendants = true) {}, verticalAlignment = Alignment.CenterVertically ) { - Text(axisLabelDescription, fontSize = 12.sp) + Text(axisLabelDescription, fontSize = titleTextSize) Spacer(modifier = Modifier.width(10.dp)) Column( modifier = Modifier @@ -66,7 +71,7 @@ fun CombinedChartInfo( ) .size(10.dp) ) - Text(point.description, fontSize = 12.sp) + Text(point.description, fontSize = descriptionTextSize) } Spacer(modifier = Modifier.height(5.dp)) } @@ -79,7 +84,7 @@ fun CombinedChartInfo( .background(barColorPaletteList[index]) .size(20.dp) ) - Text(value.description, fontSize = 12.sp) + Text(value.description, fontSize = descriptionTextSize) } Spacer(modifier = Modifier.height(5.dp)) } diff --git a/YChartsLib/src/main/java/co/yml/charts/common/components/accessibility/GroupBarInfo.kt b/YChartsLib/src/main/java/co/yml/charts/common/components/accessibility/GroupBarInfo.kt index fc9876cc..b9ce6795 100644 --- a/YChartsLib/src/main/java/co/yml/charts/common/components/accessibility/GroupBarInfo.kt +++ b/YChartsLib/src/main/java/co/yml/charts/common/components/accessibility/GroupBarInfo.kt @@ -16,6 +16,7 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.semantics.semantics +import androidx.compose.ui.unit.TextUnit import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import co.yml.charts.ui.barchart.models.GroupBar @@ -26,12 +27,16 @@ import co.yml.charts.ui.barchart.models.GroupBar * @param axisLabelDescription: Axis label description. * @param groupBar: Details of each group bar. * @param barColorPaletteList: List of each bar colors for a given group bar. + * @param titleTextSize: TextUnit title font size + * @param descriptionTextSize: TextUnit description font size */ @Composable fun GroupBarInfo( groupBar: GroupBar, axisLabelDescription: String, - barColorPaletteList: List + barColorPaletteList: List, + titleTextSize: TextUnit, + descriptionTextSize: TextUnit ) { // Merge elements below for accessibility purposes Row(modifier = Modifier @@ -39,7 +44,7 @@ fun GroupBarInfo( .clickable { } .semantics(mergeDescendants = true) {}, verticalAlignment = Alignment.CenterVertically ) { - Text(axisLabelDescription, fontSize = 12.sp) + Text(axisLabelDescription, fontSize =titleTextSize) Spacer(modifier = Modifier.width(10.dp)) Column( modifier = Modifier @@ -54,7 +59,7 @@ fun GroupBarInfo( .background(barColorPaletteList[index]) .size(20.dp) ) - Text(value.description, fontSize = 12.sp) + Text(value.description, fontSize = descriptionTextSize) } Spacer(modifier = Modifier.height(5.dp)) } diff --git a/YChartsLib/src/main/java/co/yml/charts/common/components/accessibility/LinePointInfo.kt b/YChartsLib/src/main/java/co/yml/charts/common/components/accessibility/LinePointInfo.kt index 93f37360..2700730a 100644 --- a/YChartsLib/src/main/java/co/yml/charts/common/components/accessibility/LinePointInfo.kt +++ b/YChartsLib/src/main/java/co/yml/charts/common/components/accessibility/LinePointInfo.kt @@ -15,6 +15,7 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.semantics.semantics +import androidx.compose.ui.unit.TextUnit import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp @@ -23,12 +24,17 @@ import androidx.compose.ui.unit.sp * @param axisLabelDescription: Axis label description. * @param pointDescription: Details of each point on the line. * @param lineColor: Color of each line. + * @param titleTextSize: TextUnit title font size + * @param descriptionTextSize: TextUnit description font size + * */ @Composable fun LinePointInfo( axisLabelDescription: String, pointDescription: String, - lineColor: Color + lineColor: Color, + titleTextSize: TextUnit, + descriptionTextSize: TextUnit ) { // Merge elements below for accessibility purposes Row(modifier = Modifier @@ -36,7 +42,7 @@ fun LinePointInfo( .clickable { } .semantics(mergeDescendants = true) {}, verticalAlignment = Alignment.CenterVertically ) { - Text(axisLabelDescription, fontSize = 12.sp) + Text(axisLabelDescription, fontSize = titleTextSize) Spacer(modifier = Modifier.width(5.dp)) Column( modifier = Modifier @@ -50,7 +56,7 @@ fun LinePointInfo( .background(lineColor) .size(20.dp) ) - Text(pointDescription, fontSize = 12.sp) + Text(pointDescription, fontSize = descriptionTextSize) } } } diff --git a/YChartsLib/src/main/java/co/yml/charts/common/components/accessibility/SliceInfo.kt b/YChartsLib/src/main/java/co/yml/charts/common/components/accessibility/SliceInfo.kt index 81add4f7..d74e4651 100644 --- a/YChartsLib/src/main/java/co/yml/charts/common/components/accessibility/SliceInfo.kt +++ b/YChartsLib/src/main/java/co/yml/charts/common/components/accessibility/SliceInfo.kt @@ -12,6 +12,7 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.semantics.semantics +import androidx.compose.ui.unit.TextUnit import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import co.yml.charts.ui.piechart.models.PieChartData @@ -20,9 +21,10 @@ import co.yml.charts.ui.piechart.models.PieChartData * Composable to display each slice for a given pie chart. * @param slice: Details of each slice in pie/ donut chart. * @param slicePercentage: Percentage of each slice. + * @param textSize: TextUnit text font size */ @Composable -fun SliceInfo(slice: PieChartData.Slice, slicePercentage: Int) { +fun SliceInfo(slice: PieChartData.Slice, slicePercentage: Int, textSize: TextUnit) { // Merge elements below for accessibility purposes Row(modifier = Modifier .clickable { } @@ -40,7 +42,7 @@ fun SliceInfo(slice: PieChartData.Slice, slicePercentage: Int) { .weight(1f) .padding(top = 10.dp, bottom = 10.dp) ) { - Text(slice.sliceDescription(slicePercentage), fontSize = 12.sp) + Text(slice.sliceDescription(slicePercentage), fontSize = textSize) } } } diff --git a/YChartsLib/src/main/java/co/yml/charts/common/model/AccessibilityConfig.kt b/YChartsLib/src/main/java/co/yml/charts/common/model/AccessibilityConfig.kt index f7c9fe8a..c1cd8a86 100644 --- a/YChartsLib/src/main/java/co/yml/charts/common/model/AccessibilityConfig.kt +++ b/YChartsLib/src/main/java/co/yml/charts/common/model/AccessibilityConfig.kt @@ -2,7 +2,9 @@ package co.yml.charts.common.model import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.Dp +import androidx.compose.ui.unit.TextUnit import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp import co.yml.charts.common.utils.ChartConstants /** @@ -13,6 +15,8 @@ import co.yml.charts.common.utils.ChartConstants * @param popUpTopRightButtonDescription: Content description of the button visible on the accessibility popUp at the top right. * @param dividerColor: Defines the color for the divider used in the accessibility popUp * @param dividerThickness: Defines the thickness for the divider in Dp used in the accessibility popUp + * @param titleTextSize: Defines the font-size of titles used in the accessibility popUp + * @param descriptionTextSize: Defines the font-size of descriptions used in the accessibility popUp */ data class AccessibilityConfig( val chartDescription: String = ChartConstants.CHART_DESCRIPTION, @@ -20,6 +24,8 @@ data class AccessibilityConfig( val popUpTopRightButtonTitle: String = ChartConstants.POPUP_TOP_RIGHT_BUTTON_TITLE, val popUpTopRightButtonDescription: String = ChartConstants.POPUP_TOP_RIGHT_BUTTON_DESCRIPTION, val dividerColor: Color = Color.Gray, - val dividerThickness: Dp = 2.dp -) + val dividerThickness: Dp = 2.dp, + val titleTextSize: TextUnit = 14.sp, + val descriptionTextSize: TextUnit = 14.sp, + ) diff --git a/YChartsLib/src/main/java/co/yml/charts/common/model/LegendsConfig.kt b/YChartsLib/src/main/java/co/yml/charts/common/model/LegendsConfig.kt index 0d939328..d3b6b311 100644 --- a/YChartsLib/src/main/java/co/yml/charts/common/model/LegendsConfig.kt +++ b/YChartsLib/src/main/java/co/yml/charts/common/model/LegendsConfig.kt @@ -5,7 +5,9 @@ import androidx.compose.ui.graphics.Brush import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.TextStyle import androidx.compose.ui.unit.Dp +import androidx.compose.ui.unit.TextUnit import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp /** * LegendsConfig data class params used in config label in graph. @@ -19,6 +21,7 @@ import androidx.compose.ui.unit.dp * */ data class LegendsConfig( val legendLabelList: List, + val textSize: TextUnit = 14.sp, val gridColumnCount: Int = 1, val gridPaddingHorizontal: Dp = 8.dp, val gridPaddingVertical: Dp = 8.dp, diff --git a/YChartsLib/src/main/java/co/yml/charts/ui/barchart/BarChart.kt b/YChartsLib/src/main/java/co/yml/charts/ui/barchart/BarChart.kt index 7d282be6..e3a3b9f5 100644 --- a/YChartsLib/src/main/java/co/yml/charts/ui/barchart/BarChart.kt +++ b/YChartsLib/src/main/java/co/yml/charts/ui/barchart/BarChart.kt @@ -92,7 +92,9 @@ fun BarChart(modifier: Modifier, barChartData: BarChartData) { ) }, chartData[index].description, - chartData[index].color + chartData[index].color, + accessibilityConfig.titleTextSize, + accessibilityConfig.descriptionTextSize ) ItemDivider( thickness = accessibilityConfig.dividerThickness, diff --git a/YChartsLib/src/main/java/co/yml/charts/ui/barchart/GroupBarChart.kt b/YChartsLib/src/main/java/co/yml/charts/ui/barchart/GroupBarChart.kt index 6935b03c..79b234c7 100644 --- a/YChartsLib/src/main/java/co/yml/charts/ui/barchart/GroupBarChart.kt +++ b/YChartsLib/src/main/java/co/yml/charts/ui/barchart/GroupBarChart.kt @@ -304,7 +304,9 @@ fun GroupBarChart(modifier: Modifier, groupBarChartData: GroupBarChartData) { xAxisData.axisLabelDescription( xAxisData.labelData(index) ), - barPlotData.barColorPaletteList + barPlotData.barColorPaletteList, + accessibilityConfig.titleTextSize, + accessibilityConfig.descriptionTextSize ) ItemDivider( thickness = accessibilityConfig.dividerThickness, diff --git a/YChartsLib/src/main/java/co/yml/charts/ui/barchart/StackedBarChart.kt b/YChartsLib/src/main/java/co/yml/charts/ui/barchart/StackedBarChart.kt index 5033a004..3cf65ede 100644 --- a/YChartsLib/src/main/java/co/yml/charts/ui/barchart/StackedBarChart.kt +++ b/YChartsLib/src/main/java/co/yml/charts/ui/barchart/StackedBarChart.kt @@ -311,7 +311,9 @@ fun StackedBarChart( xAxisData.axisLabelDescription( xAxisData.labelData(index) ), - barPlotData.barColorPaletteList + barPlotData.barColorPaletteList, + accessibilityConfig.titleTextSize, + accessibilityConfig.descriptionTextSize ) ItemDivider( thickness = accessibilityConfig.dividerThickness, diff --git a/YChartsLib/src/main/java/co/yml/charts/ui/bubblechart/BubbleChart.kt b/YChartsLib/src/main/java/co/yml/charts/ui/bubblechart/BubbleChart.kt index 80e365e5..5fce08ce 100644 --- a/YChartsLib/src/main/java/co/yml/charts/ui/bubblechart/BubbleChart.kt +++ b/YChartsLib/src/main/java/co/yml/charts/ui/bubblechart/BubbleChart.kt @@ -253,8 +253,9 @@ fun BubbleChart(modifier: Modifier, bubbleChartData: BubbleChartData) { ) ), bubbles[index].center.description, - bubbles[index].bubbleStyle.solidColor - ?: bubbles[index].bubbleStyle.gradientColors.first() + bubbles[index].bubbleStyle.solidColor, + accessibilityConfig.titleTextSize, + accessibilityConfig.descriptionTextSize ) ItemDivider( thickness = accessibilityConfig.dividerThickness, diff --git a/YChartsLib/src/main/java/co/yml/charts/ui/combinedchart/CombinedChart.kt b/YChartsLib/src/main/java/co/yml/charts/ui/combinedchart/CombinedChart.kt index 7dbdf34a..c36bedc2 100644 --- a/YChartsLib/src/main/java/co/yml/charts/ui/combinedchart/CombinedChart.kt +++ b/YChartsLib/src/main/java/co/yml/charts/ui/combinedchart/CombinedChart.kt @@ -388,7 +388,9 @@ fun CombinedChart(modifier: Modifier, combinedChartData: CombinedChartData) { xAxisData.labelData(index) ), barColorPaletteList = barPlotData.barColorPaletteList, - dividerColor = accessibilityConfig.dividerColor + dividerColor = accessibilityConfig.dividerColor, + accessibilityConfig.titleTextSize, + accessibilityConfig.descriptionTextSize ) ItemDivider( thickness = accessibilityConfig.dividerThickness, diff --git a/YChartsLib/src/main/java/co/yml/charts/ui/linechart/LineChart.kt b/YChartsLib/src/main/java/co/yml/charts/ui/linechart/LineChart.kt index 8ae78dea..b7230d10 100644 --- a/YChartsLib/src/main/java/co/yml/charts/ui/linechart/LineChart.kt +++ b/YChartsLib/src/main/java/co/yml/charts/ui/linechart/LineChart.kt @@ -256,7 +256,9 @@ fun LineChart(modifier: Modifier, lineChartData: LineChartData) { ) ), point.description, - linePlotData.lines[lineIndex].lineStyle.color + linePlotData.lines[lineIndex].lineStyle.color, + accessibilityConfig.titleTextSize, + accessibilityConfig.descriptionTextSize ) ItemDivider( diff --git a/YChartsLib/src/main/java/co/yml/charts/ui/piechart/charts/DonutPieChart.kt b/YChartsLib/src/main/java/co/yml/charts/ui/piechart/charts/DonutPieChart.kt index 0c2a6679..3fc48c5f 100644 --- a/YChartsLib/src/main/java/co/yml/charts/ui/piechart/charts/DonutPieChart.kt +++ b/YChartsLib/src/main/java/co/yml/charts/ui/piechart/charts/DonutPieChart.kt @@ -252,7 +252,8 @@ fun DonutPieChart( items(pieChartData.slices.size) { index -> SliceInfo( pieChartData.slices[index], - proportions[index].roundToInt() + proportions[index].roundToInt(), + accessibilityConfig.descriptionTextSize ) } } diff --git a/YChartsLib/src/main/java/co/yml/charts/ui/piechart/charts/PieChart.kt b/YChartsLib/src/main/java/co/yml/charts/ui/piechart/charts/PieChart.kt index fbd04c59..8713068d 100644 --- a/YChartsLib/src/main/java/co/yml/charts/ui/piechart/charts/PieChart.kt +++ b/YChartsLib/src/main/java/co/yml/charts/ui/piechart/charts/PieChart.kt @@ -245,7 +245,8 @@ fun PieChart( LazyColumn { items(pieChartData.slices.size) { index -> SliceInfo( - pieChartData.slices[index], proportions[index].roundToInt() + pieChartData.slices[index], proportions[index].roundToInt(), + accessibilityConfig.descriptionTextSize ) } } diff --git a/YChartsLib/src/main/java/co/yml/charts/ui/wavechart/WaveChart.kt b/YChartsLib/src/main/java/co/yml/charts/ui/wavechart/WaveChart.kt index d78ecd4b..da36fa6d 100644 --- a/YChartsLib/src/main/java/co/yml/charts/ui/wavechart/WaveChart.kt +++ b/YChartsLib/src/main/java/co/yml/charts/ui/wavechart/WaveChart.kt @@ -256,7 +256,9 @@ fun WaveChart(modifier: Modifier, waveChartData: WaveChartData) { ), linePoints?.get(index)?.description ?: "", wavePlotData.lines.firstOrNull()?.waveStyle?.color - ?: Color.Transparent + ?: Color.Transparent, + accessibilityConfig.titleTextSize, + accessibilityConfig.descriptionTextSize ) ItemDivider( thickness = accessibilityConfig.dividerThickness,