5 Replies Latest reply on Mar 14, 2007 7:03 AM by Arthur@aginova

    Hslider as date range in charts

    Arthur@aginova
      im using hslider as a date range to show data based
      on the two dates selected for the chart.
      my problem is how to alter the chart data, based on the date selection from the hslider
      note: there are 3 line series on the chart, so the series data has to be shown based on the hslider's date range selection

      Any Idea!. Any examples
        • 1. Re: Hslider as date range in charts
          peterent Level 2
          Your chart uses a Collection for its data, right? A Collection has a filter function - a simple function that takes a single argument (a record from the data) and returns a Boolean.

          When you get a change on your slider, invoke the Collection's refresh() method. That will cause the filter function to run. Now you just write the filter function:

          // assuming myData is the Collection:
          myData.filterFunction = testDates;
          ...
          public function testDates( item:Object ) : Boolean
          {
          // test your item to see if should be visible in the chart. return true if it should, false otherwise.
          }

          Then your HSlider can do: change="myData.refresh()"

          • 2. Re: Hslider as date range in charts
            Arthur@aginova Level 1
            im doin something like this:
            public function processFilter1(item:Object):Boolean
            {
            var result:Boolean=false;
            if (item.i=="1001")
            {
            if(item.ts>=moteData[slider.values[0]].ts && item.ts<=moteData[slider.values[1]].ts)
            // motedata is an array fetched from httpservice
            {
            result=true;
            }
            }
            return result;
            }

            im filtering 2 areas in my dataprovider, one is the id=1001 & date range
            im getting nothing
            • 3. Re: Hslider as date range in charts
              peterent Level 2
              I suggest you step through this code using the debugger. The debugger will tell you the values of the variables and their data types.

              When I need to do something like this, I set up additional local variables for any values which are not local to the function:

              var v0:* = moteData[slider.values[0]];
              var v1:* = moteData[slider.values[1]];

              I am using the * data type for these; the * means the anonymous type (or generic) type. This way you don't have to know what type the data is. It is just a simple way to double-check you really have the data you think you have.

              The debugger will then show you the values for v0 and v1.
              • 4. Re: Hslider as date range in charts
                Arthur@aginova Level 1
                hey got to work the slider with multiple series, thanks
                another issue is the hslider does not show me the values in sequence, how do i sort a date field, i get alphabetical sort,
                eg. Fri Mon Sat Sun etc...
                how do i sort the dates on the hslider?
                • 5. Re: Hslider as date range in charts
                  Arthur@aginova Level 1
                  found a good dual slider use it if you're trying to make something like google charts, thanks to brendan, good work.
                  http://www.stretchmedia.ca/code_examples/chart_range_selection/main.html