5 Replies Latest reply on Feb 3, 2011 3:01 PM by Pablo Souza

    Where do charts get the datatips from?

    JoGlez Level 1

      Hi all,

           My column chart is generating data tips which i cant seem to access if I were to make a datatip function.. What is the default location for this information? yField isn't working and I can't call the data by item.name... If you would like I can send a screen shot of the charts structure and where the info I want is located... but I just cant seem to drill down to it...

        • 1. Re: Where do charts get the datatips from?
          Pablo Souza Level 3

          I'm not sure If I purely understand your issue. Can you send the screen shot and also your data provider structure ?

          But normally you would be able to have access to the data provider and so custom your data tip from a data tip function.

          Also check this link, you can get helpful information about this:

          http://livedocs.adobe.com/flex/3/html/help.html?content=charts_displayingdata_08.html

           

          Regards,

          Pablo Souza

          • 2. Re: Where do charts get the datatips from?
            JoGlez Level 1

            I initially receive an array which is then parsed (thanks to the help of the Flex community member).  below is the function

            static public function buildSeries(dp:ArrayCollection):void
                    {       
                         if(ConfigData.Global.PowerDetailArray != null)   
                            ConfigData.Global.PowerDetailArray.removeAll();
                        mx.core.FlexGlobals.topLevelApplication.myChart.series = null;
                        var nameTable:Object = {};
                        var timeTable:Object = {};
                        var nameDataList:Array = [];
                        var timeSeriesList:Array = [];
                        var columnSet:ColumnSet = new ColumnSet();
                       
                        columnSet.type = "clustered";
                       
                        for each(var rawItem:Object in dp)
                        {
                            var Name:String = rawItem.Name;               
                            var time:String = rawItem.Time.toString();
                            var Value:Number = rawItem.Value;
                            var dataItem:Object;
                           
                            //if we already have an object for this site,
                            //then retrieve. Otherwise create one.
                            if( nameTable.hasOwnProperty(Name) )
                            {
                                dataItem = nameTable[Name];
                            }
                            else
                            {
                                dataItem = {Name:Name};
                                nameTable[Name] = dataItem;
                                nameDataList.push(dataItem);
                            }
                           
                            //now add a value pair for the time and power
                            dataItem[time] = Value;
                           
                            //we need to create a series for every unique time you have
                            if( !timeTable.hasOwnProperty(time) )
                            {
                                timeTable[time] = 1;
                               
                                var timeSeries:ColumnSeries = new ColumnSeries();
                                timeSeries.yField = time;
                                columnSet.series.push(timeSeries);
                            }
                        }
                       
                        trace(ObjectUtil.toString(nameDataList));
                       
                        //invalidate the chart series to force a redraw
                        var chartSeries:Array = mx.core.FlexGlobals.topLevelApplication.myChart.series;  
                        chartSeries.push(columnSet);
                        mx.core.FlexGlobals.topLevelApplication.myChart.series =chartSeries;
                        mx.core.FlexGlobals.topLevelApplication.myChart.invalidateSeriesStyles();              
                        ConfigData.Global.PowerDetailArray = new ArrayCollection(nameDataList);
                    }

             

            I will provide the screenshot in a couple of minutes

            • 3. Re: screen shot
              JoGlez Level 1

              this screent shot shows where the data I want is located inside of the structure

               

              http://img51.imageshack.us/img51/9250/spotsi.jpg

               

              best if you open on your browser

              • 4. Re: screen shot
                JoGlez Level 1

                bumpity bump bump


                • 5. Re: screen shot
                  Pablo Souza Level 3

                  Have you seen the link I sent you before? You can get access to that any data through the DataTip function:

                   

                   

                   

                  This is the dataprovider:

                   

                  [Bindable]

                  public var expenses:ArrayCollection = new ArrayCollection([

                            {Month:"Jan", Profit:2000, Expenses:1500},

                            {Month:"Feb", Profit:1000, Expenses:200},

                                    {Month:"Mar", Profit:1500, Expenses:500}

                  ]);

                   

                   

                  This is how can you have access to any field from your dataprovider:

                   

                  public function dtFunc(hd:HitData):String

                  {

                       return hd.item.Month + ":<b>$" +             hd.item.Profit + "</b>";

                  }

                   

                   

                   

                   

                  Let me know if you need further help.

                   

                   

                  Best regards,

                  Pablo Souza