Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
Juggernaut

Change Chart x-values and sorting options based on a Button (script)

Featured Replies

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?

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 by comment

  • 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?

  • 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.

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 by comment

This chart demo of yours is exceptional.  Thank you for sharing it with everyone. 😺

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.