Obrigado João, Já consegui por AS3 Quem estiver interessado no código (nem que seja só para cascar):
<?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"> <fx:Declarations> <!-- Place non-visual elements (e.g., services, value objects) here --> </fx:Declarations> <fx:Script> <![CDATA[ import mx.collections.ArrayCollection; [Bindable] public var arr1:ArrayCollection = new ArrayCollection([ {Data:"2011",ID_Serie:"9",Valor:11}, {Data:"2012",ID_Serie:"9",Valor:22}, {Data:"2013",ID_Serie:"25",Valor:33}, {Data:"2011",ID_Serie:"25",Valor:44}, {Data:"2012",ID_Serie:"25",Valor:55}, {Data:"2013",ID_Serie:"9",Valor:66}]); [Bindable] public var arr2:ArrayCollection = new ArrayCollection(); public var arrProp:ArrayCollection = new ArrayCollection(); public var arrUDatas:ArrayCollection = new ArrayCollection(); public function transformGrid():void { var arrIDSerie:ArrayCollection = new ArrayCollection(); for(var a:Number = 0; a<arr1.length; a++) { arrIDSerie.addItem(arr1[a].ID_Serie); } arrProp = getUniqueValues(arrIDSerie); callLater(populaDatas,null); } public function populaDatas():void { var arrDatas:ArrayCollection = new ArrayCollection(); for(var a:Number = 0; a<arr1.length; a++) { arrDatas.addItem(arr1[a].Data); } arrUDatas = getUniqueValues(arrDatas); callLater(populanovosdados,null); } public function populanovosdados():void { var i:Number = 0; for(i=0; i<arrUDatas.length;i++) { var obj:Object = new Object(); obj.Data = arrUDatas[i]; for(var a:Number = 0; a<arrProp.length; a++) { var str:String = arrProp[a]; for(var s:Number = 0; s<arr1.length; s++) { if(arrUDatas[i] == arr1[s].Data && str == String(arr1[s].ID_Serie)) { obj[str] = arr1[s].Valor; } } } arr2.addItem(obj); } } public function getUniqueValues (collection : ArrayCollection):ArrayCollection { var length : Number = collection.length; var dic : Dictionary = new Dictionary(); //this should be whatever type of object you have inside your AC var value : Object; for(var i:Number = 0; i < length; i++){ value = collection.getItemAt(i); dic[value] = value; } //this bit goes through the dictionary and puts data into a new AC var unique:ArrayCollection = new ArrayCollection(); for(var prop :String in dic){ unique.addItem(dic[prop]); } return unique; } ]]> </fx:Script> <mx:DataGrid x="59" y="111" dataProvider="{arr1}"/> <mx:DataGrid x="451" y="111" dataProvider="{arr2}"/> <s:Button x="369" y="295" label="Transform" click="transformGrid()"/> </s:Application> 2013/5/3 João Fernandes <[email protected]> > Experimenta usar as classes de OLAP, devem de resolver o teu problema. > > > 2013/5/3 Luis Costa <[email protected]> > >> Boas, eu sei que este problema é só uma questão de algoritmo e que o >> posso descobrir sozinho, contudo também sei que estar a partir pedra em >> algo que pode ser demasiado simples mas estar a passar-me completamente ao >> lado. >> >> Tenho um resultado que me dá algo do estilo: >> Data - Serie - Valor >> >> 2011 - Lisboa - 21 >> 2012 - Lisboa - 32 >> 2013 - Lisboa - 43 >> 2011 - Porto - 12 >> 2012 - Porto - 33 >> 2013 - Porto - 21 >> >> Ou seja um resultado da pluviosidade (por exemplo) da série Porto e da >> série Lisboa e queria que isto convertesse a tabela de resultados para algo >> como >> >> Data - Lisboa - Porto >> 2011 - 21 - 12 >> 2012 - 32 - 33 >> 2013 - 43 - 21 >> >> Eu tenho quase a certeza que até já fiz isto mas não encontro por nada >> Se alguém conseguir ajudar, agradeço >> Cumprimentos >> >> >> >> >> -- >> Luís Medeiro Costa >> >> Flex Front-End Developer >> URL: http://www.luiscostaweb.com/ >> E-mail: [email protected] >> MSN: [email protected] >> Twitter: http://twitter.com/LTostas >> >> -- >> Recebeu esta mensagem porque está inscrito no grupo "Mailing List da >> Comunidade Portuguesa de Rich Internet Applications - www.riapt.org" dos >> Grupos do Google. >> >> Para anular a subscrição deste grupo e parar de receber emails deste >> grupo, envie um email para [email protected]. >> Para publicar uma mensagem neste grupo, envie um e-mail para >> [email protected]. >> Visite este grupo em http://groups.google.com/group/riapt?hl=pt-PT. >> Para mais opções, consulte https://groups.google.com/groups/opt_out. >> >> >> > > > > -- > > João Fernandes > > -- > Recebeu esta mensagem porque está inscrito no grupo "Mailing List da > Comunidade Portuguesa de Rich Internet Applications - www.riapt.org" dos > Grupos do Google. > > Para anular a subscrição deste grupo e parar de receber emails deste > grupo, envie um email para [email protected]. > Para publicar uma mensagem neste grupo, envie um e-mail para > [email protected]. > Visite este grupo em http://groups.google.com/group/riapt?hl=pt-PT. > Para mais opções, consulte https://groups.google.com/groups/opt_out. > > > -- Luís Medeiro Costa Flex Front-End Developer URL: http://www.luiscostaweb.com/ E-mail: [email protected] MSN: [email protected] Twitter: http://twitter.com/LTostas -- Recebeu esta mensagem porque está inscrito no grupo "Mailing List da Comunidade Portuguesa de Rich Internet Applications - www.riapt.org" dos Grupos do Google. Para anular a subscrição deste grupo e parar de receber emails deste grupo, envie um email para [email protected]. Para publicar uma mensagem neste grupo, envie um e-mail para [email protected]. Visite este grupo em http://groups.google.com/group/riapt?hl=pt-PT. Para mais opções, consulte https://groups.google.com/groups/opt_out.
