8 Replies Latest reply on Dec 21, 2015 10:12 AM by cbrown

    Chart Labelling

    cbrown

      I have data regarding a number of sales, and I've created a new layout to display this information in a chart.  Simple layout, just a chart assigned to my Sales table and some buttons to sort the records and display the chart differently.  I would like this one chart to adapt depending on how the data is sorted, instead of having multiple charts.  I can get it to display just fine when I sort by "Year", for example, and the chart display changes accurately when I change the sort, but the issue comes in trying to get the chart labels to change for each sort.

       

      The criteria are "Year", "Payment Method", "Sale Portal" and "Primary Income Type"

       

      I created a new input field "Current Sort" that stores text about what the information is currently being sorted by.  My sorting buttons run a small script to "Sort By" and Set Field [ Sales::Current Sort ; "Year"]

       

      Now I got to my chart labels and try to set my X-Axis by calculation to run a small test with 0 as my secondary result to see what is and isn't working:

      If ( Sales::Current Sort="Year" ; Sales::Year ; 0 )

       

      And all I get for my label is 0

       

      I've tried as many variations as I can think of, with variables too, but it's not working

       

      Is this even doable?  My knowledge and coding capabilities are limited

        • 1. Re: Chart Labelling
          mikebeargie

          Well, it's working in the sense that it's returning a value of zero. So one of two things is happening, either this isn't valid: Sales::Current Sort="Year", or your chart object needs to be refreshed because it's returning zero before sort is set to "year".


          You can add a refresh window script step to the end of the script that sets sort to "year" and see if that updates it.

          • 2. Re: Chart Labelling
            cbrown

            Makes sense

             

            I added refresh window to the script, and I also tried a refresh object, but neither made a difference :/

             

            I imagine if there's a way to set chart label in a script that'd help make sure it's all happening in the proper order too

            • 3. Re: Chart Labelling
              mikebeargie

              If your chart labels are calculated from global variables (EG $$label1, $$label2, etc..), then you could change them via script.

              • 4. Re: Chart Labelling
                cbrown

                I changed the script to set variable

                 

                Set Variable [$$current_sort ; Value:Sales::Year]

                 

                and then changed my chart label to $$current_sort

                 

                but it only returns one value (eg 2015) instead of all the values

                 

                I can get the labels to switch given the sort now, but again, only returning one value instead of all values

                • 5. Re: Chart Labelling
                  mikebeargie

                  Try:

                   

                  List(Value:Sales::Year)

                   

                  otherwise you're only pulling a single record's value instead of a found set.

                  • 6. Re: Chart Labelling
                    cbrown

                    Changed to

                     

                    Set Variable [$$current_sort ; Value:List(Sales::Year)

                     

                    but now it returns 2014 for all labels instead of 2015??

                    • 7. Re: Chart Labelling
                      mikebeargie

                      You'll need to come up with a calculation that works to return the value in a format you need.

                       

                      Without a demo file to play around with or screenshots, it's getting hard to continue to offer suggestions.

                      • 8. Re: Chart Labelling
                        cbrown

                        I figured it out. 

                         

                        After many attempts and trying a number of functions to list values... it ended up working by setting the chart label calculation to Case ( Sales::Current Sort="Year" ; Sales::Year ; Sales::Current Sort="Payment Method" ; Sales::Payment Method ; Sales::Current Sort="Sale Portal" ; Sales::Sale Portal ; Sales::Current Sort="Primary Income Type" ; Sales::Primary Income Type ; 0 )

                         

                        no variable needed

                         

                        thanks for helping me get the creative juices flowing!