Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook



The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic

Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.

If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.

Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.

Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Pie chart using calculated fields

  • Filter
  • Time
  • Show
Clear All
new posts

  • Pie chart using calculated fields

    I am trying to setup a pie chart on a form that needs to draw the data from 3 calculated fields.

    I would just use the built-in documentation to try and figure this out but Alpha has disabled all image examples so it is hard to tell if you are reading the right part of the docs for things like this.

    Calculated fields I need to pull from are:




    Will keep looking for the answer myself but if anyone has a clue, thanks in advance.

  • #2
    Re: Pie chart using calculated fields

    These are form level or table level? The AlphaSports sample uses a table level calc field in one of the graphs on the ProductSalesByState form. Not sure about using form level calculations. They do use a mapped table as well.
    There can be only one.


    • #3
      Re: Pie chart using calculated fields

      Originally posted by Stan Mathews View Post
      These are form level or table level? The AlphaSports sample uses a table level calc field in one of the graphs on the ProductSalesByState form. Not sure about using form level calculations. They do use a mapped table as well.
      Form level.

      I guess I could add 3 more fields to the parent table and then have an event on the form that forces the forms calculated fields to get writen to the table.

      Just did not want to go through all of that if I could get out of it.


      • #4
        Re: Pie chart using calculated fields

        see new wiki help

        Hi Preston,
        According to that little bit of info, a chart embedded on a form can use the form variables. So create your 3 calcs and 3 vars and set the vars to the calcs in an OnFetch or button event.

        Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford


        • #5
          Re: Pie chart using calculated fields

          Robin, you must see more there then I do.

          I am going to watch some of the videos but so far the docs and "New Wiki" are not much help.

          I mean you can make a chart in Excel or Quatro Pro in just a few seconds but the Alpha chart supercontrol is being a pain in the rear. I do not see why showing 3 values on a chart in Alpha is so screwy. I can get it to show a chart that is not really a chart, but two separate circles, and they are just grey.

          Right now I am just going to move on as the chart is not a necessity but would have been a nice addition to the form.


          • #6
            Re: Pie chart using calculated fields

            I have come to the conclusion that Alpha cannot do charts the way I need them to work.

            At least I have not found a way. Alpha insist on using ONE field (column), variable or calculated field as a series even if you have set it to use multiple fields. If you select multiple fields it then wants to build a series for each field.

            I need it to look at 3 different fields(columns, all on the same row) or 3 different variables or 3 different calculated fields on a form.

            I can put 3 different values in 3 different cells in Excel and wa-la, an f'ing chart but when it comes to Alpha's embedded chart, forget it.


            • #7
              Re: Pie chart using calculated fields

              Looks like I should be able to create a chart or charts the way I want using Google Charts for Developers.

              This is a rough of one I created with just a few minutes of coding. It is displayed on a Desktop Form in my app.

              It does require that the computer is connected to the internet so it can access the Google Forms api but the file with the code and data is stored on the local machine.

              Right now I am using static code but as soon as I figure out the best way to generate and write the html to a local file substituting static values for those in variables, I will post my code for others to play with.

              It also looks like I may be able to use a ui_dlg_box() to display the chart on the fly. I will investigate this as well.

              Here is the rough code so far to generate the chart. When I get more into it I will have it substitue the values in variables for the static ones under data.addrows([

                  <!--Load the AJAX API-->
                  <script type="text/javascript" src=""></script>
                  <script type="text/javascript">
                    // Load the Visualization API and the corechart package.
                    google.charts.load('current', {'packages':['corechart']});
                    // Set a callback to run when the Google Visualization API is loaded.
                    // Callback that creates and populates a data table,
                    // instantiates the pie chart, passes in the data and
                    // draws it.
                    function drawChart() {
                      // Create the data table.
                      var data = new google.visualization.DataTable();
                      data.addColumn('string', 'Sales');
                      data.addColumn('number', 'Commission');
                        ['Sales', 2220.35],
                        ['Commission', 200.59],
                        ['Paid', 175.59],
                        ['Due', 25.00]
                      // Set chart options
                      var options = {'title':'Sales Performace',
                      // Instantiate and draw our chart, passing in some options.
              		var formatter = new google.visualization.NumberFormat(
                  {prefix: '$', negativeColor: 'red', negativeParens: true});
              formatter.format(data, 1); // Apply formatter to second column
                      var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
                      chart.draw(data, options);
                  <!--Div that will hold the pie chart-->
                  <div id="chart_div"></div>


              • #8
                Re: Pie chart using calculated fields

                Ok, I have gotten the code working to write and rewrite the local html file as data changes. This works perfectly for now.

                I am displaying the html that contains the chart on a form using the supercontrol "Web Content".

                I am now trying to figure out how to make the "Web Content" refresh every time I change records. The underlying html changes but the "Web Content" does not update.

                I have tried <object>.refresh() and even re-syncing the display but nothing works yet. I have looked at the "Web Content" object properties in the object explorer but there is no help on what some of the setting may or may not do.

                Anyone have a clue? Or maybe another way to display an html file on a form so it can be refreshed/updated with changes to the record on when going to a different record?

                Just for anyone that wants to know, here is the code that writes and updates the file. I currently have it in the forms OnFetch event.

                dim vn_sales as n
                dim vn_comish as n
                dim vn_paid as n
                dim vn_due as n
                vn_due = topparent:Comish_due.value
                vn_sales = topparent:Sales_tot_sp.value
                vn_comish = topparent:Comish_tot_sp.value
                vn_paid = topparent:Paid_tot_sp.value
                dim vc_html as c
                vc_html = "<html>"+crlf()
                vc_html=vc_html+"<!--Load the AJAX API-->"+crlf()
                vc_html=vc_html+"<script type=""text/javascript"" src=""""></script>"+crlf()
                vc_html=vc_html+"<script type=""text/javascript"">"+crlf(2)
                vc_html=vc_html+"// Load the Visualization API and the corechart package."+crlf()
                vc_html=vc_html+"google.charts.load('current', {'packages':['corechart']});"+crlf(2)
                vc_html=vc_html+"// Set a callback to run when the Google Visualization API is loaded."+crlf()
                vc_html=vc_html+"// Callback that creates and populates a data table,"+crlf()
                vc_html=vc_html+"// instantiates the pie chart, passes in the data and"+crlf()
                vc_html=vc_html+"// draws it."+crlf()
                vc_html=vc_html+"function drawChart() {"+crlf(2)
                vc_html=vc_html+"// Create the data table."+crlf()
                vc_html=vc_html+"var data = new google.visualization.DataTable();"+crlf()
                vc_html=vc_html+"data.addColumn('string', 'Sales');"+crlf()
                vc_html=vc_html+"data.addColumn('number', 'Commission');"+crlf()
                vc_html=vc_html+"['Sales', "+vn_sales+"],"+crlf()
                vc_html=vc_html+"['Commission', "+vn_comish+"],"+crlf()
                vc_html=vc_html+"['Paid', "+vn_paid+"],"+crlf()
                vc_html=vc_html+"['Due', "+vn_due+"]"+crlf()
                vc_html=vc_html+"// Set chart options"+crlf()
                vc_html=vc_html+"var options = {'title':'Sales Performace',"+crlf()
                vc_html=vc_html+"// Instantiate and draw our chart, passing in some options."+crlf()
                vc_html=vc_html+"var formatter = new google.visualization.NumberFormat("+crlf()
                vc_html=vc_html+"{prefix: '$', negativeColor: 'red', negativeParens: true});"+crlf()
                vc_html=vc_html+"formatter.format(data, 1); // Apply formatter to second column"+crlf(2)
                vc_html=vc_html+"var chart = new google.visualization.PieChart(document.getElementById('chart_div'));"+crlf()
                vc_html=vc_html+"chart.draw(data, options);"+crlf()
                vc_html=vc_html+"<!--Div that will hold the pie chart-->"+crlf()
                vc_html=vc_html+"<div id=""chart_div""></div>"+crlf()
                file_pointer = file.create("C:\T-Six\Charts\test1.html",FILE_RW_SHARED)


                • #9
                  Re: Pie chart using calculated fields

                  Can I just get the google charts data from xbasic function and use them in javascript functions.


                  • #10
                    Re: Pie chart using calculated fields

                    Well that went well!
                    Ted Giles
                    Example Consulting - UK

                    See our site for Alpha Support, Conversion and Upgrade.