From 44e54d0dd3c1268941314d5ea8c9eebae5f71a5e Mon Sep 17 00:00:00 2001 From: oky2abbas Date: Mon, 19 Oct 2020 22:42:26 +0330 Subject: [PATCH] update license and README and review code --- LICENSE | 4 +- README.md | 73 +++++++------------ .../java/com/naqdi/chart/ChainChartView.kt | 2 +- .../com/naqdi/chart/utils/ConversionsExt.kt | 2 +- sample/src/main/res/layout/main_activity.xml | 43 ++++++----- 5 files changed, 52 insertions(+), 72 deletions(-) diff --git a/LICENSE b/LICENSE index b9a9536..051ba66 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2021 amir abbas naqdi +Copyright (c) 2021 amir abbas naqdi Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +SOFTWARE \ No newline at end of file diff --git a/README.md b/README.md index 560e937..7f30090 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,20 @@ -##### `Node Line Chart` +##### `Chain Chart` [![](https://jitpack.io/v/oky2abbas/chain-chart.svg)](https://jitpack.io/#oky2abbas/chain-chart) [![License](http://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://github.com/oky2abbas/chain-chart) [![API](https://img.shields.io/badge/API-17%2B-blue.svg?style=flat)](https://github.com/oky2abbas/chain-chart) -<<<<<<< HEAD -**Chain Chart X is a library for displaying chain and line charts, the idea of this library came to my mind from Google Analytics.** -======= -**Chain Chart View** is a +**Chain Chart is a library for displaying chain and line charts, the idea of this library came to my mind from Google Analytics.** - ->>>>>>> abbd81de27ad957c269427823fad421db395f2ca +**Bitcoin (BTC) [![Donate](https://img.shields.io/badge/Donate-green)](https://idpay.ir/oky2abbas): `1HPZyUP9EJZi2S87QrvCDrE47qRV4i5Fze`** + +**Ethereum (ETH) [![Donate](https://img.shields.io/badge/Donate-green)](https://idpay.ir/oky2abbas): `0x4a4b0A26Eb31e9152653E4C08bCF10f04a0A02a9`** -[![Donate](https://img.shields.io/badge/Donate-green)](https://idpay.ir/naqdi) +**Tron (TRX) [![Donate](https://img.shields.io/badge/Donate-green)](https://idpay.ir/oky2abbas): `TAewZVAD4eKjPo9uJ5TesxJUrXiBtVATsK`** -**Bitcoin (BTC) Donate: `1HPZyUP9EJZi2S87QrvCDrE47qRV4i5Fze`** -**Ethereum (ETH) Donate: `0x4a4b0A26Eb31e9152653E4C08bCF10f04a0A02a9`** -**Tron (TRX) Donate: `TAewZVAD4eKjPo9uJ5TesxJUrXiBtVATsK`** + @@ -40,78 +36,63 @@ Add the dependency : ```java dependencies { - implementation 'com.github.oky2abbas:chain-chart:0.9.0' + implementation 'com.github.oky2abbas:chain-chart:0.9.1' } ``` + + ##### Simple API (default) : In `XML` : ```XML - - - ``` In `Code` : ```java - - - val intervalList = listOf("Jul", "Aug", "Sep", "Oct", "Nov", "Dec") + val intervalList = listOf("Jul", "Aug", "Sep", "Oct", "Nov", "Dec") val rangeList = listOf("0-1K", "100K", "200K", "500K") val lineList = arrayListOf().apply { add(Line("Line 1", Color.BLUE, listOf(10f, 280f, 88f, 70f, 23f, 33f))) add(Line("Line 2", Color.RED, listOf(300f, 40f, 38f, 180f, 403f, 201f))) } - setData(lineList, intervalList, rangeList) - - + chainChartView.setData(lineList, intervalList, rangeList) ``` ##### Customazation : ```XML - - app:cc_line_size="3dp" - app:cc_node_size="3sp" - app:cc_text_size="11sp" - app:cc_font_family="@font/font_name" - + app:cc_line_size="3dp" //size as dp + app:cc_node_size="3dp" //size as dp + app:cc_text_size="11sp" //size as sp + app:cc_text_color="#000000" //color as int or resource id + app:cc_font_family="@font/font_name" //font as resource id ``` In `Code` : ```java - - - chainChartView.setLineSize(3f) - chainChartView.setTextSize(13f) - chainChartView.setTextColor(Color.GRAY) - chainChartView.setNodeSize(8F) - chainChartView.setFontFamily(Typeface.DEFAULT_BOLD) - - + chainChartView.setLineSize(3f) // size as dp + chainChartView.setNodeSize(8F) //size as dp + chainChartView.setTextSize(11f) // size as sp + chainChartView.setTextColor(Color.GRAY) //color as int + chainChartView.setFontFamily(font_family) //font as typeface ``` -##### FAQ : - -###### Need more help? - -- [Check out the classes in this folder](sample/src/main/java/com/naqdi/sample) - -##### License +##### Licenses ``` MIT License -Copyright (c) 2020 amir abbas naqdi +Copyright (c) 2021 amir abbas naqdi Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/library/src/main/java/com/naqdi/chart/ChainChartView.kt b/library/src/main/java/com/naqdi/chart/ChainChartView.kt index 02564b1..fbdf444 100644 --- a/library/src/main/java/com/naqdi/chart/ChainChartView.kt +++ b/library/src/main/java/com/naqdi/chart/ChainChartView.kt @@ -202,7 +202,7 @@ class ChainChartView @JvmOverloads constructor( This code finds the largest graph based on the number of nodes, then divides it based on this graph. */ - lineList.getMaxGraph()?.let { + lineList.getMaxLine()?.let { for (index in it.nodeList.indices) { splitList.add(it.getGraphX(index)) } diff --git a/library/src/main/java/com/naqdi/chart/utils/ConversionsExt.kt b/library/src/main/java/com/naqdi/chart/utils/ConversionsExt.kt index ceeb920..5efba1b 100644 --- a/library/src/main/java/com/naqdi/chart/utils/ConversionsExt.kt +++ b/library/src/main/java/com/naqdi/chart/utils/ConversionsExt.kt @@ -18,6 +18,6 @@ internal fun List.closestValue(value: Float): Float? { return minByOrNull { kotlin.math.abs(value - it) } } -internal fun List.getMaxGraph(): Line? { +internal fun List.getMaxLine(): Line? { return maxByOrNull { it.nodeList.size } } \ No newline at end of file diff --git a/sample/src/main/res/layout/main_activity.xml b/sample/src/main/res/layout/main_activity.xml index a233185..1bb532c 100644 --- a/sample/src/main/res/layout/main_activity.xml +++ b/sample/src/main/res/layout/main_activity.xml @@ -1,28 +1,27 @@ + + + android:layout_height="300dp" + android:layout_gravity="center" + android:layout_marginStart="8dp" + android:layout_marginTop="24dp" + android:layout_marginEnd="8dp" /> - + - -rrrrrrr \ No newline at end of file