Jump to content
Server Maintenance This Week. ×

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


emtau

Recommended Posts

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?

Link to comment
Share on other sites

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
  • Thanks 1
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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