Skip to content

Repository files navigation

WilliamChart

WilliamChart is an Android Library based on Views to help the implementation of charts in android applications. For the ones that would like to contribute, my idea is not only to implement the conventional charts but instead everything that could be pleasant and intuitive to represent and visualize data. I would prefer to keep charts simple and clean rather than overfeatured.

At the moment it provides:

  • LineChartView
  • BarChartView
  • StackBarChartView

It has been tested in Android 2.2 and above.

Demo2

Android app on Google Play

Android Arsenal

Usage

Each chart type has common but also specific customization attributes. Add the View to your layout and configure it using styleable attributes or/and programmatically.

Gradle build

To install the sample application to your device run the following task:

$ ./gradlew installDebug

To deploy the library to your local Maven repository run the following task:

$ ./gradlew install

Then, to use the library in your project add the following to your build.gradle:

dependencies {
compile 'com.db.williamchart:williamchart:1.0.0'
}

Chart (Common customization)

To create a new chart that requires axis extend the class ChartView and implement the necessary abstract methods. I believe the data you get from those methods should be enough to draw whatever you feel like.

 <com.db.chart.view.ChartView
xmlns:chart="http://schemas.android.com/apk/res-auto"android:layout_width="match_parent"android:layout_height="dp"
...
chart:chart_shadowDx="dp"chart:chart_shadowDy="dp"chart:chart_shadowRadius="dp"chart:chart_shadowColor="color"chart:chart_fontSize="dp"chart:chart_typeface="typeface"chart:chart_axisBorderSpacing="dp"chart:chart_axisThickness="dp"chart:chart_axisTopSpacing="dp"chart:chart_axisColor="color"chart:chart_labelColor="color"
/>
// Customize labelschart.setYLabels(NONE/OUTSIDE/INSIDE)
chart.setXLabels(NONE/OUTSIDE/INSIDE)
chart.setLabelColor(color)
chart.setLabelsMetric(string)
chart.setFontSize(integer)
chart.setTypeface(typeface)
// Define gridchart.setGrid(paint)
chart.setHorizontalGrid(paint)
chart.setVerticalGrid(paint)
// Show threshold linechart.setThresholdLine(float, paint)
chart.setAxisBorderValues(integer, integer, integer)
chart.setStep(integer)
chart.setTopSpacing(dimen)
chart.setBorderSpacing(dimen)
chart.setAxisX(boolean)
chart.setAxisY(boolean)
chart.show()
// Update values of a given setchart.updateValues(int, array)
// Notify chart about updated valueschart.notifyDataUpdate()
// Tooltip supportchart.showTooltip(view)
chart.dismissTooltip(view)

LineChart

 <com.db.chart.LineChartView
... />
LineChartViewchartView= newLineChartView()
LineSetlineSet = newLineSet()
lineSet.addPoint(newPoint(string, float)
lineSet.addPoint(string, float)
lineSet.addPoints(string[], float[])
// Style dotslineSet.setDots(boolean)
lineSet.setDotsColor(color)
lineSet.setDotsRadius(dimen)
lineSet.setDotsStrokeThickness(dimen)
lineSet.setDotsStrokeColor(color)
// Style linelineSet.setLineThickness(dimen)
lineSet.setLineColor(color)
// Style background filllineSet.setFill(boolean)
lineSet.setFillColor(color)
// Style typelineSet.setDashed(boolean)
lineSet.setSmooth(boolean)
chartView.addData(lineSet)

BarChart & StackBarChart

 <com.db.chart.BarChartView
... chart:chart_barSpacing="dp"chart:chart_setSpacing="dp"
/>
BarChartViewchartView = newBarcChartView()
barChart.setBarSpacing(dimen)
barChart.setSetSpacing(dimen)
barChart.setBarBackground(boolean)
barChart.setBarBackgroundColor(color)
barChart.setRoundCorners(dimen)
BarSetbarSet = newBarSet()
barSet.addBar(string, float)
barSet.addBars(string[], float[])
Barbar = newBar(string, float)
bar.setColor(color)
barSet.addBar(bar)
chartView.addData(barSet)

Listener

chart.setOnEntryClickListener(newOnEntryClickListener(){
@OverridepublicvoidonClick(intsetIndex, intentryIndex, RectentryRect) {
//Do things
}
});

Animation

Animationanim = newAnimation()
anim.setDuration(integer)
anim.setEasing(easingFunction)
anim.setEndAction(runnable)
// Animation overlap between entriesanim.setOverlap(float)
// Animation overlap between entries in a specific orderanim.setOverlap(float,int[])
// Animation starting pointanim.setStartPoint(float, float)
// Include alpha transitionanim.setAlpha(int)
// Starts animationchart.animate(animation)

Implementing the interface BaseEasingMethod you can create your own easing function. I've implemented a few (credits to Jesus Gollonet):

  • LinearEase
  • BounceEaseOut
  • ElasticEaseOut
  • CircEaseOut
  • CubicEaseOut
  • ExpoEaseOut
  • QuadEaseOut
  • QuartEaseOut
  • QuintEaseOut
  • SineEaseOut

License

Copyright 2014 Diogo Bernardino
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.

About

Android library to create charts.

Resources

Stars

1 star

Watchers

10 watching

Forks

Releases

Packages

Contributors

Languages