3 Replies Latest reply on Oct 23, 2009 9:26 AM by kminev

    Single Chart Series with multiple color data points

    kminev
      I am developing an application using the flex chart component and I am binding data to 3 different chart series which is pretty intense processing. I was wondering can I use only one chart series and when I bind the data points just to change the color per data point which meet certain criteria?

      Here one method from my application where I am dynamically binding data to my series.

      private function loadSeries(data:XMLList, yAxis:String):void
      {
      seriesAdd.yField = yAxis;
      seriesAdd.xField = "Date";
      //seriesDelete.yField = yAxis;
      //seriesDelete.xField = "Date";
      //seriesChange.yField = yAxis;
      //seriesChange.xField = "Date";

      seriesAdd.dataProvider = data.Trade.(A == 'Add');
      seriesAdd.//Can I change the color per each data point if I have multiple data sets?

      //seriesDelete.dataProvider = data.Trade.(A == 'Delete');
      //seriesChange.dataProvider = data.Trade.(A == 'Change');
      }


      Thank you
        • 1. Re: Single Chart Series with multiple color data points
          kminev Level 1
          I think I found something to get me started: http://livedocs.adobe.com/flex/3/html/help.html?content=charts_displayingdata_09.html

          My next question is if I have the following function to fill my data points:\

          private function myFillFunction(element:ChartItem, index:Number):IFill {
          var c:SolidColor = new SolidColor(0x00CC00);

          var item:ColumnSeriesItem = ColumnSeriesItem(element);
          var sales:Number = Number(item.yValue);

          if (sales >= 50000) {
          return c;
          } else {
          // They have not met their goal.
          c.color = 0xFF0000;
          }
          return c;
          }

          How can I access values that pertain to the specific chart item, but are not plotted on the x and y axis. Something similar to the checking on the above function, but check if value that is not plotted but still exists on the data provider.


          Thanks in advance.
          • 2. Re: Single Chart Series with multiple color data points
            kminev Level 1
            I guess I answered my questions. For finding the value I just used HitData object and colored my data point if I found the value.

            Here is the code I wrote for that if someone comes across with similar problem:

            private function myFillFunction(element:ChartItem, index:Number):IFill
            {
            var addColor:SolidColor = new SolidColor(0x00FF00);//Green
            var deleteColor:SolidColor = new SolidColor(0xFF0066);//Red
            var changeColor:SolidColor = new SolidColor(0x0033ff);//Blue

            var item:PlotSeriesItem = PlotSeriesItem(element);

            var hitData:HitData = new HitData(1, 1, item.x, item.y, item);

            switch(hitData.item.A)
            {
            case "Add":
            return addColor;
            break;

            case "Delete":
            return deleteColor;
            break;

            case "Change":
            return changeColor;
            break;
            default:
            return null;
            break;
            }
            }

            This is my fill function on the plot series