-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Jordan Akinpelu (akinpelud)
committed
Jun 3, 2023
1 parent
1eaff0c
commit f6e1019
Showing
22 changed files
with
916 additions
and
134 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
233 changes: 233 additions & 0 deletions
233
PowerOf10/app/src/main/java/com/example/powerof10/AnalysisTool.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,233 @@ | ||
package com.example.powerof10 | ||
|
||
import android.graphics.Paint | ||
import android.os.Bundle | ||
import androidx.activity.ComponentActivity | ||
import androidx.activity.compose.setContent | ||
import androidx.compose.foundation.layout.* | ||
import androidx.compose.material.MaterialTheme | ||
import androidx.compose.material.Surface | ||
import androidx.compose.material.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import androidx.compose.ui.unit.sp | ||
import com.example.powerof10.Components.rememberLegend | ||
import com.example.powerof10.ui.theme.PowerOf10Theme | ||
import com.himanshoe.charty.common.axis.AxisConfig | ||
import com.himanshoe.charty.line.LineChart | ||
import com.himanshoe.charty.line.model.LineData | ||
import com.patrykandpatrick.vico.compose.axis.axisLabelComponent | ||
import com.patrykandpatrick.vico.compose.axis.horizontal.bottomAxis | ||
import com.patrykandpatrick.vico.compose.axis.vertical.startAxis | ||
import com.patrykandpatrick.vico.compose.chart.Chart | ||
import com.patrykandpatrick.vico.compose.chart.column.columnChart | ||
import com.patrykandpatrick.vico.compose.chart.line.lineChart | ||
import com.patrykandpatrick.vico.core.axis.AxisPosition | ||
import com.patrykandpatrick.vico.core.axis.formatter.AxisValueFormatter | ||
import com.patrykandpatrick.vico.core.axis.horizontal.HorizontalAxis | ||
import com.patrykandpatrick.vico.core.chart.scale.AutoScaleUp | ||
import com.patrykandpatrick.vico.core.chart.values.AxisValuesOverrider | ||
import com.patrykandpatrick.vico.core.entry.FloatEntry | ||
import com.patrykandpatrick.vico.core.entry.entryModelOf | ||
import com.patrykandpatrick.vico.sample.showcase.rememberMarker | ||
import org.jsoup.nodes.Element | ||
import java.time.Month | ||
|
||
class AnalysisTool : ComponentActivity() { | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContent { | ||
PowerOf10Theme { | ||
// A surface container using the 'background' color from the theme | ||
Surface( | ||
modifier = Modifier.fillMaxSize(), | ||
color = MaterialTheme.colors.background | ||
) { | ||
|
||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
fun Greeting(ldata:MutableList<LineData>) { | ||
|
||
|
||
Column { | ||
|
||
|
||
Text(text = "Hello !") | ||
var colors = listOf(Color.Cyan, Color.Blue) | ||
Box(modifier = Modifier | ||
.fillMaxWidth() | ||
.padding(20.dp)) { | ||
LineChart( | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.height(100.dp), | ||
color = colors.first(), | ||
lineData = ldata | ||
) | ||
LineChart( | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.height(100.dp), | ||
color = colors[1], | ||
axisConfig = AxisConfig(false,false,false,false, textColor = Color.Black), | ||
lineData = listOf( | ||
LineData(10F, 0F), | ||
LineData(20F, 23F), | ||
LineData(10F, 0f), | ||
LineData(80F, 0f), | ||
LineData(10F, 0f), | ||
LineData(50F, 50F), | ||
LineData(20F, 35F), | ||
) | ||
) | ||
}} | ||
|
||
} | ||
@Composable | ||
fun BestVSCountryChart (datalist:MutableMap<String, MutableList<FloatEntry>>){ | ||
var axis = listOf("2023","2022","2021","2020","2019","2018") | ||
var marker = rememberMarker() | ||
val chartEntryModel = datalist.values.first() | ||
val bottomAxisValueFormatter = | ||
AxisValueFormatter<AxisPosition.Horizontal.Bottom>{ x, chartVal ->axis[x.toInt()] } | ||
Chart( | ||
chart = lineChart( axisValuesOverrider = AxisValuesOverrider.adaptiveYValues(1f, round = false)), | ||
model = entryModelOf(chartEntryModel, listOf(FloatEntry(0f,6.88f), FloatEntry(1f,6.88f),FloatEntry(2f,6.75f),FloatEntry(3f,6.68f),FloatEntry(4f,6.60f),FloatEntry(5f,6.55f))) , | ||
startAxis = startAxis(), | ||
bottomAxis = bottomAxis(valueFormatter = bottomAxisValueFormatter), | ||
marker = marker, | ||
legend = rememberLegend(), | ||
modifier = Modifier.fillMaxHeight(), | ||
autoScaleUp = AutoScaleUp.Full, | ||
isZoomEnabled = true | ||
) | ||
|
||
} | ||
@Composable | ||
fun BestOverSeasonChart (datalist:MutableList<Element>){ | ||
var xaxis = mutableListOf<String>() | ||
var yaxis = mutableListOf<FloatEntry>() | ||
for (index in 0 until datalist.size){ | ||
xaxis.add(datalist[index].child(11).text()) | ||
yaxis.add(FloatEntry(index.toFloat(),datalist[index].child(1).text().toFloat())) | ||
|
||
} | ||
var marker = rememberMarker() | ||
val chartEntryModel = entryModelOf(yaxis) | ||
val bottomAxisValueFormatter = | ||
AxisValueFormatter<AxisPosition.Horizontal.Bottom>{ x, chartVal ->xaxis[x.toInt()] } | ||
Chart( | ||
chart = lineChart( axisValuesOverrider = AxisValuesOverrider.adaptiveYValues(1f, round = false)), | ||
model = chartEntryModel, | ||
startAxis = startAxis(), | ||
bottomAxis = bottomAxis(tickPosition = | ||
HorizontalAxis.TickPosition.Center(1, 3), valueFormatter = bottomAxisValueFormatter), | ||
marker = marker, | ||
//legend = rememberLegend(), | ||
modifier = Modifier.fillMaxHeight(), | ||
autoScaleUp = AutoScaleUp.Full, | ||
isZoomEnabled = true | ||
) | ||
|
||
} | ||
@Composable | ||
fun BestByVenueChart (datalist:MutableMap<String, MutableList<String>>){ //for individuals | ||
var marker = rememberMarker() | ||
val chartEntryModel = mutableListOf<FloatEntry>() | ||
for (index in 0 until datalist.values.flatten().size){ | ||
chartEntryModel.add(FloatEntry(index.toFloat(),datalist.values.flatten()[index].toFloat()))// this will not work if athlete has only a dnf | ||
} | ||
val bottomAxisValueFormatter = | ||
AxisValueFormatter<AxisPosition.Horizontal.Bottom>{ x, chartVal ->datalist.keys.toList()[x.toInt()] } | ||
Chart( | ||
chart = columnChart( axisValuesOverrider = AxisValuesOverrider.adaptiveYValues(1.005f, round = false)), | ||
model = entryModelOf(chartEntryModel) , | ||
startAxis = startAxis(), | ||
marker = marker, | ||
bottomAxis = bottomAxis(valueFormatter = bottomAxisValueFormatter), | ||
modifier = Modifier.fillMaxHeight(), | ||
autoScaleUp = AutoScaleUp.Full, | ||
isZoomEnabled = true | ||
) | ||
|
||
} | ||
|
||
@Composable | ||
fun VenueByTimesChart (datalist:MutableMap<String, MutableList<String>>){//for country | ||
var marker = rememberMarker() | ||
val chartEntryModel = mutableListOf<FloatEntry>() | ||
for (index in 0 until datalist.values.flatten().size){ | ||
chartEntryModel.add(FloatEntry(index.toFloat(),datalist.values.flatten()[index].toFloat()))// this will not work if athlete has only a dnf | ||
} | ||
val bottomAxisValueFormatter = | ||
AxisValueFormatter<AxisPosition.Horizontal.Bottom>{ x, chartVal ->datalist.keys.toList()[x.toInt()] } | ||
Chart( | ||
chart = columnChart( spacing = 60.dp, axisValuesOverrider = AxisValuesOverrider.adaptiveYValues(1.005f, round = false)), | ||
model = entryModelOf(chartEntryModel) , | ||
startAxis = startAxis(), | ||
marker = marker, | ||
bottomAxis = bottomAxis( valueFormatter = bottomAxisValueFormatter , label = axisLabelComponent(lineCount = 4, textAlign = Paint.Align.CENTER, textSize = 14.sp)), | ||
modifier = Modifier.fillMaxHeight(), | ||
autoScaleUp = AutoScaleUp.Full, | ||
isZoomEnabled = true | ||
) | ||
|
||
} | ||
|
||
@Composable | ||
fun FastestTimeByMonthChart (datalist:MutableMap<Month, MutableList<String>>){//for country | ||
var marker = rememberMarker() | ||
val chartEntryModel = mutableListOf<FloatEntry>() | ||
for (index in 0 until datalist.values.flatten().size){ | ||
chartEntryModel.add(FloatEntry(index.toFloat(),datalist.values.flatten()[index].toFloat()))// this will not work if athlete has only a dnf | ||
} | ||
val bottomAxisValueFormatter = | ||
AxisValueFormatter<AxisPosition.Horizontal.Bottom>{ x, chartVal ->datalist.keys.toList()[x.toInt()].toString() } | ||
Chart( | ||
chart = columnChart( spacing = 60.dp, axisValuesOverrider = AxisValuesOverrider.adaptiveYValues(1.005f, round = false)), | ||
model = entryModelOf(chartEntryModel) , | ||
startAxis = startAxis(), | ||
marker = marker, | ||
bottomAxis = bottomAxis( valueFormatter = bottomAxisValueFormatter , label = axisLabelComponent(lineCount = 4, textAlign = Paint.Align.CENTER, textSize = 14.sp)), | ||
modifier = Modifier.fillMaxHeight(), | ||
autoScaleUp = AutoScaleUp.Full, | ||
isZoomEnabled = true | ||
) | ||
|
||
} | ||
|
||
@Composable | ||
fun PBsByMonthChart (datalist: MutableMap<Month, Int>){//for country | ||
var marker = rememberMarker() | ||
val chartEntryModel = mutableListOf<FloatEntry>() | ||
for (index in 0 until datalist.values.size){ | ||
chartEntryModel.add(FloatEntry(index.toFloat(),datalist.values.toList()[index].toFloat()))// this will not work if athlete has only a dnf | ||
} | ||
val bottomAxisValueFormatter = | ||
AxisValueFormatter<AxisPosition.Horizontal.Bottom>{ x, chartVal ->datalist.keys.toList()[x.toInt()].toString() } | ||
Chart( | ||
chart = columnChart( spacing = 60.dp, axisValuesOverrider = AxisValuesOverrider.adaptiveYValues(1.005f, round = true)), | ||
model = entryModelOf(chartEntryModel) , | ||
startAxis = startAxis(), | ||
marker = marker, | ||
bottomAxis = bottomAxis( valueFormatter = bottomAxisValueFormatter , label = axisLabelComponent(lineCount = 4, textAlign = Paint.Align.CENTER, textSize = 14.sp)), | ||
modifier = Modifier.fillMaxHeight(), | ||
autoScaleUp = AutoScaleUp.Full, | ||
isZoomEnabled = true | ||
) | ||
|
||
} | ||
@Preview(showBackground = true, heightDp = 500) | ||
@Composable | ||
fun DefaultPreview() { | ||
PowerOf10Theme { | ||
} | ||
} |
115 changes: 115 additions & 0 deletions
115
PowerOf10/app/src/main/java/com/example/powerof10/AthleteDataCollection.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
package com.example.powerof10 | ||
|
||
import com.patrykandpatrick.vico.core.entry.FloatEntry | ||
import com.patrykandpatrick.vico.core.entry.entryModelOf | ||
import org.jsoup.nodes.Element | ||
import java.text.SimpleDateFormat | ||
import java.time.LocalDate | ||
import java.time.Month | ||
import java.time.format.DateTimeFormatter | ||
|
||
class AthleteDataCollection { | ||
val yearly60times = entryModelOf(6.45f,6.56f,6.59f,6.53f,6.53f,6.53f) | ||
|
||
suspend fun lifetimePerformances(): MutableMap<String, MutableList<FloatEntry>> { | ||
var html = getHTML("profile.aspx?athleteid=525045") | ||
var bestPerf = getBestPerformances(html) | ||
var lineData= mutableMapOf<String,MutableList<FloatEntry> >()// Example (Key:60,Value:(6.59,6.56,6.78)) | ||
for (event in 1 until bestPerf.size){//for every event that the athlete has on their page | ||
var performances = mutableListOf<FloatEntry>() | ||
for(it in 0..5){//retrieves the last 5 years | ||
if (!bestPerf.eq(event).first()?.child(it + 2)?.text()!!.replace("i","").isNullOrEmpty()){//checks if the athlete has an SB for that season | ||
performances.add(FloatEntry(x = it.toFloat(),y=bestPerf.eq(event).first()?.child(it + 2)?.text()!!.replace("i","").replace(":","").replace("w","").substringBefore("/").toFloat()))//formats results like "6.34i" or "11.23/11.11w" to float | ||
} else { | ||
//performances.add(FloatEntry(0f,0f)) | ||
} | ||
|
||
} | ||
lineData.put(bestPerf.eq(event).first()?.child(0 )?.text()!!.replace("i",""), performances) | ||
|
||
} | ||
|
||
//return line | ||
|
||
return (lineData) | ||
|
||
|
||
|
||
} | ||
} | ||
|
||
|
||
suspend fun Overall60Season(): MutableList<Element> { | ||
var html = getHTML("profile.aspx?athleteid=525045") | ||
var data = getAllPerformances(html).first()!!.children() | ||
var allPerformances60 = mutableListOf<Element>()//empty array for each performance | ||
data.removeFirst()//removes headers | ||
var dataList = data.sortedBy { SimpleDateFormat("dd MMM yy").parse(it.child(11).text()) } | ||
for (performance in dataList){//in all performances | ||
if (performance.firstElementChild()!!.text()=="60"){ | ||
allPerformances60.add(performance)//add to the allperformances60 array if its a 60m event | ||
} | ||
} | ||
|
||
return(allPerformances60) | ||
|
||
} | ||
|
||
|
||
suspend fun timeByVenue(): MutableMap<String, MutableList<String>> { | ||
var html = getHTML("profile.aspx?athleteid=21361") | ||
var data = getAllPerformances(html).first()!!.children() | ||
var allPerformances60 = mutableListOf<Element>()//empty array for each performance | ||
for (performance in data){//in all performances | ||
if (performance.firstElementChild()!!.text()=="60"){ | ||
allPerformances60.add(performance)//add to the allperformances60 array if its a 60m event | ||
} | ||
} | ||
var grouped = allPerformances60.groupByTo (mutableMapOf(),{it.child(9).text() },{it.child(1).text()}) | ||
for (key in grouped.keys){ | ||
grouped[key.toString()] = mutableListOf(grouped[key.toString()]!!.min()) | ||
} | ||
|
||
return(grouped) | ||
} | ||
suspend fun PbsByVenue(): MutableMap<String, MutableList<String>> { | ||
var html = getHTML("60","All","Men","2023").getElementsByAttributeValueContaining("class", "rlr") | ||
var grouped = html.groupByTo(mutableMapOf(),{it.child(11).text() },{it.child(1).text()}) | ||
for (key in grouped.keys){ | ||
grouped[key.toString()] = mutableListOf(grouped[key.toString()]!!.min()) | ||
} | ||
return(grouped) | ||
|
||
} | ||
|
||
suspend fun FastestByMonth(): MutableMap<Month, MutableList<String>> { | ||
var data = getHTML("60","All","Men","2023").getElementsByAttributeValueContaining("class", "rlr") | ||
|
||
var grouped = data.groupByTo(mutableMapOf(),{ LocalDate.parse(it.child(12).text(), DateTimeFormatter.ofPattern("d MMM uu")).month },{it.child(1).text()}) | ||
for (key in grouped.keys){ | ||
grouped[key] = mutableListOf(grouped[key]!!.min()) | ||
} | ||
|
||
return(grouped) | ||
|
||
} | ||
suspend fun PBsByMonth(): MutableMap<Month, Int> { | ||
var data = getHTML("60","All","Men","2023").getElementsByAttributeValueContaining("class", "rlr") | ||
var PBsPerformances = mutableListOf<Element>()//empty array for each performance | ||
data.forEach{ | ||
if(it.child(5).firstElementChild()?.hasClass("rlpb") == true){ | ||
PBsPerformances.add(it) | ||
} | ||
} | ||
var grouped = PBsPerformances.groupingBy { LocalDate.parse(it.child(12).text(), DateTimeFormatter.ofPattern("d MMM uu")).month }.eachCount().toMutableMap() | ||
|
||
println(grouped.javaClass.name) | ||
|
||
return(grouped) | ||
|
||
|
||
} | ||
suspend fun main(){ | ||
(PBsByMonth()) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
156 changes: 156 additions & 0 deletions
156
PowerOf10/app/src/main/java/com/example/powerof10/ChartsPage.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
package com.example.powerof10 | ||
|
||
//import androidx.compose.ui.platform.LocalContext | ||
import android.annotation.SuppressLint | ||
import androidx.compose.animation.* | ||
import androidx.compose.foundation.Image | ||
import androidx.compose.foundation.layout.* | ||
import androidx.compose.foundation.lazy.LazyColumn | ||
import androidx.compose.material.* | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.filled.Menu | ||
import androidx.compose.material3.CenterAlignedTopAppBar | ||
import androidx.compose.material3.ExperimentalMaterial3Api | ||
import androidx.compose.material3.TopAppBarDefaults | ||
import androidx.compose.runtime.* | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.layout.ContentScale | ||
import androidx.compose.ui.res.painterResource | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import androidx.navigation.NavController | ||
import androidx.navigation.compose.rememberNavController | ||
import com.example.powerof10.Components.NavDrawerBody | ||
import com.example.powerof10.ui.theme.PowerOf10Theme | ||
import com.patrykandpatrick.vico.core.entry.FloatEntry | ||
import kotlinx.coroutines.launch | ||
import org.jsoup.nodes.Element | ||
import java.time.Month | ||
|
||
|
||
@SuppressLint("UnusedMaterialScaffoldPaddingParameter") | ||
@OptIn(ExperimentalMaterial3Api::class) | ||
@Composable | ||
fun ChartsPage(navController: NavController) { | ||
val powerOfTen = painterResource(id = R.drawable.powerof10) | ||
val scaffoldState = rememberScaffoldState() | ||
var isRSSLoading by remember { mutableStateOf(true) } //the state of whether the rss data has loaded yet | ||
var ldata by remember { mutableStateOf(mutableMapOf("60" to mutableListOf<FloatEntry>())) } | ||
val scope = rememberCoroutineScope() | ||
var chart2data by remember { mutableStateOf(mutableListOf<Element>()) } | ||
var chart3data by remember { mutableStateOf(mutableMapOf<String,MutableList<String>>()) } | ||
var chart4data by remember { mutableStateOf(mutableMapOf<String,MutableList<String>>()) } | ||
var chart5data by remember { mutableStateOf(mutableMapOf<Month,MutableList<String>>()) } | ||
var chart6data by remember { mutableStateOf(mutableMapOf<Month, Int>()) } | ||
LaunchedEffect(Unit) { | ||
chart2data = Overall60Season() | ||
chart3data = timeByVenue() | ||
chart4data = PbsByVenue() | ||
chart5data = FastestByMonth() | ||
chart6data = PBsByMonth() | ||
isRSSLoading = false | ||
ldata = AthleteDataCollection().lifetimePerformances() | ||
println(ldata) | ||
|
||
} | ||
|
||
//var context = LocalContext.current | ||
if (isRSSLoading) {// if the RSS hasn't loaded circular progress indicator will appear | ||
Box( | ||
contentAlignment = Alignment.Center, | ||
modifier = Modifier.fillMaxSize() | ||
) { | ||
CircularProgressIndicator() | ||
} | ||
} | ||
if (!isRSSLoading) {// hides everything till loaded | ||
Column { | ||
|
||
Scaffold( | ||
scaffoldState = scaffoldState, | ||
topBar = { | ||
CenterAlignedTopAppBar(modifier = Modifier.fillMaxWidth(), | ||
title = { | ||
Image( | ||
painter = powerOfTen, | ||
contentDescription = "Power of Ten Logo", | ||
modifier = Modifier.padding(5.dp), | ||
contentScale = ContentScale.FillBounds | ||
) | ||
}, | ||
colors = TopAppBarDefaults.centerAlignedTopAppBarColors( | ||
Color(0xFFE5383B), | ||
navigationIconContentColor = Color.White | ||
), | ||
navigationIcon = { | ||
IconButton(onClick = { scope.launch { scaffoldState.drawerState.open() } }) { | ||
Icon( | ||
Icons.Filled.Menu, contentDescription = null, | ||
tint = Color.White, | ||
modifier = Modifier.size(48.dp) | ||
) | ||
} | ||
} | ||
) | ||
}, | ||
drawerContent = { | ||
NavDrawerBody( | ||
items = NavigationOptions.nav, | ||
onItemClick = { navController.navigate(route = it.route) } | ||
) | ||
}, | ||
content = { | ||
LazyColumn(modifier =Modifier.fillMaxSize() , content = { | ||
item{ | ||
Text(text = "Louie Hinchliffe") | ||
Text(text = "Perf vs Country by year") | ||
BestVSCountryChart(ldata) | ||
Text(text = "Eugene Amo Dadzie") | ||
Text(text = "Perf over season") | ||
BestOverSeasonChart(chart2data) | ||
Text(text = "Andrew Robinson") | ||
Text(text = "Best Performance by Venue") | ||
BestByVenueChart(chart3data) | ||
Text(text = "Overall Men") | ||
Text(text = "Best Performance by Venue") | ||
VenueByTimesChart(chart4data) | ||
Text(text = "Overall Men") | ||
Text(text = "Best Performance by Month") | ||
FastestTimeByMonthChart(chart5data) | ||
Text(text = "Overall Men") | ||
Text(text = "PBs by Month") | ||
PBsByMonthChart(chart6data) | ||
} | ||
|
||
|
||
}) | ||
} | ||
) | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
} | ||
|
||
} | ||
} | ||
|
||
|
||
@Preview(name = "PIXEL_45") | ||
@Composable | ||
fun DefaultPreview8() { | ||
|
||
val navController = rememberNavController() | ||
PowerOf10Theme { | ||
//AthleteProfile(navController)//, viewModel) | ||
//ExpandableView(performances = Elements(), isExpanded = true) | ||
} | ||
} | ||
|
33 changes: 33 additions & 0 deletions
33
PowerOf10/app/src/main/java/com/example/powerof10/Components/Legend.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.example.powerof10.Components | ||
|
||
import android.graphics.Typeface | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.unit.dp | ||
import androidx.compose.ui.unit.sp | ||
import com.patrykandpatrick.vico.compose.component.shapeComponent | ||
import com.patrykandpatrick.vico.compose.component.textComponent | ||
import com.patrykandpatrick.vico.compose.dimensions.dimensionsOf | ||
import com.patrykandpatrick.vico.compose.legend.verticalLegend | ||
import com.patrykandpatrick.vico.compose.legend.verticalLegendItem | ||
import com.patrykandpatrick.vico.compose.style.currentChartStyle | ||
import com.patrykandpatrick.vico.core.component.shape.Shapes | ||
|
||
var chartColors = listOf(Color.Red,Color.Yellow) | ||
@Composable | ||
fun rememberLegend() = verticalLegend( | ||
items = chartColors.mapIndexed { index, chartColor -> | ||
verticalLegendItem( | ||
icon = shapeComponent(Shapes.pillShape, chartColor), | ||
label = textComponent( | ||
color = currentChartStyle.axis.axisLabelColor, | ||
textSize = 16.sp, | ||
typeface = Typeface.MONOSPACE, | ||
), | ||
labelText = " Dataset $index", | ||
) | ||
}, | ||
iconSize = 16.dp, | ||
iconPadding = 0.dp, | ||
padding = dimensionsOf(top = 0.dp), | ||
) |
118 changes: 118 additions & 0 deletions
118
PowerOf10/app/src/main/java/com/example/powerof10/Components/Marker.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
|
||
/* | ||
* Copyright 2023 by Patryk Goworowski and Patrick Michalik. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.patrykandpatrick.vico.sample.showcase | ||
|
||
import android.graphics.Typeface | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.graphics.toArgb | ||
import androidx.compose.ui.unit.dp | ||
import com.patrykandpatrick.vico.compose.component.lineComponent | ||
import com.patrykandpatrick.vico.compose.component.overlayingComponent | ||
import com.patrykandpatrick.vico.compose.component.shapeComponent | ||
import com.patrykandpatrick.vico.compose.component.textComponent | ||
import com.patrykandpatrick.vico.compose.dimensions.dimensionsOf | ||
import com.patrykandpatrick.vico.core.chart.insets.Insets | ||
import com.patrykandpatrick.vico.core.chart.segment.SegmentProperties | ||
import com.patrykandpatrick.vico.core.component.marker.MarkerComponent | ||
import com.patrykandpatrick.vico.core.component.shape.DashedShape | ||
import com.patrykandpatrick.vico.core.component.shape.ShapeComponent | ||
import com.patrykandpatrick.vico.core.component.shape.Shapes | ||
import com.patrykandpatrick.vico.core.component.shape.cornered.Corner | ||
import com.patrykandpatrick.vico.core.component.shape.cornered.MarkerCorneredShape | ||
import com.patrykandpatrick.vico.core.context.MeasureContext | ||
import com.patrykandpatrick.vico.core.extension.copyColor | ||
import com.patrykandpatrick.vico.core.marker.Marker | ||
|
||
@Composable | ||
internal fun rememberMarker(): Marker { | ||
val labelBackgroundColor = MaterialTheme.colorScheme.surface | ||
val labelBackground = remember(labelBackgroundColor) { | ||
ShapeComponent(labelBackgroundShape, labelBackgroundColor.toArgb()).setShadow( | ||
radius = LABEL_BACKGROUND_SHADOW_RADIUS, | ||
dy = LABEL_BACKGROUND_SHADOW_DY, | ||
applyElevationOverlay = true, | ||
) | ||
} | ||
val label = textComponent( | ||
background = labelBackground, | ||
lineCount = LABEL_LINE_COUNT, | ||
padding = labelPadding, | ||
typeface = Typeface.MONOSPACE, | ||
) | ||
val indicatorInnerComponent = shapeComponent(Shapes.pillShape, MaterialTheme.colorScheme.surface) | ||
val indicatorCenterComponent = shapeComponent(Shapes.pillShape, Color.White) | ||
val indicatorOuterComponent = shapeComponent(Shapes.pillShape, Color.White) | ||
val indicator = overlayingComponent( | ||
outer = indicatorOuterComponent, | ||
inner = overlayingComponent( | ||
outer = indicatorCenterComponent, | ||
inner = indicatorInnerComponent, | ||
innerPaddingAll = indicatorInnerAndCenterComponentPaddingValue, | ||
), | ||
innerPaddingAll = indicatorCenterAndOuterComponentPaddingValue, | ||
) | ||
val guideline = lineComponent( | ||
MaterialTheme.colorScheme.onSurface.copy(GUIDELINE_ALPHA), | ||
guidelineThickness, | ||
guidelineShape, | ||
) | ||
return remember(label, indicator, guideline) { | ||
object : MarkerComponent(label, indicator, guideline) { | ||
init { | ||
indicatorSizeDp = INDICATOR_SIZE_DP | ||
onApplyEntryColor = { entryColor -> | ||
indicatorOuterComponent.color = entryColor.copyColor(INDICATOR_OUTER_COMPONENT_ALPHA) | ||
with(indicatorCenterComponent) { | ||
color = entryColor | ||
setShadow(radius = INDICATOR_CENTER_COMPONENT_SHADOW_RADIUS, color = entryColor) | ||
} | ||
} | ||
} | ||
|
||
override fun getInsets(context: MeasureContext, outInsets: Insets, segmentProperties: SegmentProperties) = | ||
with(context) { | ||
outInsets.top = label.getHeight(context) + labelBackgroundShape.tickSizeDp.pixels + | ||
LABEL_BACKGROUND_SHADOW_RADIUS.pixels * SHADOW_RADIUS_MULTIPLIER - | ||
LABEL_BACKGROUND_SHADOW_DY.pixels | ||
} | ||
} | ||
} | ||
} | ||
|
||
private const val LABEL_BACKGROUND_SHADOW_RADIUS = 4f | ||
private const val LABEL_BACKGROUND_SHADOW_DY = 2f | ||
private const val LABEL_LINE_COUNT = 1 | ||
private const val GUIDELINE_ALPHA = .2f | ||
private const val INDICATOR_SIZE_DP = 36f | ||
private const val INDICATOR_OUTER_COMPONENT_ALPHA = 32 | ||
private const val INDICATOR_CENTER_COMPONENT_SHADOW_RADIUS = 12f | ||
private const val GUIDELINE_DASH_LENGTH_DP = 8f | ||
private const val GUIDELINE_GAP_LENGTH_DP = 4f | ||
private const val SHADOW_RADIUS_MULTIPLIER = 1.3f | ||
|
||
private val labelBackgroundShape = MarkerCorneredShape(Corner.FullyRounded) | ||
private val labelHorizontalPaddingValue = 8.dp | ||
private val labelVerticalPaddingValue = 4.dp | ||
private val labelPadding = dimensionsOf(labelHorizontalPaddingValue, labelVerticalPaddingValue) | ||
private val indicatorInnerAndCenterComponentPaddingValue = 5.dp | ||
private val indicatorCenterAndOuterComponentPaddingValue = 10.dp | ||
private val guidelineThickness = 2.dp | ||
private val guidelineShape = DashedShape(Shapes.pillShape, GUIDELINE_DASH_LENGTH_DP, GUIDELINE_GAP_LENGTH_DP) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
159 changes: 159 additions & 0 deletions
159
PowerOf10/app/src/main/java/com/example/powerof10/LineChartDemo.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
package com.himanshoe.charty.ui | ||
|
||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.lazy.LazyColumn | ||
import androidx.compose.material.MaterialTheme.colors | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.text.style.TextAlign | ||
import androidx.compose.ui.unit.dp | ||
import androidx.compose.ui.unit.sp | ||
import com.himanshoe.charty.common.axis.AxisConfig | ||
import com.himanshoe.charty.line.LineChart | ||
import com.himanshoe.charty.line.config.LineConfig | ||
import com.himanshoe.charty.line.model.LineData | ||
|
||
@Composable | ||
fun LineChartDemo() { | ||
var colors = listOf(Color.Cyan,Color.Blue) | ||
LazyColumn( | ||
modifier = Modifier | ||
.fillMaxSize() | ||
.padding(32.dp) | ||
) { | ||
item { | ||
LineChart( | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.height(300.dp), | ||
|
||
colors = colors, | ||
lineData = listOf( | ||
LineData(10F, 35F), | ||
LineData(20F, 25F), | ||
LineData(20F, 25F), | ||
LineData(20F, 25F), | ||
LineData(20F, 25F), | ||
LineData(20F, 25F), | ||
LineData(20F, 25F), | ||
LineData(20F, 25F), | ||
LineData(20F, 25F), | ||
LineData(20F, 25F), | ||
LineData(20F, 25F), | ||
LineData(20F, 25F), | ||
LineData(20F, 25F), | ||
LineData(20F, 25F), | ||
LineData(20F, 25F), | ||
LineData(20F, 25F), | ||
LineData(20F, 25F), | ||
LineData(20F, 25F), | ||
LineData(20F, 25F), | ||
LineData(20F, 25F), | ||
LineData(10F, 50F), | ||
LineData(80F, 10F), | ||
LineData(10F, 15F), | ||
LineData(50F, 100F), | ||
LineData(20F, 25F), | ||
) | ||
) | ||
} | ||
item { | ||
Text( | ||
text = "Gradient Line Chart", | ||
fontSize = 16.sp, | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.padding(vertical = 32.dp), | ||
textAlign = TextAlign.Center | ||
) | ||
} | ||
item { | ||
LineChart( | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.height(300.dp), | ||
color = colors.first(), | ||
lineData = listOf( | ||
LineData(10F, 35F), | ||
LineData(20F, 25F), | ||
LineData(10F, 50F), | ||
LineData(80F, 10F), | ||
LineData(10F, 15F), | ||
LineData(50F, 100F), | ||
LineData(20F, 25F), | ||
) | ||
) | ||
} | ||
item { | ||
Text( | ||
text = "Solid Line Chart", | ||
fontSize = 16.sp, | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.padding(vertical = 32.dp), | ||
textAlign = TextAlign.Center | ||
) | ||
} | ||
item { | ||
LineChart( | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.height(300.dp), | ||
color = colors.first(), | ||
lineConfig = LineConfig(hasDotMarker = false), | ||
lineData = listOf( | ||
LineData(10F, 35F), | ||
LineData(20F, 25F), | ||
LineData(10F, 50F), | ||
LineData(80F, 10F), | ||
LineData(10F, 15F), | ||
LineData(50F, 100F), | ||
LineData(20F, 25F), | ||
) | ||
) | ||
} | ||
item { | ||
Text( | ||
text = "Line Chart without marker", | ||
fontSize = 16.sp, | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.padding(vertical = 32.dp), | ||
textAlign = TextAlign.Center | ||
) | ||
} | ||
item { | ||
LineChart( | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.height(300.dp), | ||
color = colors.first(), | ||
lineConfig = LineConfig(hasSmoothCurve = true), | ||
lineData = listOf( | ||
LineData(10F, 35F), | ||
LineData(20F, 25F), | ||
LineData(10F, 50F), | ||
LineData(80F, 10F), | ||
LineData(10F, 15F), | ||
LineData(50F, 100F), | ||
LineData(20F, 25F), | ||
) | ||
) | ||
} | ||
item { | ||
Text( | ||
text = "Line Chart with smooth curve", | ||
fontSize = 16.sp, | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.padding(vertical = 32.dp), | ||
textAlign = TextAlign.Center | ||
) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
PowerOf10/app/src/main/java/com/example/powerof10/NavigationOptions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.example.powerof10 | ||
|
||
object NavigationOptions{ | ||
val nav = listOf( | ||
MenuItems(1, "Home",Screen.HomepageRSS.route), | ||
MenuItems(2, "Rankings",Screen.RankingPage.route), | ||
MenuItems(3, "Athlete Search",Screen.AthleteSearch.route), | ||
MenuItems(4, "Charts",Screen.ChartsPage.route) | ||
) | ||
} |
60 changes: 0 additions & 60 deletions
60
PowerOf10/app/src/main/java/com/example/powerof10/RSSActivity.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters