FORUMS

How to Listen to Beats 1 on Android Right Now

If you felt a bit left out by Apple launching their own online radio station Beats 1 … more

NVidia SHIELD TV – XDA TV Device Review

The SHIELD TV is a not an Android smartphone device. However, that doesn’t mean it … more

PSA: Having cellular connectivity or texting issues tonight?

You’re not alone…Tonight, many users are experiencing a myriad … more

Beats Music No Longer Accepting New Accounts

Whenever Apple launches a new product or service, it definitely manages to grab the … more

[Library][Fork] HoloGraphLibrary

2,051 posts
Thanks Meter: 7,099
 
Post Reply Subscribe to Thread Email Thread
If you need to display graphs and/or charts in your application in a stylish, holo-compliant way, this is your go-to library.

I especially needed the BarGraph view for a project I am preparing for the Samsung Smart App Challenge 2013, but unfortunately, the base library by Daniel Nadeau was hardcoding the prepended $ unit, while my project requires several different other units to be displayed.

So I forked the library and added a couple features (I will be adding more over time), so I thought I would share:
  • Defining the unit programmatically, using BarGraph.setUnit(String unit)
    Code:
    // Example
    BarGraph bg = (BarGraph) findViewById(R.id.bargraph);
    bg.setUnit("m");
  • Appending or prepending the unit programmatically using #BarGraph.appendUnit(Boolean doAppend)
    Code:
    // Example
    BarGraph bg = (BarGraph) findViewById(R.id.bargraph);
    bg.appendUnit(true);
  • ==> The result would be :


Additionnally, I converted the library for proper compatibility with Gradle & Android Studio (IntelliJ).
You can find my fork on Github at the following url: https://github.com/Androguide/HoloGraphLibrary

If you haven't heard of this library before, it currently offers the following views:




You can use them in your project as follows:
  • LineGraph:
    XML
    Code:
    <com.echo.holographlibrary.LineGraph
            android:layout_width="match_parent"
            android:layout_height="200dp"
            android:id="@+id/graph" />
    Java
    Code:
    Line l = new Line();
    LinePoint p = new LinePoint();
    p.setX(0);
    p.setY(5);
    l.addPoint(p);
    p = new LinePoint();
    p.setX(8);
    p.setY(8);
    l.addPoint(p);
    p = new LinePoint();
    p.setX(10);
    p.setY(4);
    l.addPoint(p);
    l.setColor(Color.parseColor("#FFBB33"));
    
    LineGraph li = (LineGraph)findViewById(R.id.graph);
    li.addLine(l);
    li.setRangeY(0, 10);
    li.setLineToFill(0);
  • BarGraph:
    XML
    Code:
    <com.echo.holographlibrary.BarGraph
            android:layout_width="match_parent"
            android:layout_height="200dp"
            android:id="@+id/graph" />
    Java
    Code:
    ArrayList<Bar> points = new ArrayList<Bar>();
    Bar d = new Bar();
    d.setColor(Color.parseColor("#99CC00"));
    d.setName("Test1");
    d.setValue(10);
    Bar d2 = new Bar();
    d2.setColor(Color.parseColor("#FFBB33"));
    d2.setName("Test2");
    d2.setValue(20);
    points.add(d);
    points.add(d2);
    
    BarGraph g = (BarGraph)findViewById(R.id.graph);
    g.setBars(points);
    g.setUnit("$");
    g.appendUnit(true);
  • PieGraph:
    XML
    Code:
    <com.echo.holographlibrary.PieGraph
            android:layout_width="match_parent"
            android:layout_height="200dp"
            android:id="@+id/graph" />
    Java
    Code:
    PieGraph pg = (PieGraph)findViewById(R.id.graph);
    PieSlice slice = new PieSlice();
    slice.setColor(Color.parseColor("#99CC00"));
    slice.setValue(2);
    pg.addSlice(slice);
    slice = new PieSlice();
    slice.setColor(Color.parseColor("#FFBB33"));
    slice.setValue(3);
    pg.addSlice(slice);
    slice = new PieSlice();
    slice.setColor(Color.parseColor("#AA66CC"));
    slice.setValue(8);
    pg.addSlice(slice);

If you guys have ideas or feature requests, please share. Pull-requests are obviously welcome.

BTW, anyone else participating in the SSAC this year? The $800k prize-money is mindblowing.
Attached Thumbnails
Click image for larger version

Name:	Screenshot_2013-07-09-22-59-46.jpg
Views:	1170
Size:	26.1 KB
ID:	2135237  
Last edited by Androguide.fr; 25th July 2013 at 04:45 PM.
The Following 11 Users Say Thank You to Androguide.fr For This Useful Post: [ View ]
 
 
24th July 2013, 12:44 PM |#2  
Junior Member
Thanks Meter: 1
 
More
1st place is $200k. Considering the fact that it's Samsung, I would expect a higher prize, but I guess it's a specific contest with the Chord SDK. The venture capital pitch and marketing promotion are equally valuable imo.
The Following User Says Thank You to generalu For This Useful Post: [ View ]
27th July 2013, 01:33 AM |#3  
H3R3T1C's Avatar
Senior Member
Thanks Meter: 1,733
 
Donate to Me
More
This is very cool! Thank you for sharing!
27th July 2013, 07:29 AM |#4  
Junior Member
Thanks Meter: 16
 
More
Hi this is a cool library. As you asked for feature requests. How about stacked bar charts. So one is able to show a distribution of values in a group over time or categories?

Gesendet von meinem Nexus 7 mit Tapatalk 4 Beta
28th July 2013, 12:09 AM |#5  
Androguide.fr's Avatar
OP Senior Member
Flag Lyon, France
Thanks Meter: 7,099
 
Donate to Me
More
Quote:
Originally Posted by mickru

Hi this is a cool library. As you asked for feature requests. How about stacked bar charts. So one is able to show a distribution of values in a group over time or categories?

Gesendet von meinem Nexus 7 mit Tapatalk 4 Beta

That's a very good idea, I'll try to implement it as soon as I have some time. Thanks.
I'll also soon add the possibility to add a dynamic line chart, updated every X milliseconds cleanly in a separate thread
Last edited by Androguide.fr; 28th July 2013 at 01:40 AM.
The Following User Says Thank You to Androguide.fr For This Useful Post: [ View ]
29th July 2013, 05:21 AM |#6  
H3R3T1C's Avatar
Senior Member
Thanks Meter: 1,733
 
Donate to Me
More
I've added this library to one of my apps that I'm working on. Here is a quick screenshot.
I've had to modify the LineGraph to be able to show the range lines between max and min.
The Following User Says Thank You to H3R3T1C For This Useful Post: [ View ]
29th July 2013, 01:24 PM |#7  
Junior Member
Thanks Meter: 1
 
More
I see a lot more apps and even infographics using the pie graph format. I personally think it looks more clean and easier to digest. I was looking at the challenge you're looking into, and it sounds interesting enough. It might be a perfect opportunity to enter, and just to learn about the whole process of bringing an app to market. We haven't integrated the Chord SDK, but I think it can be easily implemented since our game concept is related to live interactions. I'm more interested in the Venture Capital pitch with Samsung VC - that company has ridiculous amounts of money - it's ridiculous!

Great post!
The Following User Says Thank You to HAL2001ASO For This Useful Post: [ View ]
30th July 2013, 02:12 AM |#8  
Androguide.fr's Avatar
OP Senior Member
Flag Lyon, France
Thanks Meter: 7,099
 
Donate to Me
More
Quote:
Originally Posted by H3R3T1C

I've added this library to one of my apps that I'm working on. Here is a quick screenshot.
I've had to modify the LineGraph to be able to show the range lines between max and min.

Nice, very clean UI.
If you feel like submitting a pull-request for your LIneGraph modifications please do so.
30th July 2013, 02:16 AM |#9  
H3R3T1C's Avatar
Senior Member
Thanks Meter: 1,733
 
Donate to Me
More
Quote:
Originally Posted by Androguide.fr

Nice, very clean UI.
If you feel like submitting a pull-request for your LIneGraph modifications please do so.

I plan on sharing my code for the graph as soon as I clean up the code and add some more stuff !

Edit: pull request sent!
Last edited by H3R3T1C; 30th July 2013 at 02:49 AM.
The Following User Says Thank You to H3R3T1C For This Useful Post: [ View ]
30th July 2013, 01:39 PM |#10  
fyska's Avatar
Junior Member
Thanks Meter: 3
 
More
This looks great - don't have the need for it at the moment but have favourited it for future use! Thanks!
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes