B4A Library MPAndroidCharts - Various type of graphs / charts (Latest library V1.17 in post #1)

Similar threads

B4A Tutorial Android Charts Framework
B4A Library [B4X] [XUI] Pie Chart
Share My Creation Google Charts
B4A Tutorial Add Charts With Google Charts Service
B4A Tutorial [B4X] Smart String Literal

Johan Schoeman

Expert
Licensed User
Will have to amend the library to do so. Will try to get to it sometime this week.

JS
Here you go - lib files attached. It should show as V1.13 in the B4A IDE libs tab

Just set the marker to use to 0

B4X:
mlc1.MarkerToUse = 0
I suggest you leave the files in the /Objects/res/layout and Objects/res/drawable folder. They are however not required to be there when MarkerToUse is set to 0 but when setting MarkerToUse to any other value they MUST be there.

I have applied this change to all the graph types in the library.

JS
 

Attachments

jtare

Active Member
Licensed User
Unfortunately not as the library stands at present unless you superimpose two charts on top of one another with transparency in the right places.
Is there any solution to this? Searching I found that there is a way to combine charts, but there is only the same example of bar charts and lines charts, not candlestick and lines or candlesticks and points.
Thanks.

Seems possible: https://github.com/PhilJay/MPAndroidChart/blob/master/MPChartExample/src/com/xxmassdeveloper/mpchartexample/CombinedChartActivity.java

EDIT:
I got it to work. I edited the source code from the combine bar chart and line chart. Now I can draw a candlestick chart and a line chart. Now I will try candlestick+multiline+multibubble+multiscatter.
 
Last edited:

Johan Schoeman

Expert
Licensed User
Hi everybody, Is there any way to set the color of crosshair cursor lines ?
Thanks !
Have not looked at the lib in a very long time but from memory it takes the color of the line/chart that you have clicked on. This lib is probably outdated and someone can perhaps try and wrap the latest version of this Github project and in all probability do it far better than what I have done. Done this in my early days of trying to do wrappers.
 

loonet

Member
Licensed User
Have not looked at the lib in a very long time but from memory it takes the color of the line/chart that you have clicked on. This lib is probably outdated and someone can perhaps try and wrap the latest version of this Github project and in all probability do it far better than what I have done. Done this in my early days of trying to do wrappers.
Thanks, its outdated but anyway usefull. Thanks for your reply
 

Johan Schoeman

Expert
Licensed User
Hi everybody, Is there any way to set the color of crosshair cursor lines ?
Thanks !
Use the attached lib files (copy them to your additional libs folder. Have added the ability to set the color and the width of the cross hair to multilinecharts, radarcharts, and linecharts (single) for now.

Lib should show as V1.14

Example code from multilinechart:
B4X:
    mlc1.HighlightLineWidth = 2.0f
    mlc1.CrossHairColor = Array As Int(Colors.White, Colors.Yellow, Colors.White, Colors.Yellow, Colors.White, Colors.Yellow, Colors.White, Colors.Yellow, Colors.White, Colors.Yellow)
    
    mlc1.setLineData(10,37)
I need to do some method naming changes in the library at some time or another...:eek:
 

Attachments

loonet

Member
Licensed User
Use the attached lib files (copy them to your additional libs folder. Have added the ability to set the color and the width of the cross hair to multilinecharts, radarcharts, and linecharts (single) for now.

Lib should show as V1.14

Example code from multilinechart:
B4X:
    mlc1.HighlightLineWidth = 2.0f
    mlc1.CrossHairColor = Array As Int(Colors.White, Colors.Yellow, Colors.White, Colors.Yellow, Colors.White, Colors.Yellow, Colors.White, Colors.Yellow, Colors.White, Colors.Yellow)
   
    mlc1.setLineData(10,37)
I need to do some method naming changes in the library at some time or another...:eek:
Thanks so much Johan ! I really appreciate the favor you gave me
 

mico

Member
Licensed User
Hi Johan,

Thank you for this great library. I am stuck at getting values from a listview, can you help?

I have two listviews, one for x's and the other for y's. I can succesfully add items and log the values they took with this code:
B4X:
For i=0 To x_list.Size-1 Step 1
m=x_list.GetItem(i)
Log(m)
Next

For j=0 To y_list.Size-1 Step 1
n=y_list.GetItem(j)
Log(n)
Next
But I cannot define these values as x labels and y values in the multiline chart. Is there a way to do it? How can I transfer my "x" values in
B4X:
chart.XaxisLables = Array As String()
and "y" values in
B4X:
chart.Chart_1_Data= Array As Float()
using my values from the related listviews.

Thanks for any help.

The attached project adds Multi Line charts. It uses a lot of arrays to set up the individual line graphs within a chart. See the code within the project. You can customize each line graph within a chart to "your liking". It also has a very nice animation when a new chart it drawn. Click on the button at the bottom of the chart to cycle through some examples that I have created in the code.

The pics below is what the code in the project draws at present. You can obviously change your individual graphs to your liking (different X-axis data, different, Y-axis data, colours, etc.). There are lots of methods that can be applied to the charts.

You can draw/display from 1 to 5 line charts (see code in the B4A project). You can also load data for 5 graphs and just display for eg the first 2. It also allows you to for eg only display a defined portion of the X axis (and then obviously the corresponding y-axis values).

It incorporates all of the single line chart functionality in Post #7 above and some more (the pop-up marker views is still there if you touch a data point, etc, etc)

Uploading the B4A project and the new library files.

View attachment 37541

View attachment 37542

View attachment 37543

View attachment 37544

View attachment 37545

View attachment 37546

View attachment 37547

View attachment 37548
 
Last edited:

Johan Schoeman

Expert
Licensed User
Hi Johan,

Thank you for this great library. I am stuck at getting values from a listview, can you help?

I have two listviews, one for x's and the other for y's. I can succesfully add items and log the values they took with this code:
B4X:
For i=0 To x_list.Size-1 Step 1
m=x_list.GetItem(i)
Log(m)
Next

For j=0 To y_list.Size-1 Step 1
n=y_list.GetItem(j)
Log(n)
Next
But I cannot define these values as x labels and y values in the multiline chart. Is there a way to do it? How can I transfer my "x" values in
B4X:
chart.XaxisLables = Array As String()
and "y" values in
B4X:
chart.Chart_1_Data= Array As Float()
using my values from the related listviews.

Thanks for any help.
Solved in the PM that you have sent me.
 

wimpie3

Well-Known Member
Licensed User
@Johan Schoeman It seems the value of the data point is ALWAYS shown when you click on a data point. I thought I could disable that behavior by passing FALSE to DrawGraphValues, but that only disables the INITIAL showing of the data value. When you touch a data point on the graph, the value is shown no matter what DrawGraphValues is set to.
 
Top