B4J Question [xChart] Show a circle on YXChart

angel_

Well-Known Member
Licensed User
Longtime User
I cannot highlight a specific point on a logarithmic scale YXChart1 with a circle:

B4X:
Private Sub InitYXChart1
    Private i, Nb As Int
    Private m0, n0, m1, n1, m2, n2, m3, n3 As Double
   
    YXChart1.AddYXLine("Freq0", xui.Color_Magenta, 1dip)
    YXChart1.AddYXLine("Freq1", xui.Color_Red, 1dip)
    YXChart1.AddYXLine("Freq2", xui.Color_Blue, 1dip)
    YXChart1.AddYXLine("Freq3", xui.Color_Black, 1dip)
    YXChart1.AddYXLine2("Freq4", xui.Color_Green, 20dip, True, "CIRCLE", True, xui.Color_Green)    '<--- New line
    YXChart1.ScaleYValuesLog = "1!2!3!4!5!6!7!8!9!10"
    YXChart1.ScaleXValuesLog = "1!2!3!4!5!6!7!8!9!10"
    YXChart1.XMinValue = 1
    YXChart1.XMaxValue = 100
    YXChart1.YScaleMinValue = 40
    YXChart1.YScaleMaxValue = 100
   
   
    Nb = 65
    m0 = 3
    n0 = 0.03
    m1 = 10
    n1 = 0.1
    m2 = 20
    n2 = 0.2
    m3 = 30
    n3 = 0.3
    For i = 1 To Nb
        Private x, y0, y1, y2, y3 As Double
       
        x = i + 2
        y0 = m0 / (Power(x, n0) - 1)
        y1 = m1 / (Power(x, n1) - 1)
        y2 = m2 / (Power(x, n2) - 1)
        y3 = m3 / (Power(x, n3) - 1)
        YXChart1.AddYXPoint(0, x, y0)
        YXChart1.AddYXPoint(1, x, y1)
        YXChart1.AddYXPoint(2, x, y2)
        YXChart1.AddYXPoint(3, x, y3)
    Next
    YXChart1.AddYXPoint(4, 5, 60)    '<--- New line
   
    Chart = 1
    YXChart1.DrawChart
End Sub
 

Attachments

  • B4JLogScale.zip
    5 KB · Views: 124

angel_

Well-Known Member
Licensed User
Longtime User
Did it work in the past? maybe I'm wrong but I think I remember that it was enabled
 
Upvote 0

angel_

Well-Known Member
Licensed User
Longtime User
I can't see the point, I don't know if I'm using it correctly, should I change the code?
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Did you download the new xChart.b4xlib ?
Did you set the YXChartDisplayValues property ?

1635630782145.png

Di
 
Upvote 0

angel_

Well-Known Member
Licensed User
Longtime User
I was looking to mark a point on the graph, something like this:

B4X:
YXChart1.AddYXPoint(4, 5, 60)
YXChart1.AddYXPoint(4.001, 5.001, 60)

Captura.JPG
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Sorry, I misunderstood your request.
Moving the cursor on an xChart did not highlight any point with logarithmic scales.
This is what I added.

To your question.
The problem was not only with logarithmic scales it was also with linear scales.
The code below would be better understandable but your code works !

B4X:
YXChart1.AddYXPoint(4, 5, 60)
YXChart1.AddYXPoint(4, 5.001, 60)
The first parameter is the line index and not the coordinate. Your code works also because the line index is an integer therefore the decimal part is ignored.
It would even have worked if you had added the same point twice.

I was always thinking with lines, and lines need two points.
I should have changed my mind to point sets, which could have only one point, and not lines.
I added the drawing of only one point.
Attached the new library, version 7.9.
I will not yet update it in the xChart thread, I will do it in a further update.
 

Attachments

  • xChart.b4xlib
    40 KB · Views: 110
Last edited:
Upvote 0
Top