B4J Library [B4X] [XUI] xChart Class

Discussion in 'B4J Libraries & Classes' started by klaus, Apr 12, 2018.

  1. Peter Simpson

    Peter Simpson Expert Licensed User

    That is looking excellent Klaus, thank you very very very much.
     
  2. klaus

    klaus Expert Licensed User

    Hi Peter,
    Can you please try this version:

    upload_2019-1-12_13-16-52.png

    The default orientation is still HORIZONTAL, backward compatibility.
    For HORIZONTAL, if the text width is greater than the bar interval, the orientation is automatically set to VERTICAL.
    For VERTICAL, if the text height is greater than the bar width, the text size is reduced to fit in the bar width. If the size is less than 10, the values are not displayed.

    EDIT: 2019.01.15
    Removed the file, updated in post #1.
     
    Last edited: Jan 15, 2019
    DonManfred and Peter Simpson like this.
  3. Peter Simpson

    Peter Simpson Expert Licensed User

    This is excellent @klaus.
    Below is a screenshot of one items orders before I print the chart using JavaFX8, printout looks fabulous.

    This chart is from November 2018, but starting from this month (January 2019) all weekend orders will be added using the correct dates rather than Mondays date, thus there will be at least 8 more bars per month starting from this month.

    By the way I like the fact that the chart will auto rotate the values if necessary.

    B4J project for a client running on my MacBook Pro - Red is redacted information
    2.png

    Thank you...
     
    Last edited: Jan 15, 2019
  4. klaus

    klaus Expert Licensed User

    The xChart Class has been updated to version 3.4 in the first post.
    Added following properties: Subtitle, SubtitleTextSize, SubtitleTextColor
    Added BarValueOrientation property
    Amended transparent color
     
  5. Peter Simpson

    Peter Simpson Expert Licensed User

    BTW I created a virtual chart with 31 days and 5 figure values, everything worked 100% perfect.

    Nice work updating the chart with the subtitle and especially the auto (horizontal/vertical) direction for the values is especially good.

    Thank you...
     
    klaus likes this.
  6. micro

    micro Well-Known Member Licensed User

    Hi to all, excellent library but i need a help

    upload_2019-1-15_8-43-9.png

    I can not trace the two lines of reference, how can I draw them?
    The central lines are the results of same operations.
    Thanks
     
  7. klaus

    klaus Expert Licensed User

    This kind of lines cannot be drawn with the xChart class.
    The data structure is not adapted for this kind of data.
    There are missing points and two y values for a same x coordinate.
     
  8. micro

    micro Well-Known Member Licensed User

    ok, it's like I thought.
    An solution comes to mind?
    Thanks
     
  9. klaus

    klaus Expert Licensed User

    I had a closer look at your problem.
    It is possible with the YXChart type.

    upload_2019-1-15_21-51-37.png

    The code:
    Code:
    YXChart1.ClearData
       YXChart1.AddYXLine2(
    "Example1", xui.Color_Red, 2dipTrue"CIRCLE"False, xui.Color_Red)
        YXChart1.AddYXLine2(
    "Example2", xui.Color_Blue, 2dipTrue"CIRCLE"False, xui.Color_Blue)
        YXChart1.AddYXLine2(
    "Example3", xui.Color_Blue, 2dipTrue"CIRCLE"False, xui.Color_Blue)
        YXChart1.XScaleTextOrientation = 
    "VERTICAL"
        YXChart1.ChartBackgroundColor = xui.Color_White
        YXChart1.GridFrameColor = xui.Color_Black
        YXChart1.GridColor = xui.Color_Gray
        YXChart1.TitleTextColor = xui.Color_Black
        YXChart1.ScaleTextColor = xui.Color_Black
        YXChart1.DisplayValues = 
    False
        YXChart1.YScaleMaxValue = 
    50
        YXChart1.YScaleMinValue = -
    50
        YXChart1.XScaleMaxValue = 
    20000
        YXChart1.XScaleMinValue = 
    0

        YXChart1.AddYXPoint(
    000)
       YXChart1.AddYXPoint(
    0200020)
       YXChart1.AddYXPoint(
    0400035)
       YXChart1.AddYXPoint(
    0600045)
       YXChart1.AddYXPoint(
    0800030)
       YXChart1.AddYXPoint(
    01000020)
       YXChart1.AddYXPoint(
    0120005)
       YXChart1.AddYXPoint(
    014000, -10)
       YXChart1.AddYXPoint(
    016000, -20)
       YXChart1.AddYXPoint(
    018000, -40)
       YXChart1.AddYXPoint(
    020000, -30)

       YXChart1.AddYXPoint(
    1010)
       YXChart1.AddYXPoint(
    11000010)
       YXChart1.AddYXPoint(
    11000020)
       YXChart1.AddYXPoint(
    12000020)

       YXChart1.AddYXPoint(
    20, -10)
       YXChart1.AddYXPoint(
    210000, -10)
       YXChart1.AddYXPoint(
    210000, -20)
       YXChart1.AddYXPoint(
    220000, -20)

        YXChart1.DrawChart
     
    Erel and Peter Simpson like this.
  10. micro

    micro Well-Known Member Licensed User

    Many thanks, klaus.
     
  11. Erel

    Erel Administrator Staff Member Licensed User

    Klaus you did an amazing job here. All the screenshots look excellent!
     
    micro, Peter Simpson and klaus like this.
  12. Tayfur

    Tayfur Well-Known Member Licensed User

    @klaus ; Can i get min value of chart width & height with active text size.
    Because my bar chart has alot of bar, therefore I need resize with aviable size of chart.
     
  13. micro

    micro Well-Known Member Licensed User

    Hi Klaus
    a small display problem
    upload_2019-1-17_8-28-38.png
    Why the test + and test-lines do not come up to 3000?
    Code:
    TestChart.ClearData
        TestChart.XAxisName = 
    "Testy"
        TestChart.YAxisName = 
    "Testx"
        TestChart.AutomaticScale = 
    True
        TestChart.AddYXLine2(
    "Test", xui.Color_Red, 2dipTrue"CIRCLE"False, xui.Color_Red)
        TestChart.AddYXLine2(
    "Test+", xui.Color_Blue, 2dipTrue"CIRCLE"False, xui.Color_Blue)
        TestChart.AddYXLine2(
    "Test-", xui.Color_Blue, 2dipTrue"CIRCLE"False, xui.Color_Blue)
        TestChart.XScaleTextOrientation = 
    "VERTICAL"
        TestChart.ChartBackgroundColor = xui.Color_White
        TestChart.GridFrameColor = xui.Color_Black
        TestChart.GridColor = xui.Color_Gray
        TestChart.TitleTextColor = xui.Color_Black
        TestChart.ScaleTextColor = xui.Color_Black
        TestChart.DisplayValues = 
    False
        TestChart.YScaleMaxValue = 
    5
        TestChart.YScaleMinValue = -
    5
        TestChart.XScaleMaxValue = 
    3000
        TestChart.XScaleMinValue = 
    0

        
    'result
        TestChart.AddYXPoint(000)
        TestChart.AddYXPoint(
    02000.4)
        TestChart.AddYXPoint(
    04000.5)
        TestChart.AddYXPoint(
    06000.5)
        TestChart.AddYXPoint(
    08001.0)
        TestChart.AddYXPoint(
    010001.4)
        TestChart.AddYXPoint(
    012001.6)
        TestChart.AddYXPoint(
    01400, -1)
        TestChart.AddYXPoint(
    01600, -1.2)
        TestChart.AddYXPoint(
    01800, -1.2)
        TestChart.AddYXPoint(
    02000, -1.6)
        
    'rif1
        TestChart.AddYXPoint(101)
        TestChart.AddYXPoint(
    15001)
        TestChart.AddYXPoint(
    15002)
        TestChart.AddYXPoint(
    120002)
        TestChart.AddYXPoint(
    120003)
        TestChart.AddYXPoint(
    130003)
        
    'rif2
        TestChart.AddYXPoint(20, -1)
        TestChart.AddYXPoint(
    2500, -1)
        TestChart.AddYXPoint(
    2500, -2)
        TestChart.AddYXPoint(
    22000, -2)
        TestChart.AddYXPoint(
    22000, -3)
        TestChart.AddYXPoint(
    23000, -3)
      
        TestChart.DrawChart
    Thanks

    Edit:
    sorry I just confused the x axis with y
     
    Last edited: Jan 17, 2019
  14. klaus

    klaus Expert Licensed User

    Strange !?
    I copied your code into my test program and I get this!?

    upload_2019-1-17_10-20-33.png

    Can you please post your project so I can look at it?
     
  15. klaus

    klaus Expert Licensed User

    The text sizes are available as properties, but not the chart dimensions.
    What exactly is the problem, do the bars become too small?
    Can you post an example project showing your problem.

    You could replace, in the class code:
    Private Graph As GraphData
    by
    Public Graph As GraphData

    And the in the main code:
    Code:
    Private Graph As GraphData
    Graph = BarChart1.Graph
    Log(Graph.Left)
    Log(Graph.Width)
    Log(Graph.Top)
    Log(Graph.Height)
     
    Last edited: Jan 17, 2019
  16. Tayfur

    Tayfur Well-Known Member Licensed User

    Basiclly;
    I setting all text size is "8". its fix.
    and for example i need 50 bar.
    I need All bars and bars label show

    What is the minimum form width(X) for all bars and bar's tags to appear.
    What is the minimum form height(Y) for all bars and bar's tags to appear.

    I calculated it but not correctly. you knows it.
    upload_2019-1-17_16-19-24.png
     
  17. micro

    micro Well-Known Member Licensed User

    Attached
    Thanks
     

    Attached Files:

  18. klaus

    klaus Expert Licensed User

    @Tayfur
    The bar width is calculated in the InitChart routine in several steps.
    The min bar width, without the values is 4 dip.
    The min automatic text size is 10, below this size, the values are not displayed.
     
    Last edited: Jan 18, 2019
    Peter Simpson and Tayfur like this.
  19. klaus

    klaus Expert Licensed User

    @micro
    I see it too now.
    I need to look deeper why this happens.
    It appears only at the first drawing. In my test program, the chart is drawn two times and it worked and I didn't see it
    As an intermediate workaround, duplicate this line: TestChart.DrawChart
    It will be amended in the next version with some other minor problems.
     
  20. klaus

    klaus Expert Licensed User

    @micro
    I found the solution. Will be amended soon in the first post.
    Added Sleep(0) in the Base_Resize routine:
    Code:
    Private Sub Base_Resize (Width As Double, Height As Double)
        xcvsGraph.Resize(Width, Height)
        xpnlCursor.Width = Width
        xpnlCursor.Height = Height
        xcvsCursor.Resize(Width, Height)
        Sleep(
    0)
        
    If Points.Size > 0 Or Graph.ChartType = "PIE" Or Graph.ChartType = "YX_CHART" Then
            DrawChart
        
    End If
    End Sub
    To make sure that the dimension adjustments are effectively done before drawing the chart.
     
    Peter Simpson and DonManfred like this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice