October 12, 20232 yr I want to create buttons that will go inside a chart and change the x-values and the sorting option. Is this possible? For example I created a Chart called Post, it works fine. Now I want the same Chart to change to Sections if I click a button, and then Change again to Genders with another button. The first current Chart is working now with Post, how can I create a script to change the Chart to other x-values and sorting?
October 12, 20232 yr It is not possible to change chart settings programmatically. The rest depends on where your chart gets its data from. • If your chart gets its data from the found set, then it's a simple matter of performing a different sort. • If your chart is defined to chart data from related records, then you cannot change the sort order specified inside the chart setup. It may be possible to sort the records by a calculation field that gets its value from one field or another, depending on a global field or variable. You would then have your script change the value of the global and refresh the chart (I haven't tested this, and I suspect it could get slow with a large number of records). The above refers to the sort order. The labels can be calculated, so that's less of a problem (again, I haven't tested this). Consider also the option of having 2 charts and showing only one of them on demand - either by hiding the other one, or using a tab/slide control. Edited October 12, 20232 yr by comment
October 13, 20232 yr Author 14 hours ago, comment said: If your chart gets its data from the found set, then it's a simple matter of performing a different sort. My Chart gets its data from the found set on the same Table (I only have one table), I did perform a different sort (sort by Section) and the bars response correctly but the Labels on the bars stays the same as Post Labels instead of Section Labels. Which is why I thought its because the Chart settings on the x-axis still points to the Post field. Which is why the question to Change the x-axis value from Post Field to the Section Field via script on a button. 15 hours ago, comment said: Consider also the option of having 2 charts and showing only one of them on demand - either by hiding the other one, or using a tab/slide control. I will try this option.. can you elaborate more on the "showing only one of them on demand?" does this require table occurrences for each Chart?
October 13, 20232 yr Author I've solved my problem by creating multiple charts overlaying each other and use the "Hide Object Behavior" on each Chart with a combination of a script trigger on a Radio Button Field with values that corresponds to different sorting conditions. This works well: All Charts are "Hidden" by default, if a user chooses a The Fields Radio Button value like "Posts", a script will be triggered to Show the Chart of "Posts" and sort it accordingly, if the user changes the Field's radio button to "Section" the current Post Chart will be hidden and the Chart of "Section" will appear and sorted accordingly, etc. If there is a problem with this approach please advice. Thanks alot.
October 13, 20232 yr 4 hours ago, emtau said: but the Labels on the bars stays the same As I said, the labels can be calculated - see the attached demo. But separate charts are fine, too. It's just a matter of preference. ChartBySelectedField.fmp12 Edited October 13, 20232 yr by comment
October 13, 20232 yr This chart demo of yours is exceptional. Thank you for sharing it with everyone. 😺
Create an account or sign in to comment