Alpha Video Training
Results 1 to 10 of 10

Thread: How to pass a UX control value to Xbasic charting routine

  1. #1
    Member nlights's Avatar
    Real Name
    pertti karjalainen
    Join Date
    May 2011
    Location
    California
    Posts
    217

    Default How to pass a UX control value to Xbasic charting routine

    I wonder if anyone can point me in the right direction with the following:

    Setup:

    Two UX panels, one with a list of accounts, another with a chart control (which is supposed to chart expenditure, burn-rate, etc. data for an account selected in panel 1)

    Selecting an account in panel 1 activates panel 2, which has the (native) chart


    Problem:

    I have managed to update a label in panel 2, showing which account was selected in the list in panel 1.

    I can't figure out how to orchestrate the chart refresh so that it filters the list on the selected account number. I've tried calling active javascript and passing the selected account number to the chart Xbasic routine, but the problem with that approach is that teh active javascript cannot refresh the chart using the Xbasic chart data return value, because chart, apparently, doesn't support the setvalue -method. I tried running active javascript something like this:

    Code:
    var chartValue = {dialog.object}.ajaxCallback('','','getMonthlyAccountExpenditures','','_var='+AccountNumber,{deviceOfflineFunction: function() {   }});
    {dialog.object}.setvalue('MonthlyAccountExpenditures',chartValue);
    where getMonthlyAccountExpenditures is the Xbasic code that queries the database and returns a pipe-delimited string, and MonthlyAccountExpenditures is the name of the chart variable. The setvalue method returned error that the object doesn't support setvalue, so I'm stuck.

    I guess the question really boils down to this: Is there any way to insert a value directly into a chart's Field Properties/Variable name and refresh the chart without triggering another trip to the Xbasic code, all this using javascript?

    I may have to try Google graph instead, maybe it is more approachable...

  2. #2
    "Certified" Alphaholic
    Real Name
    David Kates
    Join Date
    Apr 2008
    Location
    Unionville, ON
    Posts
    7,819

    Default Re: How to pass a UX control value to Xbasic charting routine

    There are so many variables here. There is probably a simple answer, but a simple sample UX showing a sample chart would be helpful.

    You can't call an Xbasic function with an Ajax Callback like that. The Xbasic function 'getMonthlyAccountExpenditures' will return Javascript in 'getMonthlyAccountExpenditures'. Set getMonthlyAccountExpenditures to Javascript statements or a Javascript function...

    Code:
    function getMonthlyAccountExpenditures as c (e as p)
    
    ''''your XBasic code...
    
    getMonthlyAccountExpenditures = "{dialog.object}.setvalue('MonthlyAccountExpenditures','" + chartValue + "');"
    
    end function

  3. #3
    Member nlights's Avatar
    Real Name
    pertti karjalainen
    Join Date
    May 2011
    Location
    California
    Posts
    217

    Default Re: How to pass a UX control value to Xbasic charting routine

    Thank (as always) you for your response.

    I have tried what you suggested, understanding how action javascript works. However, I may not have explained the problem very clearly.

    You probably know this already, but when using charts, every time a chart is refreshed some Xbasic code runs to get and format the data for the time series (in this case my getMonthlyAccountExpenditures() does all that.) That works fine since apparently in the background the refresh method of the chart makes a specific call to that routine. However, when the Xbasic code runs through active javascript, the code needs to return a javascript statement. So far so good, I've done exactly that (like you showed in your example.) However, the returned javascript statement cannot refresh the data in the chart directly with setvalue(), because the chart component doesn't support that function. The only way (as far as I can tell) to refresh the chart data can be done from refresh() or other events, which then run the Xbasic function that doesn't receive the filter value (in my case Account number.)

    My other option would be to use a session variable to store the selected account number and grab it in the Xbasic code, but that approach seems to be frowned upon, if I understand correctly some discussions around that technique. Ideally, this type of messaging between the UI (javascript) and the server (Xbasis) is all done using active javascript.

  4. #4
    Member nlights's Avatar
    Real Name
    pertti karjalainen
    Join Date
    May 2011
    Location
    California
    Posts
    217

    Default Re: How to pass a UX control value to Xbasic charting routine

    Meh... I'm moving on to Google charts... Which I probably should have done a while ago already.

    Based on the Alpha videos on Google charts it seems to me that it is relatively easy to send a filter value to the server when refreshing the chart data and the chart itself. But, of course, seeing is believing.

  5. #5
    "Certified" Alphaholic peteconway's Avatar
    Real Name
    Peter Conway
    Join Date
    Oct 2005
    Location
    Melbourne, Australia
    Posts
    2,676

    Default Re: How to pass a UX control value to Xbasic charting routine

    As you already have the chart details in your list - pass those values to the Google chart and draw it.
    Insanity: doing the same thing over and over again and expecting different results.
    Albert Einstein, (attributed)
    US (German-born) physicist (1879 - 1955)

  6. #6
    Member
    Real Name
    Frank Zwolinski
    Join Date
    Aug 2013
    Location
    Vernon, NJ USA
    Posts
    125

    Default Re: How to pass a UX control value to Xbasic charting routine

    Here is one my posts that has an example of using Google charts with Northwind SQL database. I have used Google charts extensively with good results. Hope this helps.
    https://www.alphasoftware.com/alphaf...-SQL-Agruments

  7. #7
    Member nlights's Avatar
    Real Name
    pertti karjalainen
    Join Date
    May 2011
    Location
    California
    Posts
    217

    Default Re: How to pass a UX control value to Xbasic charting routine

    Thank you for the link! In the meanwhile, I have successfully implemented Google charts for my application, including dynamically refreshed content from SQL server. Regardless, your posting included some great ideas, such as a placeholder for no data.

    While struggling through yet another Alpha thicket, I've had some recurring thoughts about effective and non-effective documentation. While Selwyn's videos are very well done and informative, they are still videos. Videos are good for getting a quick overview of a topic, but they are not all that helpful when trying to build your own app using the techniques covered in the video. You can't copy code, you can't re-read difficult concepts easily, small but critical details are too easy to miss, searching for certain details in a video is extremely time-consuming. Maybe it's just my learning style, but I often find videos more frustrating than helpful.

    As for charts, you can choose between "native" charts, Google charts, and Javascript charts. Nowhere did I see a good comparison of the three charts, so I had to learn it the hard way. I started with native charts but realized soon that they are very difficult to use in a dynamic way (refreshing with new content,) at least without resorting to session variables. Maybe there is a way to do that, but I didn't see any examples or mentions of how to do it. I moved on to Javascript charts because they are the most recent addition to Alpha and thus I expected them to be most advanced as well. I soon learned that customizing them is frustratingly limited (such as adding y-axis titles or rotating x-axis labels.) I can see all kinds of optional settings in the charting platform they are based on, but Alpha seems to turn a blind eye to most of them (i.e., they have no effect.) The major buzz-killer for me was the inability to rotate x-axis labels, which means that labels longer than 1-2 characters overlap each other and render the graph practically useless. Finally, I moved on to Google charts, which seem very well designed, adjust automatically to available screen space, and allow for all kinds of customization. Most of this happens outside of Alpha's control, but at least Alpha allows you to tap directly into Google charts' native APIs

    Finally, the way the documentation is written for this and many other Alpha topics reminds me of a construction process where you are given a picture of the final building and an explanation of the necessary techniques to do the construction, but blueprints are very few and far between. For example, it would be great if charts -related documentation had a section right up front explaining on a high, conceptual level how everything goes together and what the interdependencies are. I've complained about Alpha's documentation in the past, and while it is much improved from just a few years ago, it still has a long way to go, in my humble opinion. It might be a good idea to hire a consultant or a full-time person who has been trained specifically on writing efficient documentation. It is an art in itself, and engineers are generally notoriously unprepared to do a good job at it.

    Be that as it may, I now have a good looking mobile app with charts, working exactly as I want it to work. So, there's that :-)

  8. #8
    Alpha Software Employee Beta Spark's Avatar
    Real Name
    Sarah Mitchell
    Join Date
    Jul 2015
    Posts
    427

    Default Re: How to pass a UX control value to Xbasic charting routine

    Hello pertti!

    We do have a full time documentation person here at Alpha. If you find an issue with documentation or have suggestions for ways to improve our articles, you can use the link at the bottom of any article to send us feedback. Our documentation team will be more than happy to have your feedback.

    Thank you!
    Sarah Mitchell

    Looking for answers? Try our documentation.
    If you can't find something, let us know!

  9. #9
    Member
    Real Name
    Michael Cornford
    Join Date
    Oct 2011
    Location
    East Sussex, UK
    Posts
    884

    Default Re: How to pass a UX control value to Xbasic charting routine

    There is no problem using all features of Rgraph in Alpha. The only slight problem is you don't use the builders but you can still use Alpha to get and filter the base data.

  10. #10
    "Certified" Alphaholic peteconway's Avatar
    Real Name
    Peter Conway
    Join Date
    Oct 2005
    Location
    Melbourne, Australia
    Posts
    2,676

    Default Re: How to pass a UX control value to Xbasic charting routine

    I had success with the Rgfaph, but the constraint of using a UX Data Series as the default source rather than the List or vBox controls and the absence of a legend control alienated it from my UX data already in play.
    Insanity: doing the same thing over and over again and expecting different results.
    Albert Einstein, (attributed)
    US (German-born) physicist (1879 - 1955)

Similar Threads

  1. Pass variables between xbasic functions
    By Peter.Greulich in forum Application Server Version 11 - Web/Browser Applications
    Replies: 9
    Last Post: 11-26-2012, 04:09 PM
  2. Charting feature pack if you dont do xbasic or need static data
    By Andy in forum Application Server Version 11 - Web/Browser Applications
    Replies: 7
    Last Post: 07-30-2012, 10:50 AM
  3. Pass XBasic array to JavaScript
    By koga101 in forum Application Server Version 10 - Web/Browser Applications
    Replies: 5
    Last Post: 04-01-2011, 03:12 PM
  4. Backup Routine Fails When Control Panel Hidden
    By MikeC in forum Alpha Five Version 8
    Replies: 12
    Last Post: 06-09-2008, 09:27 PM
  5. Xbasic help with backup routine
    By John Keogh in forum Alpha Five Version 5
    Replies: 11
    Last Post: 12-13-2002, 07:16 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •