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:
Is it possible to display a chart with data from a single record?
3 replies
-
I would also be interested in this
-
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 ...
-
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
Content aside
- Status Answered
-
1
Likes
- 2 yrs agoLast active
- 3Replies
- 1021Views
-
4
Following