B4J Library [B4X] [XUI] xChart Class and b4xlib

Peter Simpson

Expert
Licensed User
Longtime User
CrtOrderItems.DrawChart and it should work.
I tested it in my demo program.

Hello @klaus, you are correct as usual, I didn't really need all those lines as I already had them in the actual create chart sub. Also removing the drawchart line from the clear chart sub did fix the issue. Never in a million years would I have thought about removing that line, especially as the name of DrawChart made me think it was necessary to use with the other lines. But as you correctly said none of those lines were needed actually, so I've now deleted that sub and replaced the calls with .ClearData.

Looking at my code I've decided to scrap the chart code and start again from scratch. I've just logged into my online server and created some stored procedures just for all the charts in this particular application. This will easily speed up query responses up by at least 6 or 7 times as my server will be doing all the hard work and not the app.

Thank you for opening my eyes, just rethinking that sub has made me realise that I should in fact also changes the MySQL queries to stored procedures
 
Last edited:

Peter Simpson

Expert
Licensed User
Longtime User
About post #237
Hello @klaus .

I've not deployed the updated charts and other bit add to my clients Windows app as yet. Back to post #237, I now completely remember why the code was there. I was using it to clear the actual chart on the screen.

The order is as follows.
  1. Go to accounting screen
  2. Select or search for an item from the list (which is in a tab(0)), double clicking on the item in the list sends you straight to the chart tab(1)
  3. On the chart screen, select a year, month and a specific customer (or all customers), then press the populate chart button to view the sales
Now if you go back to number 2 above and select another item from the list, it takes you to the chart tab again. I was using the code above to visually clear the chart of information. For example you first selected a part that you make for Jaguar Land Rover and you could see their orders in the chart, then the second item you select is for a part you make for Rolls Royce, and the third part you select is for BAE Systems. The code above visually clears the chart ready for you to select your date and specific filters ready for you to start generating the next chart. Can you imaging selecting an item for a different manufacturer and still seeing the chart from your previous selected item until you press the populate chart button again, basically I was using the code the clear the chart completely the very second a new item was selected by the client. That way there is noting on the screen when they are selecting their dates clients etc.

As I can't find a methods like CrtOrderItems.ClearChart and my efforts above only leads to the error message that you see above. I've reverted to using CrtOrderItems.Visible = False and .CrtOrderItems.Visible = True to get around showing the error message above. It was actually one of my beta testers that noticed the chart was no longer clearing when he was selecting new items, thank goodness for external beta testers ?

Basically without CrtOrderItems.DrawChart the chart is just left there as is. I didn't spot it previously as I was not looking for it, I should have realised what the code was actually for from the sub name 'ClearChart' ?

My request: Please can you add a method to clear the charts of all visual visible information just leaving the currently set background colour.


Thank you
Pete...
 

klaus

Expert
Licensed User
Longtime User
Hi Peter,
Can you please test the attached library, version 4.5?
I have added a DrawEmptyChart method, which simply draws the background color of the chart.

Your code from post #237 will be reduced to:
B4X:
Sub ClearChart As ResumableSub
    CrtOrderItems.DrawEmptyChart

    Return Null
End Sub
I think that you don't even need to use a ResumableSub any more.
 

Attachments

  • xChart.b4xlib
    20.4 KB · Views: 319
Last edited:

Peter Simpson

Expert
Licensed User
Longtime User

Thank you Klaus,, I've downloaded your 4.5 and I'll test it when I get back from my meeting with a potentially new prospect.
 

Peter Simpson

Expert
Licensed User
Longtime User
Hi Peter,
Can you please test the attached library, version 4.5?
Good Morning Klaus, well it will be morning when you receive this message.
I've tested your updated library and I'm happy to report that everything is working 100% as expected, the .DrawEmptyChart method is exactly what the doctor ordered

Thank you, xCharts V4.5 has done the trick...
 

Peter Simpson

Expert
Licensed User
Longtime User
Good morning @klaus,
Request time ?

Would it be possible for you to add XAxisName and XAxisName text color. When you change the GridFrameColor, the XAxisName and XAxisName text colors changes to match the GridFrameColor. XAxisName and XAxisName text size would also be nice to have too, but changing the text color could be nicer to have.

Thank you...
 

klaus

Expert
Licensed User
Longtime User
Would it be possible for you to add XAxisName and XAxisName text color.
Sure !

I suppose you mean: Would it be possible for you to add YAxisName and XAxisName text color.
Do you expect independant colors for the Y and X axes or would the same color for both be OK.
The AxisTextSize property does already exist.
 

Peter Simpson

Expert
Licensed User
Longtime User
Sure !

I suppose you mean: Would it be possible for you to add YAxisName and XAxisName text color.
Do you expect independant colors for the Y and X axes or would the same color for both be OK.
The AxisTextSize property does already exist.

Hello @klaus
Thank you for your fast as usual response.
I would presume that both X and Y AxisName text colors would be the same color, preferably black, but does not change when the GridFrameColor changes.
 

angel_

Well-Known Member
Licensed User
Longtime User
It seems that the following properties are not available in B4i:
B4X:
ScaleXValuesLog
ScaleYValuesLog
 

klaus

Expert
Licensed User
Longtime User
I have added the CPP_xChart_V4_6.zip file, a CrossPlatformProject, which reduces the platform specific code to a minimum.
It contains an xMain module with all the cross platform common code even all the event handling.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
I've created a cross platform example which combines B4XTable and xChart:




This library is really awesome!

One thing that I was missing is a way to resize the chart in B4A. I ended changing the logic of my program to only add the chart after the size is known.
I think that if Base_Resize was public then it would have been possible to resize the chart. In B4J and B4i it works automatically as Base_Resize is called.
 

klaus

Expert
Licensed User
Longtime User
One thing that I was missing is a way to resize the chart in B4A.
Could you please give some more details on the conditions where and how you needed to resize the chart.
There is no problem for me to set Base_Resize as Public, but I like to understand why I change something.
 
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…