1

Pie chart for a single record

I want to display a pie chart within a form, that visualises info contained in numeric fields within a single record of a single table.  But it seems no matter how I try to construct the forumla for the Chart view, or how I edit the Colums for it, I can't get anything to display.

For example, see this screenshot, which shows four formula fields containing numbers, for which I want to produce a pie chart:

Screenshot 2020-02-10 at 22.41.33

Is it possible to display a chart with data from a single record?

3replies Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
  • I would also be interested in this

    Like
    • Lars
    • Lars
    • 8 mths ago
    • Reported - view

    Peter Amies Peter, 

    I have an idea ... it's a hack, but it works.

    First, the pie chart can only show records. This said, you have to convert your fields into records and voilà:

    The steps:

    Pie-Chart is a table like this:

    PieChart-Numbers is just that (the "Name" is for the legend, but I haven't figured out how to use it):

    Then you need the button "Populate Chart". It creates records based on your numbers. Of course it first has to delete the old entries

    delete (select 'PieChart-Numbers');
    let z1 := Number1;
    let p1 := (create 'PieChart-Numbers');
    p1.(Number := z1);
    p1.(Name := "Complete");
    let z2 := Number2;
    (create 'PieChart-Numbers').(Number := z2);
    let z3 := Number3;
    (create 'PieChart-Numbers').(Number := z3);
    let z4 := Number4;
    (create 'PieChart-Numbers').(Number := z4)
    

    For the pie chart itself the config is:

    (where "Kreisdiagramm" = "pie chart", "Datenreihe" = "data row", and "Spalten" = "columns" in english)

    You have to update the chart manually, but you'll have your chart. If you know how to handle the legend ...

    Like
  • Another approach is to use google charts. https://developers.google.com/chart

    Google Charts is open source and is free to use.

    Lots of different chart types possible!

     

    Code in the formula field (to copy/paste):

    let gscode := "<head>
        <script type='text/javascript' src='https://www.gstatic.com/charts/loader.js'></script>
        <script type='text/javascript'>
          google.charts.load('current', {'packages':['corechart']});
          google.charts.setOnLoadCallback(drawChart);
          function drawChart() {
            var data = google.visualization.arrayToDataTable([
              ['Status Counts', 'Total Counts'],
              ['Complete'," + Complete + "],
              ['In Progress'," + 'In Progress' + "],
              ['Unstarted'," + Unstarted + "],
              ['On Hold'," + 'On Hold' + "]
            ]);
            var options = {
              title: 'Example Chart Single Record'
            };
            var chart = new google.visualization.PieChart(document.getElementById('piechart'));
            chart.draw(data, options);
          }
        </script>
      </head>
      <body>
        <div id='piechart' style='width: 900px; height: 500px;'></div>
      </body>
    ";
    html(gscode)

    Steven

    Like 2
Like1 Follow
  • Status Answered
  • 1 Likes
  • 8 mths agoLast active
  • 3Replies
  • 838Views
  • 4 Following