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

Edit 6 Sep 2015: Post #3 adds Single Vertical Bar Charts and update for Pie Charts
Edit 8 Sep 2015 Post #6 update for Single Vertical Bar Charts
Edit 11 Sep 2015 Post #7 adds Single Line Charts
Edit 12 Sep 2015 Post #8 update for Single Line Charts
Edit 12 Sep 2015 Post #9 adds Single Horizontal Bar Charts
Edit 12 Sep 2015 Post #11 adds Radar Charts
Edit 13 Sep 2015 Post #12 update for Single Line and Single Bar Charts
Edit 14 Sep 2015 Post #16 update for Radar Charts
Edit 16 Sep 2015 Post #19 adds Multiple Line Charts
Edit 17 Sep2016 Post #21 adds Multi Vertical Bar Charts
Edit 19 Sep 2015 Post #23 adds Multi Bubble Charts
Edit 19 Sep 2015 Post #24 adds Multi Horizontal Bar Charts
Edit 19 Sep 2015 Post #25 adds Multi Scatter Charts
Edit 19 Sep 2015 Post #26 adds Stacked Bar Charts
Edit 20 Sep 2015 Post #27 adds Candlestick Charts
Edit 20 Sep 2015 Post #28 adds Combined Line & Bar Charts
Edit 23 Sep 2015 Post #31 fixed no-show of Chart Title for Combined Charts and added ability to rotate X-axis labels between -30 and + 30 degrees

I am busy wrapping this Github project. Attached is the Pie Chart functionality of the project/library. Posting the B4A project and Library files. Copy the library files to your additional library folder.

Some remarks about the Pie Chart:
1. It will display the values passed as a percentage of the total of the values that you pass
2. There are 3 x arrays that are passed to the library. Ensure that you pass the same number of elements in each of the arrays.
3. When you click on a pie slice the slice will increase in radial size (see pics below)
4. If you click on the radial increased slice it will return to normal size.
5. You can spin the pie chart around its centre point (CW and ACW) with your finger.

Untouched ...

Pie.gif


1.png


Green slice touched ...

2.png


Pie Chart rotated with finger...

3.png



Some sample code:

B4X:
#Region  Project Attributes
    #ApplicationLabel: MPChart
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: landscape
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Private mpc1 As PieChart
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("main")

mpc1.DrawHoleEnabled = True
mpc1.HoleColorTransparent = True

mpc1.TransparentCircleColor = Colors.White
mpc1.TransparentCircleAlpha = 110

mpc1.HoleRadius = 58.0
mpc1.TransparentCircleRadius = 61.0

mpc1.DrawCenterText = True

mpc1.CenterText = "Wrapped by Johan"
mpc1.CenterTextColor = Colors.White
mpc1.CenterTextRadiusPercent = 100.0
mpc1.CenterTextSize = 15.0

mpc1.DrawSliceText = True
mpc1.HoleColor = Colors.Black
mpc1.TransparentCircleColor = Colors.Transparent

mpc1.setTheLegendPosition
mpc1.TheLegendColor = Colors.yellow
mpc1.TheLegendTextSize = 12.0
mpc1.LegendTitle = "MONTHS"

mpc1.ChartDescription = "TITLE : Some Arbitrary Data"
mpc1.ChartDescriptionColor = Colors.ARGB(200,0,255,255)
mpc1.ChartDescriptionTextSize = 17

mpc1.ValueTextColor = Colors.Black
mpc1.ValueTextSize = 15.0

mpc1.PieColors = Array As Int(Colors.Blue, Colors.Yellow, Colors.Green, Colors.Red, Colors.Magenta, Colors.Cyan)
mpc1.LegendText = Array As String("Jan", "Feb", "Mar", "Apr", "May", "Jun")
mpc1.ChartData = Array As Float(128.0, 16.0, 46.0, 40.0, 30.0, 40.0)    'values - it will be converted to %

mpc1.PieData = 6

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
 

Attachments

  • b4aMPChart.zip
    7.9 KB · Views: 1,408
  • mpChartLibraryFiles.zip
    221.5 KB · Views: 1,494
  • mpChartLibV1.15.zip
    355.2 KB · Views: 609
  • mpChartLibV1.16.zip
    355.7 KB · Views: 608
  • mpChartLibV1.17.zip
    355.8 KB · Views: 776
  • mpChartLibV1.18.zip
    356.4 KB · Views: 686
  • mpChartLibV1.20.zip
    358.1 KB · Views: 468
  • mpChartLibV1.21.zip
    358 KB · Views: 41
  • mpChartLibV1.22.zip
    359.2 KB · Views: 66
Last edited:

Alex_Puz

Member
Licensed User
Longtime User
Great! Thank you so much. Sure will donate... Let me earn a little of what I am doing.. If do same with Pie that what give me happy and many others
 

abarnett

Member
Licensed User
Longtime User
Use attached V1.06 library files. It adds an event to the RadarChart (value and index returned when touched).
Sample Code:
B4X:
#Region  Project Attributes
    #ApplicationLabel: MPRadarChart
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: landscape
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Private mrc1 As RadarChart

End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("main")

    mrc1.ChartDescription = "TITLE : IS - Company X"
    mrc1.ChartDescriptionColor = Colors.White
    mrc1.ChartDescriptionTextSize = 12

'    RIGHT_OF_CHART, RIGHT_OF_CHART_CENTER, RIGHT_OF_CHART_INSIDE,
'    LEFT_OF_CHART, LEFT_OF_CHART_CENTER, LEFT_OF_CHART_INSIDE,
'    BELOW_CHART_LEFT, BELOW_CHART_RIGHT, BELOW_CHART_CENTER,

'   CIRCLE, SQUARE, LINE

    mrc1.LegendShapeSize = 15.0
    mrc1.setTheLegendPositionAndForm("BELOW_CHART_CENTER","CIRCLE")
    mrc1.TheLegendColor = Colors.yellow
    mrc1.TheLegendTextSize = 10.0
    mrc1.LegendText = Array As String("2011", "2012", "2013", "2014", "2015")


    mrc1.ValueTextColor = Colors.Black
    mrc1.ValueTextSize = 12.0

    'mrc1.RotationEnabled = False


'    mrc1.YaxisMinVal = -400          'commented it out so that the scale will be set automatically
'    mrc1.YaxisMaxVal = 1800           'commented it out so that the scale will be set automatically
    mrc1.YaxisTextSize = 10.0
    mrc1.YaxisTextColor = Colors.White

    mrc1.Chart_1_Data = Array As Float(1100.0, 550.0, 550.0, -300.0, 600.5, 445.0, 849.7, -250.4, -380.2, 345.0)
    mrc1.Chart_2_Data = Array As Float(1200.0, 750.0, 450.0, 960.0, 730.0, 1100.0, 676.5, 985.6, 1010.8, 836.4)
    mrc1.Chart_3_Data = Array As Float(836.4, 1010.8, 985.6, 676.5, 1100.0, 730.0, 960.0, 450.0, 750.0, 1200)
    mrc1.Chart_4_Data = Array As Float(345.0, -380.2, -250.4, 849.7, 445.0, 600.5, -300.0, 50.0, 550.0, 1100.0)
    mrc1.Chart_5_Data = Array As Float(1050.0, 850.0, 650.0, 1400.0, 760.8, -450.7, 934.9, 576.2, 896.4, -380.6)

    mrc1.XaxisTextColor = Colors.Cyan
    mrc1.XaxisTextSize = 12.0

    mrc1.ValueTextSize = 10.0
    mrc1.ValueTextColor = Colors.Yellow
    mrc1.DrawGraphValues = False

'   Maximum 5 colors to be passed ==> must be at least equal to the number of data sets that are passed i.e maximum 5
'   If you pass only for eg 2 data sets then at least 2 colors need to be passed
    mrc1.GraphLineColor = Array As Int(Colors.Yellow, Colors.Red, Colors.Blue, Colors.Green, Colors.Cyan)
    mrc1.GraphLineWidth = 2.0
    mrc1.DrawFilled = True

    mrc1.WebConcentricColor = Colors.Green
    mrc1.WebRadialColor = Colors.Red
    mrc1.WebAlpha = 200
    mrc1.ConcentricLineWidth = 1.5
    mrc1.RadialLineWidth = 0.75
    mrc1.DrawWeb = True

    mrc1.XaxisLables = Array As String("Nett Sales", "Cost of Materials", "Gross Contribution", "DFL", "DFO", "Gross Margin", "Admin OH", "Selling OH", "Distribution OH", "EBITDA")

    mrc1.MarkerToUse = 2
    mrc1.NoOfMarkerDigits = 1

    mrc1.YaxisNumberOfDigits = 0

    mrc1.LegendVisible = False




'   the number of charts to be drawn (maximum 5, in this case 3)
    mrc1.setRadarData(1,10)

    mrc1.RotationEnabled = True

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub mrc1_value_selected(index As Int, value As Float)

    Log("index = " & index)
    Log("value = " & value)

End Sub
Use attached V1.06 library files. It adds an event to the RadarChart (value and index returned when touched). Also some other minor improvements. Changing the color and width of individual concentric rings is however not possible unless I do some significant changes to the original Github code.

Sample Code:
B4X:
#Region  Project Attributes
    #ApplicationLabel: MPRadarChart
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: landscape
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Private mrc1 As RadarChart

End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("main")

    mrc1.ChartDescription = "TITLE : IS - Company X"
    mrc1.ChartDescriptionColor = Colors.White
    mrc1.ChartDescriptionTextSize = 12

'    RIGHT_OF_CHART, RIGHT_OF_CHART_CENTER, RIGHT_OF_CHART_INSIDE,
'    LEFT_OF_CHART, LEFT_OF_CHART_CENTER, LEFT_OF_CHART_INSIDE,
'    BELOW_CHART_LEFT, BELOW_CHART_RIGHT, BELOW_CHART_CENTER,

'   CIRCLE, SQUARE, LINE

    mrc1.LegendShapeSize = 15.0
    mrc1.setTheLegendPositionAndForm("BELOW_CHART_CENTER","CIRCLE")
    mrc1.TheLegendColor = Colors.yellow
    mrc1.TheLegendTextSize = 10.0
    mrc1.LegendText = Array As String("2011", "2012", "2013", "2014", "2015")


    mrc1.ValueTextColor = Colors.Black
    mrc1.ValueTextSize = 12.0

    'mrc1.RotationEnabled = False


'    mrc1.YaxisMinVal = -400          'commented it out so that the scale will be set automatically
'    mrc1.YaxisMaxVal = 1800           'commented it out so that the scale will be set automatically
    mrc1.YaxisTextSize = 10.0
    mrc1.YaxisTextColor = Colors.White

    mrc1.Chart_1_Data = Array As Float(1100.0, 550.0, 550.0, -300.0, 600.5, 445.0, 849.7, -250.4, -380.2, 345.0)
    mrc1.Chart_2_Data = Array As Float(1200.0, 750.0, 450.0, 960.0, 730.0, 1100.0, 676.5, 985.6, 1010.8, 836.4)
    mrc1.Chart_3_Data = Array As Float(836.4, 1010.8, 985.6, 676.5, 1100.0, 730.0, 960.0, 450.0, 750.0, 1200)
    mrc1.Chart_4_Data = Array As Float(345.0, -380.2, -250.4, 849.7, 445.0, 600.5, -300.0, 50.0, 550.0, 1100.0)
    mrc1.Chart_5_Data = Array As Float(1050.0, 850.0, 650.0, 1400.0, 760.8, -450.7, 934.9, 576.2, 896.4, -380.6)

    mrc1.XaxisTextColor = Colors.Cyan
    mrc1.XaxisTextSize = 12.0

    mrc1.ValueTextSize = 10.0
    mrc1.ValueTextColor = Colors.Yellow
    mrc1.DrawGraphValues = False

'   Maximum 5 colors to be passed ==> must be at least equal to the number of data sets that are passed i.e maximum 5
'   If you pass only for eg 2 data sets then at least 2 colors need to be passed
'   If more that 2 colors are passed with for eg only 2 data sets then only the first 2 colors will be used in the color array
    mrc1.GraphLineColor = Array As Int(Colors.Yellow, Colors.Red, Colors.Blue, Colors.Green, Colors.Cyan)
    mrc1.GraphLineWidth = 2.0
    mrc1.DrawFilled = True

    mrc1.WebConcentricColor = Colors.Green
    mrc1.WebRadialColor = Colors.Red
    mrc1.WebAlpha = 200
    mrc1.ConcentricLineWidth = 1.5
    mrc1.RadialLineWidth = 0.75
    mrc1.DrawWeb = True

    mrc1.XaxisLables = Array As String("Nett Sales", "Cost of Materials", "Gross Contribution", "DFL", "DFO", "Gross Margin", "Admin OH", "Selling OH", "Distribution OH", "EBITDA")

    mrc1.MarkerToUse = 2
    mrc1.NoOfMarkerDigits = 1

    mrc1.YaxisNumberOfDigits = 0

    mrc1.LegendVisible = False




'   the number of charts to be drawn (maximum 5, in this case 3)
'   the number of x-axis values per chart (in this case 10 = number of elements in the array passed to mrc1.XaxisLables)
    mrc1.setRadarData(1,10)

    mrc1.RotationEnabled = True

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub mrc1_value_selected(index As Int, value As Float)

    Log("index = " & index)
    Log("value = " & value)

End Sub
Hi Johan
In the Pie chart I need event of any segment to return index and value also need click event on the label in center.
In the Radar chart, I need assign to any concentric rings any color and width also with show point should be event to return index and value of point. All of those events need to start others subs
Thank you.
Use attached V1.06 library files. It adds an event to the RadarChart (value and index returned when touched). Also some other minor improvements. Changing the color and width of individual concentric rings is however not possible unless I do some significant changes to the original Github code.

Sample Code:
B4X:
#Region  Project Attributes
    #ApplicationLabel: MPRadarChart
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: landscape
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Private mrc1 As RadarChart
  
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("main")
  
    mrc1.ChartDescription = "TITLE : IS - Company X"
    mrc1.ChartDescriptionColor = Colors.White
    mrc1.ChartDescriptionTextSize = 12  
  
'    RIGHT_OF_CHART, RIGHT_OF_CHART_CENTER, RIGHT_OF_CHART_INSIDE,
'    LEFT_OF_CHART, LEFT_OF_CHART_CENTER, LEFT_OF_CHART_INSIDE,
'    BELOW_CHART_LEFT, BELOW_CHART_RIGHT, BELOW_CHART_CENTER,

'   CIRCLE, SQUARE, LINE

    mrc1.LegendShapeSize = 15.0
    mrc1.setTheLegendPositionAndForm("BELOW_CHART_CENTER","CIRCLE")
    mrc1.TheLegendColor = Colors.yellow
    mrc1.TheLegendTextSize = 10.0  
    mrc1.LegendText = Array As String("2011", "2012", "2013", "2014", "2015")


    mrc1.ValueTextColor = Colors.Black
    mrc1.ValueTextSize = 12.0
  
    'mrc1.RotationEnabled = False


'    mrc1.YaxisMinVal = -400          'commented it out so that the scale will be set automatically
'    mrc1.YaxisMaxVal = 1800           'commented it out so that the scale will be set automatically
    mrc1.YaxisTextSize = 10.0
    mrc1.YaxisTextColor = Colors.White
  
    mrc1.Chart_1_Data = Array As Float(1100.0, 550.0, 550.0, -300.0, 600.5, 445.0, 849.7, -250.4, -380.2, 345.0)
    mrc1.Chart_2_Data = Array As Float(1200.0, 750.0, 450.0, 960.0, 730.0, 1100.0, 676.5, 985.6, 1010.8, 836.4)  
    mrc1.Chart_3_Data = Array As Float(836.4, 1010.8, 985.6, 676.5, 1100.0, 730.0, 960.0, 450.0, 750.0, 1200)  
    mrc1.Chart_4_Data = Array As Float(345.0, -380.2, -250.4, 849.7, 445.0, 600.5, -300.0, 50.0, 550.0, 1100.0)  
    mrc1.Chart_5_Data = Array As Float(1050.0, 850.0, 650.0, 1400.0, 760.8, -450.7, 934.9, 576.2, 896.4, -380.6)  
  
    mrc1.XaxisTextColor = Colors.Cyan
    mrc1.XaxisTextSize = 12.0
  
    mrc1.ValueTextSize = 10.0
    mrc1.ValueTextColor = Colors.Yellow  
    mrc1.DrawGraphValues = False  
  
'   Maximum 5 colors to be passed ==> must be at least equal to the number of data sets that are passed i.e maximum 5
'   If you pass only for eg 2 data sets then at least 2 colors need to be passed
'   If more that 2 colors are passed with for eg only 2 data sets then only the first 2 colors will be used in the color array
    mrc1.GraphLineColor = Array As Int(Colors.Yellow, Colors.Red, Colors.Blue, Colors.Green, Colors.Cyan)
    mrc1.GraphLineWidth = 2.0
    mrc1.DrawFilled = True
  
    mrc1.WebConcentricColor = Colors.Green
    mrc1.WebRadialColor = Colors.Red
    mrc1.WebAlpha = 200
    mrc1.ConcentricLineWidth = 1.5
    mrc1.RadialLineWidth = 0.75
    mrc1.DrawWeb = True
  
    mrc1.XaxisLables = Array As String("Nett Sales", "Cost of Materials", "Gross Contribution", "DFL", "DFO", "Gross Margin", "Admin OH", "Selling OH", "Distribution OH", "EBITDA")

    mrc1.MarkerToUse = 2
    mrc1.NoOfMarkerDigits = 1
  
    mrc1.YaxisNumberOfDigits = 0
  
    mrc1.LegendVisible = False
  
  
  
  
'   the number of charts to be drawn (maximum 5, in this case 3)
'   the number of x-axis values per chart (in this case 10 = number of elements in the array passed to mrc1.XaxisLables)
    mrc1.setRadarData(1,10)
  
    mrc1.RotationEnabled = True

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub mrc1_value_selected(index As Int, value As Float)
  
    Log("index = " & index)
    Log("value = " & value)
  
End Sub
Hi Johan
Fab library. I'm using v1.06 multi line chart and can only get max of 7 rather that 10 lines. Any ideas

Cheers Andrew
 

Johan Schoeman

Expert
Licensed User
Longtime User
Hi Johan
Fab library. I'm using v1.06 multi line chart and can only get max of 7 rather that 10 lines. Any ideas

Cheers Andrew

You are probably missing something in your code to show 10 lines. Attached is an example:

2.png
 

Attachments

  • b4aMPMultiLineChartV5.zip
    379.9 KB · Views: 257

abarnett

Member
Licensed User
Longtime User
Thanks for the example. Found the problem. You were right I was missing a value.

Andrew
Hi Johan,

Would you have any ideas why the animate of the multi line would not be fluid. I have been working on 4 channels but just increased to 8 channels and the plotting of the chart which was very smooth and customer loved it is now not. I have tried the animation time from 2000 to 500 and it has not helped. Would be nice to get it back to fluid.

Thanks
Andrew
 

abarnett

Member
Licensed User
Longtime User
Strange. I tested with your V5 example above and its not animated either, even though I can see the animate is set in code.

Donation made by the way..

Thanks
Andrew
 

Johan Schoeman

Expert
Licensed User
Longtime User
Strange. I tested with your V5 example above and its not animated either, even though I can see the animate is set in code.

Donation made by the way..

Thanks
Andrew


Andrew, please upload a sample project so that I can see what is happening in your project with the animation. Else send me a Dropbox link in a PM where I can download your project from.
 

abarnett

Member
Licensed User
Longtime User
Have uploaded the same program to another tablet and it animate fine. I will do some more investigation.

Thanks
Andrew
 

tufanv

Expert
Licensed User
Longtime User
Andrew, please upload a sample project so that I can see what is happening in your project with the animation. Else send me a Dropbox link in a PM where I can download your project from.
Dear Johan,

Thanks for the lib. I have used the updated line and barchart example in my app. There are 12 datas as float from 3.70 to 4.00 but all the data on the graph is rounded to 4. I also tried with the latest lib 1.06 but it still shows them rounded. Any idea ?
 

Johan Schoeman

Expert
Licensed User
Longtime User
Dear Johan,

Thanks for the lib. I have used the updated line and barchart example in my app. There are 12 datas as float from 3.70 to 4.00 but all the data on the graph is rounded to 4. I also tried with the latest lib 1.06 but it still shows them rounded. Any idea ?
Can you maybe upload a sample project and I will then look into it.
 

LouFromDetroit

Member
Licensed User
Longtime User
I notice that this feature does work OK:
mlc5.NoOfMarkerDigits= 3 'or any number

But it seems to revert to the EU style where the 1,279 would show as 1.279 and a decimal like 55.25 will show as 55,25

Is there a localization for this setting?

Note -this was using the mulitlinechart

Thanks.
 
Last edited:

beaker

Member
Licensed User
@LouFromDetroit I have the same issue with the MLC. I brought it up in post #146 in this same thread just under a year ago but Johan wasn't able to help. My app still has the same problem a year later! We've got 4 devices (2 HTC, 1 Samsung & 1 Tesco Hudl) here and it's the same on all devices.
 

Johan Schoeman

Expert
Licensed User
Longtime User
@LouFromDetroit I have the same issue with the MLC. I brought it up in post #146 in this same thread just under a year ago but Johan wasn't able to help. My app still has the same problem a year later! We've got 4 devices (2 HTC, 1 Samsung & 1 Tesco Hudl) here and it's the same on all devices.

I will post the Java code as it is at present. Please feel free to change it to accommodate your requirements and then recompile it into a new library. Doing a wrappper for a specific project does not mean that one should go and change the original code to accommodate special requirements. If you want to do so then you are more than welcome. I have wrapped what is available and added numerous additional features that were not available in the original Github project. So, if I post the code will you be able to amend it and then recompile it? Else there is no sense in me posting the Java code...
 

beaker

Member
Licensed User
I will post the Java code as it is at present. Please feel free to change it to accommodate your requirements and then recompile it into a new library. Doing a wrappper for a specific project does not mean that one should go and change the original code to accommodate special requirements. If you want to do so then you are more than welcome. I have wrapped what is available and added numerous additional features that were not available in the original Github project. So, if I post the code will you be able to amend it and then recompile it? Else there is no sense in me posting the Java code...

Sorry Johan, thanks for the offer of posting the Java code but I'm afraid that wouldn't do me any good (I just don't get on with Java at all. That's why I use B4A!). I think you might have misunderstood the issue as I don't think either myself or LouFromDetroit are asking for anything special. In my locale (UK) the decimal separator is a "." and the thousands separator is a ",". The axis labels show correctly according to my locale but the markers don't. I have accepted this as a bug and because nobody else seemed to have the same problem I didn't bother you any further with it. When I saw that LouFromDetroit appeared to be experiencing the same issue I thought I'd let him know that I have the same issue.
 

Johan Schoeman

Expert
Licensed User
Longtime User
@LouFromDetroit I have the same issue with the MLC. I brought it up in post #146 in this same thread just under a year ago but Johan wasn't able to help. My app still has the same problem a year later! We've got 4 devices (2 HTC, 1 Samsung & 1 Tesco Hudl) here and it's the same on all devices.
Here is the Java code - change it to accommodate your requirement. Note that the wrappers alone are in excess of 16 000 lines of code (this excludes the code in the original project + what I have amended / added to the original code). Enjoy!

Just by the way - it took just about 18 months of work to get to the last set of library files that I have posted - in my free time. I am giving it to you for free to change to your liking.
 

Attachments

  • src.zip
    292.9 KB · Views: 162

beaker

Member
Licensed User
Here is the Java code - change it to accommodate your requirement. Note that the wrappers alone are in excess of 16 000 lines of code (this excludes the code in the original project + what I have amended / added to the original code). Enjoy!

Just by the way - it took just about 18 months of work to get to the last set of library files that I have posted - in my free time. I am giving it to you for free to change to your liking.

Thanks Johan. Even though I didn't have much hope of finding what I was looking for in the Java code you posted I think I might have found the piece of code that's responsible for the incorrect characters. I've found the following in the "formatNumber" function (in Utils.java) which is hard-coded to use commas as a decimal separator and the full-stop as a thousands separator:

B4X:
            // add decimal point
            if (charCount == digitCount) {
                out[ind--] = ',';
                charCount++;
                decimalPointAdded = true;

                // add thousand separators
            } else if (separateThousands && lval != 0 && charCount > digitCount) {

                if (decimalPointAdded) {

                    if ((charCount - digitCount) % 4 == 0) {
                        out[ind--] = '.';
                        charCount++;
                    }

                } else {

                    if ((charCount - digitCount) % 4 == 3) {
                        out[ind--] = '.';
                        charCount++;
                    }
                }
            }
Now, although I think I've found it I have no idea how to make it conform to the current locale or to then compile it into a library!
 

LouFromDetroit

Member
Licensed User
Longtime User
I did confirm that the main Y axis works OK for the settings using
mlc4.YaxisLeftNumberOfDigits = 1 'or any other number

So the end issue is a mismatch in the axis vs the marker for the separators.
That issue withstanding, it is still a very awesome effort from your side.
I will donate if my project turns to be successful.
 

Johan Schoeman

Expert
Licensed User
Longtime User
Thanks Johan. Even though I didn't have much hope of finding what I was looking for in the Java code you posted I think I might have found the piece of code that's responsible for the incorrect characters. I've found the following in the "formatNumber" function (in Utils.java) which is hard-coded to use commas as a decimal separator and the full-stop as a thousands separator:

B4X:
            // add decimal point
            if (charCount == digitCount) {
                out[ind--] = ',';
                charCount++;
                decimalPointAdded = true;

                // add thousand separators
            } else if (separateThousands && lval != 0 && charCount > digitCount) {

                if (decimalPointAdded) {

                    if ((charCount - digitCount) % 4 == 0) {
                        out[ind--] = '.';
                        charCount++;
                    }

                } else {

                    if ((charCount - digitCount) % 4 == 3) {
                        out[ind--] = '.';
                        charCount++;
                    }
                }
            }
Now, although I think I've found it I have no idea how to make it conform to the current locale or to then compile it into a library!
Post some screenshots of what you see and I will see if I can address it. I don't think the original Githib post makes provision for Locale but I will look into it once I understand the issue
 

wimpie3

Well-Known Member
Licensed User
Longtime User
Is it possible to paint the background below some values? Like the green color I've added here?
 

Attachments

  • green.png
    green.png
    40.6 KB · Views: 141
Top