5 Replies Latest reply on Nov 19, 2009 1:06 PM by Yozef0

    A Challenge - Re-Arranging an ArrayCollection

    Yozef0 Level 1

      I am displaying data from an ArrayCollection (dynamically generated) into an Advanced DataGrid. The ArrayCollection (of objects) which looks something like this:


      { date:"2009-11-08", visitors:"252678", name:"Sitename1"},  // On this day, Sitename1 got 252678 visitors

      { date:"2009-11-09", visitors:"655378", name:"Sitename1"},

      { date:"2009-11-10", visitors:"452648", name:"Sitename1"},

      { date:"2009-11-11", visitors:"282678", name:"Sitename1"},

      { date:"2009-11-12", visitors:"315267", name:"Sitename1"},

      { date:"2009-11-13", visitors:"695135", name:"Sitename1"},

      { date:"2009-11-14", visitors:"659862", name:"Sitename1"},

      { date:"2009-11-08", visitors:"598754", name:"Sitename2"}, // On this day, Sitename2 got 598754 visitors

      { date:"2009-11-09", visitors:"255378", name:"Sitename2"},

      { date:"2009-11-10", visitors:"268554", name:"Sitename2"},

      { date:"2009-11-11", visitors:"282678", name:"Sitename2"},

      { date:"2009-11-12", visitors:"568754", name:"Sitename2"},

      { date:"2009-11-13", visitors:"695135", name:"Sitename2"},

      { date:"2009-11-14", visitors:"365874", name:"Sitename2"},

      { date:"2009-11-08", visitors:"552678", name:"Sitename3"}, // On this day, Sitename3 got 552678 visitors

      { date:"2009-11-09", visitors:"265875", name:"Sitename3"},

      { date:"2009-11-10", visitors:"452648", name:"Sitename3"},

      { date:"2009-11-11", visitors:"965875", name:"Sitename3"},

      { date:"2009-11-12", visitors:"695135", name:"Sitename3"},

      { date:"2009-11-14", visitors:"365898", name:"Sitename3"},


      So I need to re-arrange (dynamically) [not sorting] the above ArrayCollection into:

      { date:"2009-11-08", Sitename1:252678, Sitename2:598754, Sitename3:552678},

      { date:"2009-11-09", Sitename1:655378, Sitename2:255378, Sitename3:265875},

      { date:"2009-11-10", Sitename1:452648, Sitename2:268554, Sitename3:452648},



      This Data will be the dataProvider of an AreaChart, so the fastest way is generally the best way to go


      Thanks all