Skip to content

Commit

Permalink
update license and README and review code
Browse files Browse the repository at this point in the history
  • Loading branch information
oky2abbas committed Oct 19, 2020
1 parent 91dd544 commit 44e54d0
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 72 deletions.
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
73 changes: 27 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.**

<img src="screenshots/shot_1.png">
>>>>>>> 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`**
<img src="screenshots/shot_1.png">



Expand All @@ -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

<com.naqdi.chart.ChainChartView
android:id="@+id/chainChartView"
android:layout_width="match_parent"
<com.naqdi.chart.ChainChartView
android:id="@+id/chainChartView"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_gravity="center"/>

```

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<Line>().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
Expand Down
2 changes: 1 addition & 1 deletion library/src/main/java/com/naqdi/chart/ChainChartView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ internal fun List<Float>.closestValue(value: Float): Float? {
return minByOrNull { kotlin.math.abs(value - it) }
}

internal fun List<Line>.getMaxGraph(): Line? {
internal fun List<Line>.getMaxLine(): Line? {
return maxByOrNull { it.nodeList.size }
}
43 changes: 21 additions & 22 deletions sample/src/main/res/layout/main_activity.xml
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">

<com.naqdi.chart.ChainChartView
android:id="@+id/chainChartView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
android:layout_height="300dp"
android:layout_gravity="center"
android:layout_marginStart="8dp"
android:layout_marginTop="24dp"
android:layout_marginEnd="8dp" />

<com.naqdi.chart.ChainChartView
android:id="@+id/chainChartView"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_gravity="center"
android:layout_marginStart="8dp"
android:layout_marginTop="24dp"
android:layout_marginEnd="8dp"
/>
<com.google.android.material.button.MaterialButton
android:id="@+id/btnGenerate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="32dp"
android:text="@string/generate_fake_random_chart"
app:backgroundTint="@color/black" />

<com.google.android.material.button.MaterialButton
android:id="@+id/btnGenerate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="32dp"
android:text="@string/generate_fake_random_chart"
app:backgroundTint="@color/black" />
rrrrrrr
</LinearLayout>

0 comments on commit 44e54d0

Please sign in to comment.