1. Download the free trial version

Tutorial Android Charts Framework

Discussion in 'Tutorials & Examples' started by Erel, Mar 15, 2011.

  1. Erel

    Erel Administrator Staff Member Licensed User

    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.



    [​IMG]
    [​IMG]
    [​IMG]

    [​IMG]

    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.basic4ppc.com/android/forum/threads/android-charts-framework.8260/page-7#post-240181

    Attached Files:

    Last edited: Apr 24, 2014
    monki and JohnD like this.
  2. Erel

    Erel Administrator Staff Member Licensed User

    First post was updated with a new version. This version adds support for line charts.
    A line chart can show a single line or multiple lines.
    Some notes about the line chart:
    - The X axis values are treated as strings.
    - The Y axis values are treated as numbers.
    - The data is added by adding the next X point. For this point you need to supply the Y value in case of a single line, or an array of Y values in case of multiple lines.

    The code in the first post demonstrates both a single line and multiple lines charts.

    All the drawing code is included in the Charts module. You are free to customize it as needed.
  3. FrankR

    FrankR Member Licensed User

    This is an amazingly powerful addition. Thank you.
  4. tester198

    tester198 Member Licensed User

    Absolut powerful framework thank you Erel you are the best.
  5. Erel

    Erel Administrator Staff Member Licensed User

    Thank you guys. Bars chart will also be added soon.
  6. Erel

    Erel Administrator Staff Member Licensed User

    Support for bar charts, including stacked bar charts was added. The updated code is attached to the first post. There were other fixes related to graph drawing as well.
  7. vksptg

    vksptg New Member

    i am unable to download code..
  8. Erel

    Erel Administrator Staff Member Licensed User

    Have you purchased Basic4android? If yes please contact support@basic4ppc.com and your account will be set.
  9. DEHiCKA

    DEHiCKA New Member

    Does it support dynamic data and multi-touch zooming and scrolling like androidplot JAVA API?
  10. Erel

    Erel Administrator Staff Member Licensed User

    What do you mean with dynamic data?

    Zooming and scrolling are not implemented in this module. It shouldn't be difficult to add scrolling yourself. Zooming is more difficult but is also possible.
  11. tresor

    tresor New Member Licensed User

    Vertical lines

    Hello, I´m trying to draw a vertical line in a multiline chart, like changes between 0 and 1 in binary code or like a rectangle with vertical lines. When I use the multiline chart facilities of B4A and I plot a new point, the x-axis value is incremented 1 step so I never get a vertical line but a slope. Does anyone know how to draw a vertical line in a multiline chart? Thank you in advance.
  12. Erel

    Erel Administrator Staff Member Licensed User

    You will need to modify the code in order to draw vertical lines. It shouldn't be too difficult. Post here is you encounter any problem and I'll help you.
  13. tresor

    tresor New Member Licensed User

    Thanks. I´ve got it. At the end of "Sub Create2LinesTab" I appended a sentence LD.Canvas.DrawLine() and it works. Also I put a sentence LD.Canvas.DrawCircle() and it works also.
  14. Nyptop

    Nyptop Active Member Licensed User

    I get the error 'Error description: Unknown type: graph Are you missing a library reference?'. Any suggestions?

    Thanks
  15. Erel

    Erel Administrator Staff Member Licensed User

    Graph type is defined in the Charts code module. Have you added it to your project?
  16. Nyptop

    Nyptop Active Member Licensed User

    Thanks Erel,

    One question still though: How is the layout laid out? I'm having problems knowing what to do with panels.

    Thanks Again,

    Neil
  17. Erel

    Erel Administrator Staff Member Licensed User

    Each graph is drawn on a Panel. You can add this panel with the designer or by code and put it wherever needed.
  18. Nyptop

    Nyptop Active Member Licensed User

    Still having problems: The program is not recognising the keyword 'chart'. If you wish to have a look i have attached the file.

    Attached Files:

  19. klaus

    klaus Expert Licensed User

    As Erel already told you, you need to add the Chart module.
    You need to download the Charts.zip file in the first post.
    Then add the the Charts.bas file into your project with Project/Add Existing Module.

    Best regards.
  20. Nyptop

    Nyptop Active Member Licensed User

    Sorry, I have added chart module etc. Just uploaded the wrong one. Here is the correct one.

Share This Page

Loading...