Announcement

Collapse
No announcement yet.

RMChart - Trendline

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Stuart McLachlan
    replied
    Guess we should take the discussion about gbChartmaster to the other thread as per Gary's post #4 in light of Adam's reminder

    Leave a comment:


  • Gary Beene
    replied
    That's still a bit long. Give me a bit and I'll make a much simpler demo.

    The discussion page for gbChartMaster has another shorter example.

    https://forum.powerbasic.com/forum/u...ter-discussion

    Leave a comment:


  • Gary Beene
    replied
    Howdy, Tim/Stuart!

    In the DLL subfolder is a sample app ... gbchartmasterdemo.bas. It's a demonstration of how to use the gbChartMaster DLL.

    That example has 3 tabs, corresponding to 3 sets of data - DataSet1, DataSet2 and DateSet3. One or more of those can be plotted on the same graph. The default data was assigned in the demo bas file in the Initialize Settings procedure.

    The Settings toolbar button brings up the full gbChartmaster Settings Dialog. On that dialog, upper left corner, select "2-Line" to plot both DataSet1 and DataSet2. That will plot the two sets of data as lines, bar charts, pie charts - whatever you select from the Settings Dialog.

    In a simple app, the Settings Dialog is not shown. This demo just show that it can be shown if desired to make a realtime change to the graph.

    I didn't allow passing of a two-dimensional array. Instead, you'll see that the data for each dataset is passed like this in the InitializeSettings procedure.

    B.UserData(1) = "60" + $CrLf + "40" + $CrLf + "90" + $CrLf + "160" + $CrLf + "120"

    Hope that helps. Ask more questions if needed!

    Leave a comment:


  • Tim Lakinir
    replied
    Thank you Everyone

    @Gary, that's gbChartMaster is awesome!

    also as Stuart suggested, could you please give us a starter XY chart version which is less complicated

    Leave a comment:


  • Stuart McLachlan
    replied
    Wow, I see why I installed it but ddn't spend much time with it
    It will take hours to analyse gbChartMaster and extract the relevant subset of all that to just generate a chart from a dataset.

    Do you have a "starter" example of using the include file to just plot the points in a single or two dimensional array on a chart in a graphics window?

    Leave a comment:


  • Stuart McLachlan
    replied
    Originally posted by Stuart McLachlan View Post
    Wow! I wasn't aware of that one. I'm about to go play with it
    Correction. I had forgotten about that one
    Must be "oldtimers disease" !

    I went to install it and found I already had it from an install a few years ago.

    Leave a comment:


  • Stuart McLachlan
    replied
    Originally posted by Gary Beene View Post
    Hey, Tim!

    Do you know about gbChartMaster?
    Wow! I wasn't aware of that one. I'm about to go play with it


    Leave a comment:


  • Gary Beene
    replied
    Hey, Tim!

    Do you know about gbChartMaster?

    https://forum.powerbasic.com/forum/u...ic-application

    Click image for larger version

Name:	gbchartmaster_mains.jpg
Views:	115
Size:	25.7 KB
ID:	794691

    With Stuart's code above, it should be easy enough to add a trendline graph to what gbChartMaster already has.

    Leave a comment:


  • Pierre Bellisle
    replied
    For those interested, you may download RmChart 4.12 from this site.

    Zipped files kit, no installer.
    Same kit via an installer.

    If for compatibitity reason, someone want an older version, pm me.
    I got also v2.0, v2.1, v2.2, v3.0, v3.10c, v4.0, v4.01, v4.10

    Leave a comment:


  • Tim Lakinir
    replied
    Thank you Johan and Stuart, Rmchart is indeed a beauty

    Leave a comment:


  • Stuart McLachlan
    replied
    Originally posted by Johan Klassen View Post
    hello Stuart McLachlan
    thanks for the link, the setup.exe downloads ok https://web.archive.org/web/20090205...mchart.com:80/
    H, so it does. I didn't try that one, I just tried the rmchart_dll.zip download link and that one didn't work.

    Leave a comment:


  • Johan Klassen
    replied
    hello Stuart McLachlan
    thanks for the link, the setup.exe downloads ok https://web.archive.org/web/20090205...mchart.com:80/

    Leave a comment:


  • Stuart McLachlan
    replied
    Originally posted by Johan Klassen View Post
    That one is a bit early(2006) and refers to Ver 3.

    This one from Feb 2009 appears to be the last one and covers the last version (4.12) https://web.archive.org/web/20090205...mchart.com:80/
    (Note: the download links don't work)

    Leave a comment:


  • Johan Klassen
    replied
    Tim Lakinir
    yes, wayback machine does have a backup https://web.archive.org/web/20061230...w.rmchart.com/

    Leave a comment:


  • Tim Lakinir
    replied
    Thank you Sir Stuart

    Leave a comment:


  • Stuart McLachlan
    replied
    Yes, it's basic statistics. Just for fun, i knocked up a little function to calculate the trend line for a series of datapoints stored in a two diensional array
    '
    Code:
    #COMPILE EXE
    #DIM ALL
    
    FUNCTION PBMAIN () AS LONG
    LOCAL n, i AS LONG
    LOCAL slope, offset AS EXT
    LOCAL xMin,xMax AS EXT
    LOCAL yMin,yMax AS EXT
    
    'Build a data set
        n = 99 ' 100 points -1 because we are using a zero based array
        xMin = 0: xMax = 100 ' range to plot on x Axis.
        DIM dp(n,1) AS EXT ' x values in dp(i,0), y values in dp(i,1)
        RANDOMIZE TIMER
        'Comment out one of the two following plot types
        'scatter plot
    '    FOR i = 0 TO n
    '        dp(i,0) = RND(1,100)
    '        dp(i,1) =  RND(1,100)
    '    NEXT
        'linear plot
        FOR i = 0 TO n
            dp(i,0) = i
            dp(i,1) =  RND(1,20) + i * RND(1,5) ' slowly increment average y
        NEXT
        'Get linear trendline formula
        Trendline dp(),slope,offset
        yMin = offset: yMax = slope * xMax + offset
        ? "Trendline is:  y = " & FORMAT$(slope,"0.00") & IIF$(offset >= 0,"x +","x ")  & FORMAT$(offset,"0.00") & $CRLF _
        &  USING$("Line from (#.# , #.# ) to (#.# , #.#)",xMin,yMin,xMax,yMax)
    END FUNCTION
    
    FUNCTION TrendLine(a() AS EXT,s AS EXT, o AS EXT) AS LONG
    LOCAL i,n,sX,sY,sXY,sX2,sY2 AS EXT
        n = UBOUND(a())
        FOR i = 0 TO n
            sX +=  a(i,0)
            sy +=  a(i,1)
            sXY += a(i,0) * a(i,1)
            sx2 += a(i,0)^2
            sY2 += a(i,1)^2
        NEXT
        s =  (n * sXY - sX*sY)/(n*sX2 - sX^2)
        o = (sY - s *sX)/n
    END FUNCTION
    '
    Last edited by Stuart McLachlan; 1 Jun 2020, 08:47 AM.

    Leave a comment:


  • Tim Lakinir
    replied
    As Rmchart.com is gone, I'm wondering if I get to read its web info via something like waybackmachine ?

    Leave a comment:


  • Tim Lakinir
    replied
    Thanks Sir Mclachlan , that's more like high school math

    Leave a comment:


  • Stuart McLachlan
    replied
    Originally posted by Tim Lakinir View Post
    Hi All
    I'm trying to learn RMchart , but Mr Debolt above did not provide the his latest code for this post #5, I wonder if any one else can help
    at least to get me started on RMChart such as how to draw the trend line?
    Drawing a trend line is simple, you just use standard RMChart commands to draw a line from one point to another.

    Calculating what line to draw is not so simple. You need to do the math for that yourself, it's not part of the package.
    For a simple linear trendline, calculate the slope and intercept of the line from the data points and then plot it.

    Here's the formula:

    Click image for larger version  Name:	trendline.jpg Views:	0 Size:	3.7 KB ID:	794582

    If that doesn't help, there's a simple step by step explanation of the process here:
    https://classroom.synonym.com/calcul...line-2709.html

    For a polynomial, exponential, logarithmic or power trend line it gets a bit more complicated.

    .

    Leave a comment:


  • Tim Lakinir
    replied
    Hi All
    I'm trying to learn RMchart , but Mr Debolt above did not provide the his latest code for this post #5, I wonder if any one else can help
    at least to get me started on RMChart such as how to draw the trend line?

    Leave a comment:

Working...
X