-
Take the full control over drawing the path.
-
Change the gradient color
- Start Color
- End Color
-
Change the circle color
-
Change the circle radius
-
Change the path color
-
Change the line thickness
-
On/Off Gridlines
- Change the grid line color
-
On/Off Graduations
- Change the graduation text color
-
Draw graph with different starting point
- Draw graph from the left border (X0 - coordinate)
- Draw graph with exact coordinates given
- Draw graph from left border and stretch until the end of the screen
Add the jitpack repository to build.gradle in Project Level at the end of repositories
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Add the dependency to build.gradle in app level
dependencies {
implementation 'com.github.NsAveek:GraphView:0.1.0'
}
Declare coordinates to set. Since our base is along with X co-ordinates, assuming the X coordinates are sorted.
private val coordinates = arrayListOf<Pair<Float,Float>>()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
initCoordinates()
val graphView = findViewById<com.aveek.aesthetic_graphview.GraphView>(R.id.graphView)
graphView.setCoordinatePoints(coordinates)
}
private fun initCoordinates() {
coordinates.add(Pair(0f,0f))
coordinates.add(Pair(1f,2f))
coordinates.add(Pair(3f,4f))
coordinates.add(Pair(4f,3f))
coordinates.add(Pair(5f,5f))
coordinates.add(Pair(6f,4f))
coordinates.add(Pair(7f,2f))
}
<com.aveek.aesthetic_graphview.GraphView
android:id="@+id/graphView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:circleColor="#000000"
app:circleRadius="3"
app:drawGraduations="true"
app:drawGrids="true"
app:gradientEndColor="@color/endColor"
app:gradientStartColor="#fef08c"
app:graduationColor="@color/colorPrimaryDark"
app:graphType="START_AT_LEFT"
app:gridColor="#fef08c"
app:lineColor="#f8cb7a"
app:pathWidth="2"
/>
app:gradientStartColor="#fef08c"
app:gradientEndColor="@color/endColor"
app:circleColor="#000000"
app:circleRadius="3"
app:lineColor="#f8cb7a"
app:pathWidth="2"
app:drawGrids="true"
app:gridColor="#fef08c"
app:drawGraduations="true"
app:graduationColor="@color/colorPrimaryDark"
app:graphType="START_AT_LEFT"
app:graphType="TOUCH_END"
app:graphType="EXACT"
- Make it scrollable
- When there are a lots of data and user wants to see in a scrollview
- When the TOUCH_END parameters called and user want to see in a scrollview
- Allow Multiple graphs to be drawn one top of another based on user's choice
- Add the graduation parameters (i.e: User may want to see Monthly data, so the graduation will be Jan, Feb, Mar etc. The graph will fit into the monthly block accordingly. Currently user can see only X co-ordinates value)
Copyright 2020 Aveek
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.