1 Reply Latest reply on Aug 28, 2008 5:56 PM by Newsgroup_User

    Creating Series at runtime

    dalejoel Level 1
      Hello -

      In the spirit of the Model/View/Controller pattern I have created a view in Flex (mxml). I have a data model that is an object called a Chart which contains an array of ChartSeries. Each ChartSeries contains an array of DataPoint objects that have an x and y coordinate member. These are all classes generated from wsdl on a .NET webservice that provides the data.

      My Flex View already has a PlotChart, a vertical and horizontal axis, and some buttons. What I want to do is examine the Chart object to see how many ChartSeries it contains. For each ChartSeries I wish to create a PlotSeries in actionscript and add it to the PlotChart. I then wish to connect the DataPoint array in the ChartSeries with the newly created PlotSeries.

      The intended result is to have my Flex application be able to display a variable number of PlotSeries all determined by how many the Chart object contains. All of this needs to be runtime decided.

      I am simply using actionscript to create a PlotSeries per ChartSeries, attach as the dataProvider the DataPoint array within the associated ChartSeries, and then call PlotChart.addChild( <new PlotSeries> );

      However, nothing is graphing properly. I am at best getting one point to show up OFF off the graph and seeing nothing else. Stepping through the code I saw that my PlotSeries.item property is not getting set until after I have added the PlotSeries to the PlotChart.

      Any help on how I should approach this would be helpful.

      Thank you,
      Joel
        • 1. Re: Creating Series at runtime
          Level 7

          "dalejoel" <webforumsuser@macromedia.com> wrote in message
          news:g97arp$18p$1@forums.macromedia.com...
          > Hello -
          >
          > In the spirit of the Model/View/Controller pattern I have created a view
          > in
          > Flex (mxml). I have a data model that is an object called a Chart which
          > contains an array of ChartSeries. Each ChartSeries contains an array of
          > DataPoint objects that have an x and y coordinate member. These are all
          > classes
          > generated from wsdl on a .NET webservice that provides the data.
          >
          > My Flex View already has a PlotChart, a vertical and horizontal axis, and
          > some
          > buttons. What I want to do is examine the Chart object to see how many
          > ChartSeries it contains. For each ChartSeries I wish to create a
          > PlotSeries in
          > actionscript and add it to the PlotChart. I then wish to connect the
          > DataPoint
          > array in the ChartSeries with the newly created PlotSeries.
          >
          > The intended result is to have my Flex application be able to display a
          > variable number of PlotSeries all determined by how many the Chart object
          > contains. All of this needs to be runtime decided.
          >
          > I am simply using actionscript to create a PlotSeries per ChartSeries,
          > attach
          > as the dataProvider the DataPoint array within the associated ChartSeries,
          > and
          > then call PlotChart.addChild( <new PlotSeries> );
          >
          > However, nothing is graphing properly. I am at best getting one point to
          > show
          > up OFF off the graph and seeing nothing else. Stepping through the code I
          > saw
          > that my PlotSeries.item property is not getting set until after I have
          > added
          > the PlotSeries to the PlotChart.

          There's an example on my blog that you may or may not find useful:
          http://flexdiary.blogspot.com/2008/08/charting-example.html