3 Replies Latest reply on Apr 4, 2008 3:15 PM by aviorth

    dynamic chart data binding problem

      Hello! I've been using Flex for all of about three days now, and have just hit a problem that I can't seem to find a solution for: I have a [Bindable] XML variable called "queryResults" that I'm using as the dataProvider for a dynamically-created LineChart (it's defined like this: "chart.dataProvider=queryResults.institution.(attribute('composite')=='true');"). Based on what the user does in the GUI, my code occasionally updates the "composite" attribute of the corresponding element in queryResults, which should in turn add or remove the changed element from the chart. My problem is that the changes aren't being reflected in the LineChart.

      I began by building the LineChart statically using MXML tags, and it DID work then: Changing the "composite" attribute to "false" took that element out of the chart, and changing it back to "true" put it back in (this was with the MXML dataProvider attribute defined like this: dataProvider="{queryResults.institution.(attribute('composite')=='true')}"). Unfortunately, my requirements don't make static charts a good option; so I need to find a solution with the dynamically-created chart.

      The ActionScript that I'm using to create the LineChart is below. I'm hoping that I'm just missing something simple, but I'm having a hard time finding examples that are specifically like this one. Any help is greatly appreciated!

        • 1. Re: dynamic chart data binding problem
          aviorth Level 1
          Bumped once out of desperation.... ;)
          • 2. Re: dynamic chart data binding problem
            ntsiii Level 3
            In AS, this line:
            Does NOT create a binding, it only assigns the dataProvider one time. You will need to use BindingUtils to programatically create the binding. I don't do this enough to be able to give an example from the top of my head, but you wll find it in the docs.

            • 3. Re: dynamic chart data binding problem
              aviorth Level 1
              Thanks for the suggestion, Tracy! I just gave that a shot, and while BindingUtils did get the chart updating when queryResults changed, my problem now is that it only seems to work with "queryResults.institution," and not with "queryResults.institution.(@composite==true)." Reading through the docs, they say that e4x doesn't work with BindingUtils, so it looks like I've hit another obstacle with it.

              I managed a workaround today of setting a watcher on queryResults, and having it call a method that redraws the chart; so maybe that'll have to do. I'm not sure that that's the best solution, though, so any other suggestions are certainly welcome!