Android Tutorial Android Charts Framework

Status
Not open for further replies.
The purpose of this framework is to allow you to easily add different types of charts to your projects.
The current version supports pie charts, line charts and bar charts.

The framework is implemented as code modules. You are free to customize the code as needed.

I also recommend you to go over the code. It demonstrates several concepts including: usage of custom types, drawings, string measurements and region clipping.



charts_2.png

charts_bars.png

charts_stackedbars.png


charts_pie.png


The code module is attached as part of the example project.
Questions, comments and suggestions are welcomed.

Klaus has posted a version that includes automatic scaling: http://www.b4x.com/android/forum/threads/android-charts-framework.8260/page-7#post-240181
 

Attachments

  • Charts.zip
    9.6 KB · Views: 7,890
Last edited:

klaus

Expert
Licensed User
Longtime User
Here you are.
Where did you get the Chart.bas file from ?
The original Charts module is named Charts and not Chart !
I don't know what you all have tested with your program but, after removing some errors, there remained a strange error about a Calculator, as I didn't find where this did come from I started with the program version I sent you a few days ago.

Best regards.
 

Attachments

  • optioncalc5.zip
    12.3 KB · Views: 785

Nyptop

Active Member
Licensed User
Longtime User
Wow this is brilliant :) I think I should be O.K from now on.

Once again thank you,

Neil
 

Smee

Well-Known Member
Licensed User
Longtime User
This is Excellent Erel.

Thanks very much
 

Bohica93

Member
Licensed User
Longtime User
Hi,

I recently bought B4A and I am really enjoying coding for Android in a language I understand!

I was wondering if there was a way in the charts to reduce the amount of white space at the top and bottom of the charts?

Thanks.
 

Attachments

  • screen1.jpg
    screen1.jpg
    11.4 KB · Views: 1,054

JCO

Active Member
Licensed User
Longtime User
Hi,

I've made a (slight) change to the module in order to have the bars & stacked bars graphs centered in the plot area with a small margin left and right, instead of them being right-aligned with varying space to the left.

I upload it here in case someone may be interested. (Only 4 lines changed, commented for tracking)

br,

Julio
 

Attachments

  • Charts.bas
    11.3 KB · Views: 733

Paulux

Member
Licensed User
Longtime User
Hi,

I'm use the Pie related methods

i have 4 listVIew

When the user click on one listView the Pie is displayer whith the data.

When the user click on other listview, the pie is REwrited but the LegendText is not rewrited.

DO you know what is the process for erase the old value of LegendText

Thanks
 

Paulux

Member
Licensed User
Longtime User
My purged sources

Hi,

This is my sources (without sql req and 2 panel only)

for testing :

- click on first ListView item
- Check Pie Charts data

- click on 2nd ListView item
- Check Pie Charts data

- click on first ListView item
- Check Pie Charts data

...
...
...

Thanks for your help

Best Regards
 

Attachments

  • MySampleCode.zip
    6.5 KB · Views: 645
Last edited:

klaus

Expert
Licensed User
Longtime User
Here you are.
I added the lines with the comment 'KC at the end of the Populate routine.
B4X:
    Dim ImageView1 As ImageView
    ImageView1.Initialize("")
    ImageView1.SetBackgroundImage(legend)
    If stats.NumberOfViews > 0 Then    'KC
        stats.RemoveViewAt(0)          'KC
    End If                             'KC
    stats.AddView(ImageView1, 10dip, 10dip, legend.Width, legend.Height)
    PieDatanb = 0

    ProgressDialogHide

End Sub
In your code all the 'old' Imageviews remain and as the legend background color is semitransparent the old values remain visible.

Best regards.
 

ErickAsas

Member
Licensed User
Longtime User
Interactive Charts

Is it possible to add a click event on a bar chart value? If so, can you post an example. Thanks in advance.
 

mmaidul

New Member
Hello

Hello all,

I am android developer .Could you anyone send me this to my mmaidul.islam(at) gmail dot com .I have need that.

Please send me .

Thanks in advance...
Best Regards,
Maidul
 
Status
Not open for further replies.
Top