Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
8a3ceae
Merge pull request #76 from TheChance101/develop
amnah44 Sep 8, 2023
2c076df
Revert "Develop"
yassenRamadan1 Sep 8, 2023
54d9a8c
Merge pull request #77 from TheChance101/revert-76-develop
amnah44 Sep 8, 2023
1131170
complete the publishing
yassenRamadan1 Sep 9, 2023
edb2a04
convert format function to depend on kotlin pure
yassenRamadan1 Sep 9, 2023
11ee135
add ios dependencies
yassenRamadan1 Sep 9, 2023
4a0e97a
fix the grid
yassenRamadan1 Sep 9, 2023
c6d7622
complete the publishing
yassenRamadan1 Sep 9, 2023
86d105f
Merge pull request #78 from TheChance101/fix/start-spacing
amnah44 Sep 9, 2023
205ab1c
complete the ios publishing
yassenRamadan1 Sep 10, 2023
c8dec1f
add ios configuration
amnah44 Sep 10, 2023
a322f53
remove unusable code
amnah44 Sep 10, 2023
d227f4e
Merge pull request #79 from TheChance101/fix/ios-publish
AndrewAboalhana Sep 10, 2023
12c9602
Update README.md
amnah44 Sep 11, 2023
24f0784
remove local properties
amnah44 Sep 11, 2023
19102b5
Merge pull request #83 from TheChance101/fix/ios-publish
iBareq Sep 11, 2023
4465fe5
Merge pull request #82 from TheChance101/amnah44-patch-1
iBareq Sep 11, 2023
9f99950
integrate web with aay-chart
AndrewAboalhana Sep 11, 2023
63c5c8f
add dependency for web integration
AndrewAboalhana Sep 11, 2023
e7c495e
fix error when run desktop
AndrewAboalhana Sep 11, 2023
04e517e
fix error with android dependency in chart
AndrewAboalhana Sep 11, 2023
e45644a
Merge pull request #85 from TheChance101/feature/web-dependency
yassenRamadan1 Sep 11, 2023
5fdc15f
fix label drawing
aya-seif Sep 12, 2023
a3d7bbd
determine size using aspect ratio
aya-seif Sep 13, 2023
106c43a
cleanup radar chart functions
aya-seif Sep 13, 2023
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<div align="left">
The library contains several chart composables for usage in <strong>Kotlin Multiplatform</strong> projects and <strong>Android Native</strong>.
Currently supported platforms are <strong>Desktop</strong> <strong>Android</strong> and soon <strong>IOS </strong></strong>
Currently supported platforms are <strong>Desktop</strong> <strong>Android</strong> and <strong>IOS </strong></strong>
</div>

&nbsp;
Expand Down
1 change: 0 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ allprojects {

plugins {
kotlin("multiplatform") apply false
kotlin("native.cocoapods") version "1.8.0"
kotlin("android") apply false
id("com.android.application") apply false
id("com.android.library") apply false
Expand Down
65 changes: 22 additions & 43 deletions chart/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,35 +1,38 @@

plugins {
kotlin("multiplatform")
id("org.jetbrains.compose")
id("com.android.library")
id("org.jetbrains.dokka") version "1.5.0"
id("convention.publication")
id ("org.jetbrains.kotlin.native.cocoapods") version "1.8.0"
kotlin("native.cocoapods")
}
group = "io.github.thechance101"
version = "Beta-0.0.1"
version = "Beta-0.0.5"

kotlin {
android {
publishLibraryVariants("release","debug")
publishLibraryVariants("release", "debug")
}
jvm("desktop") {
jvmToolchain(11)
}
ios{}
iosX64()
iosArm64()
iosSimulatorArm64()
cocoapods {
version = "1.0.0"
summary = "Some description for the chart Module"
homepage = "Link to the chart Module homepage"
ios.deploymentTarget = "14.1"
podfile = project.file("../iosApp/Podfile")
framework {
baseName = "chart"
isStatic = true

js(IR) {
browser {
testTask {
useKarma {
useChromeHeadless()
webpackConfig.cssSupport {
enabled.set(true)
}
}
}
}
binaries.executable()
}

sourceSets {
Expand All @@ -40,42 +43,30 @@ kotlin {
api(compose.material)
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
}
}

val androidMain by getting {
dependencies {
api("androidx.appcompat:appcompat:1.5.1")
api("androidx.core:core-ktx:1.9.0")
}
}
val androidTest by getting {
dependencies {
implementation("junit:junit:4.13.2")
}
}

val desktopMain by getting {
dependencies {
api(compose.preview)
}
}
val desktopTest by getting


val iosX64Main by getting
val iosArm64Main by getting
val iosSimulatorArm64Main by getting
val iosMain by creating {
val iosMain by getting {
dependsOn(commonMain)
iosX64Main.dependsOn(this)
iosArm64Main.dependsOn(this)
iosSimulatorArm64Main.dependsOn(this)
dependencies {
implementation("io.ktor:ktor-client-darwin:2.3.3")
}

}
val jsMain by getting
}
}

Expand All @@ -91,16 +82,4 @@ android {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
buildTypes {
getByName("release") {
isMinifyEnabled = true
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
}
create("staging") {
initWith(getByName("release"))
manifestPlaceholders["TheChance101"] = "io.github.thechance101"
}
}
}


}
39 changes: 0 additions & 39 deletions chart/chart.podspec

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ internal fun <T> DrawScope.xAxisDrawing(
val yTextLayoutResult = textMeasure.measure(
text = AnnotatedString(upperValue.formatToThousandsMillionsBillions()),
).size.width
val textSpace = yTextLayoutResult - (yTextLayoutResult/4)

xAxisData.forEachIndexed { index, dataPoint ->
val xLength = (yTextLayoutResult.toDp()) + (index * xRegionWidth)
val xLength = (textSpace.toDp()) + (index * xRegionWidth)

drawContext.canvas.nativeCanvas.apply {
drawText(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ internal fun DrawScope.grid(
val yTextLayoutResult = textMeasurer.measure(
text = AnnotatedString(upperValue.formatToThousandsMillionsBillions()),
).size.width

val textSpace = yTextLayoutResult - (yTextLayoutResult/4)

if (isShowGrid) {
when (gridOrientation) {
Expand All @@ -45,7 +45,7 @@ internal fun DrawScope.grid(
gridColor = gridColor,
backgroundLineWidth = backgroundLineWidth,
showGridWithSpacer = showGridWithSpacer,
yTextLayoutResult = yTextLayoutResult
yTextLayoutResult = textSpace
)

GridOrientation.VERTICAL -> drawVerticalGrid(
Expand All @@ -54,7 +54,7 @@ internal fun DrawScope.grid(
gridColor = gridColor,
backgroundLineWidth = backgroundLineWidth,
showGridWithSpacer = showGridWithSpacer,
yTextLayoutResult = yTextLayoutResult
yTextLayoutResult = textSpace
)

else -> {
Expand All @@ -65,7 +65,7 @@ internal fun DrawScope.grid(
xEndLength = 38.dp.toPx(),
backgroundLineWidth = backgroundLineWidth,
showGridWithSpacer = showGridWithSpacer,
yTextLayoutResult = yTextLayoutResult
yTextLayoutResult = textSpace
)

drawVerticalGrid(
Expand All @@ -75,7 +75,7 @@ internal fun DrawScope.grid(
yEndLength = 9f.toDp(),
backgroundLineWidth = backgroundLineWidth,
showGridWithSpacer = showGridWithSpacer,
yTextLayoutResult = yTextLayoutResult
yTextLayoutResult = textSpace
)
}

Expand All @@ -90,12 +90,14 @@ private fun DrawScope.drawHorizontalGrid(
xEndLength: Float = 0f,
backgroundLineWidth: Float,
showGridWithSpacer: Boolean,
yTextLayoutResult: Int
yTextLayoutResult: Int,
) {

val xAxisMaxValue = size.width
val yAxisList = mutableListOf<Float>()

val textSpace = yTextLayoutResult - (yTextLayoutResult/4)

(0..yAxisRange).forEach { i ->
yAxisList.add(
size.height.toDp()
Expand All @@ -107,7 +109,7 @@ private fun DrawScope.drawHorizontalGrid(
gridColor = gridColor,
xStart = (yTextLayoutResult * 1.5.toFloat().toDp()).toPx(),
yStart = yAlignmentValue,
xEnd = xAxisMaxValue - xEndLength,
xEnd = xAxisMaxValue - (textSpace/0.9.toFloat().toDp().toPx()),
yEnd = yAlignmentValue,
backgroundLineWidth = backgroundLineWidth,
showGridWithSpacer = showGridWithSpacer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ internal fun DrawScope.drawPedigreeChart(
val angleInRadians = (startArcWithoutAnimation + arcWithoutAnimation / 2).degreeToAngle
if (pieChart == ChartTypes.PIE_CHART) {
val lineStart = Offset(
center.x + (outerCircularRadius * 1.18f) * cos(angleInRadians) * 0.8f,
center.y + (outerCircularRadius * 1.18f) * sin(angleInRadians) * 0.8f
(center.x + (outerCircularRadius * 1.18f) * cos(angleInRadians) * 0.8f).toFloat(),
(center.y + (outerCircularRadius * 1.18f) * sin(angleInRadians) * 0.8f).toFloat()
)
val lineEnd = Offset(
center.x + (outerCircularRadius * 1.18f) * cos(angleInRadians) * 1.1f,
center.y + (outerCircularRadius * 1.18f) * sin(angleInRadians) * 1.1f
(center.x + (outerCircularRadius * 1.18f) * cos(angleInRadians) * 1.1f).toFloat(),
(center.y + (outerCircularRadius * 1.18f) * sin(angleInRadians) * 1.1f).toFloat()
)
val arcOffset = Offset(center.x - (minValue / 2), center.y - (minValue / 2))
val region = pieValueWithRatio.subList(0, index).sum()
Expand Down Expand Up @@ -88,12 +88,12 @@ internal fun DrawScope.drawPedigreeChart(

} else {
val lineStart = Offset(
center.x + (outerCircularRadius * 1.18f) * cos(angleInRadians) * 0.8f,
center.y + (outerCircularRadius * 1.18f) * sin(angleInRadians) * 0.8f
(center.x + (outerCircularRadius * 1.18f) * cos(angleInRadians) * 0.8f).toFloat(),
(center.y + (outerCircularRadius * 1.18f) * sin(angleInRadians) * 0.8f).toFloat()
)
val lineEnd = Offset(
center.x + (outerCircularRadius * 1.18f) * cos(angleInRadians) * 1.1f,
center.y + (outerCircularRadius * 1.18f) * sin(angleInRadians) * 1.1f
(center.x + (outerCircularRadius * 1.18f) * cos(angleInRadians) * 1.1f).toFloat(),
(center.y + (outerCircularRadius * 1.18f) * sin(angleInRadians) * 1.1f).toFloat()
)
val arcOffset = Offset(center.x - (minValue / 2), center.y - (minValue / 2))
val region = pieValueWithRatio.subList(0, index).sum()
Expand Down Expand Up @@ -132,7 +132,7 @@ internal fun DrawScope.drawPedigreeChart(
}

private val Float.degreeToAngle
get() = (this * Math.PI / 180f).toFloat()
get() = (this * (22/7) / 180f)

private fun calculateAngle(dataLength: Float, totalLength: Float, progress: Float): Float =
-360F * dataLength * progress / totalLength
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ private fun DrawScope.drawLineAsDefault(
val yTextLayoutResult = textMeasure.measure(
text = AnnotatedString(upperValue.formatToThousandsMillionsBillions()),
).size.width

val textSpace = yTextLayoutResult - (yTextLayoutResult/4)
val info = lineParameter.data[index]
val ratio = (info - lowerValue) / (upperValue - lowerValue)
val startXPoint = (yTextLayoutResult * 1.5.toFloat().toDp()) + (index * xRegionWidth)
val startXPoint = (textSpace * 1.5.toFloat().toDp()) + (index * xRegionWidth)
val startYPoint =
(height.toPx() + 8.dp.toPx() - spacingY.toPx() - (ratio * (height.toPx() - spacingY.toPx())))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,16 @@ fun DrawScope.drawLineAsQuadratic(
val yTextLayoutResult = textMeasurer.measure(
text = AnnotatedString(upperValue.formatToThousandsMillionsBillions()),
).size.width

val textSpace = yTextLayoutResult - (yTextLayoutResult/4)

val info = lineParameter.data[index]
val nextInfo = lineParameter.data.getOrNull(index + 1) ?: lineParameter.data.last()
val firstRatio = (info - lowerValue) / (upperValue - lowerValue)
val secondRatio = (nextInfo - lowerValue) / (upperValue - lowerValue)

val xFirstPoint = (yTextLayoutResult * 1.5.toFloat().toDp()) + index * xRegionWidth
val xFirstPoint = (textSpace * 1.5.toFloat().toDp()) + index * xRegionWidth
val xSecondPoint =
(yTextLayoutResult * 1.5.toFloat().toDp()) + (index + checkLastIndex(
(textSpace * 1.5.toFloat().toDp()) + (index + checkLastIndex(
lineParameter.data,
index
)) * xRegionWidth
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal fun calculateRadarConfig(
val netCornersPoints = mutableListOf<Offset>()
val stepsStartPoints = mutableListOf<Offset>()
val stepsEndPoints = mutableListOf<Offset>()
val polygonPoints = mutableListOf<Offset>()
val scalarValuesPoints = mutableListOf<Offset>()
val labelsPoints = mutableListOf<Offset>()

val center = Offset(size.width / 2, size.height / 2)
Expand All @@ -42,12 +42,12 @@ internal fun calculateRadarConfig(
val nextEndPoint = getCircumferencePointOffset(center, value * step, nextAngle)
stepsStartPoints.add(startEndPoint)
stepsEndPoints.add(nextEndPoint)
if (lineIndex == 0) polygonPoints.add(startEndPoint)
if (lineIndex == 0) scalarValuesPoints.add(startEndPoint)
}
}

return RadarChartConfig(
center, netCornersPoints, stepsEndPoints, stepsStartPoints, polygonPoints, labelsPoints
center, netCornersPoints, stepsEndPoints, stepsStartPoints, scalarValuesPoints, labelsPoints
)
}

Expand Down
Loading