2 Replies Latest reply on Feb 22, 2007 2:30 AM by dave cragg

    Column chart with null data items

    dave cragg Level 2
      I have a Column Chart with an ArrayCollection data provider. The data will sometimes have missing items in some "rows'. For example, it might look like this where the second object has no "Male" property:

      public var myData:ArrayCollection = new ArrayCollection([
      {School: "Priorford", All: 95, Male: 92, Female: 98},
      {School: "Giffnock", All: 87, Female: 89},
      {School: "Hastings", All: 80, Male: 78, Female: 82}

      Sometimes I get the following error:
      TypeError: Error #1009: Cannot access a property or method of a null object
      at mx.charts.chartClasses::NumericAxis/mapCache()

      I'm assuming the error is because of missing data items, but I'm not 100% sure. Some data sets with missing items will display with no error. I can't see a pattern to those that don't.

      -- I can't produce the error when using a "static" data source set in the Flex app itself (such as the example above). These always display correctly, even with missing items.
      -- In the problem case, the source data comes from a MySQL database through a PHP script that is called with a Flex httpService. The returned data is parsed in Flex, and put into the ArrayCollection. I was suspecting that the returned data was flawed in some way, but the same ArrayCollection displays correctly in a DataGrid. The problem is only with the Chart.
      -- I can work round the problem by adding the missing properties and setting them to an empty value. But I don't think I should have to do this.

      Has anyone seen this problem, or know of any obvious thing I might be doing wrong.
        • 1. Re: Column chart with null data items
          try this in your array collection where the value is missing
          replace {School: "Giffnock", All: 87, Female: 89}, - ----- >{School: "Giffnock", All: 87, Male: null,Female: 89},

          apply interpolatevalues="true" for your columnseries
          • 2. Re: Column chart with null data items
            dave cragg Level 2
            Thanks Arthur.

            Your first suggestion is effectively what I'm doing as a workaround. But it is a bit of a pain to have to account for this each time when displaying a chart. It's a particular problem when you don't know in advance what "categories" might be returned by the data and that have to be charted.

            My biggest concern is that this looks like a bug, and the fact that it seems to occur intermittently is a bit worrying. (I also know that eight out of ten reported "bugs" are user error, which is why I was wondering if anyone else had experienced this.)

            About your second suggestion, I think the interpolateValues property only applies to lineSeries.