Thx ... but i want its show 2 or more lineseries in the same linechart.
--- In [email protected], "Sunil Bannur" <[EMAIL PROTECTED]> wrote: > > You should use the secondSeries array to have a secondaryVertical Axis. > > Check the livedocs on how to work with secondary Axes. > > > > This is how the addSeries function should look like > > > > Private function addSeries():void > > { > > bigChart.secondDataProvider = // the data provider for the secondseries. > > // initialize your series code > > bigChart.secondSeries = newArr; // This has the second series. > > bigChart.secondVerticalAxis.minimum = 0 // set your secondary axis values > > } > > > > -Sunil > > > > ________________________________ > > From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of ricoterox > Sent: Wednesday, June 13, 2007 7:25 PM > To: [email protected] > Subject: [flexcoders] Add series in lineaChart [ Help Ely ] > > > > Hello flexcoders !!! > > I´m doing an aplicattion with charts but I need some help. > > this is my problem ... > > I have two datagrids and two lines charts and I complete this with 2 > different xml. > > I want to do this ... but when I press the button add (agregar in > Spanish), I need to add a second line chart in the chart... > > now I ´m adding only one ... but I need to add more than one and can > select one or another from second datagrid (downthere). > > Another thing I want to do is ... when I show 2 or more linechart, > those start in the same vertical Axis, but I want that those > linecharts start in 0 or in another number > > I need a function to do that ... but I dont have idea. > > this is the code I am using right now... > > please I need some help > > Thank you very much for your help. > > <?xml version="1.0" encoding="utf-8"?> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml <http://www.adobe.com/2006/mxml> " > xmlns:mccune="com.dougmccune.controls.*" > layout="absolute" > creationComplete="inicio();"> > > <mx:Script> > <![CDATA[ > import mx.events.*; > import mx.collections.*; > import mx.managers.SystemManager; > import mx.events.ResizeEvent; > import mx.graphics.Stroke; > import mx.graphics.SolidColor; > import mx.collections.ArrayCollection; > import mx.utils.ArrayUtil; > import mx.events.DividerEvent; > import mx.managers.SystemManager; > import mx.charts.LineChart; > import mx.charts.series.LineSeries; > // Inicio Codigo Slider > [Embed(source="divider.png")] [Bindable] public var dividerClass:Class; > [Embed(source="blank.png")] [Bindable] public var > blankDividerClass:Class; > > private var DATA_LENGTH:Number = 10; > private var LEFT_START:Number = 3; > private var RIGHT_START:Number = 7; > [Bindable] public var newData:ArrayCollection; > > [Bindable] public var acData:ArrayCollection; > [Bindable] public var acDatos:ArrayCollection; > > [Bindable] private var leftBoundary:Number; > [Bindable] private var rightBoundary:Number; > > private var staticLeftBoundary:Number; > private var staticRightBoundary:Number; > public var smallDrag:Boolean = false; > public var bigDrag:Boolean = false; > public var mouseXRef:Number; > > > private function chartComplete():void > { > chartData = new ArrayCollection(newData.source); > mainData = new ArrayCollection(chartData.source); > acDatos = new ArrayCollection(acData.source); > > DATA_LENGTH = newData.length; > LEFT_START = 1; > RIGHT_START = newData.length; > leftBoundary = LEFT_START; > rightBoundary = RIGHT_START; > updateBoundariesFromSlider(); > } > > private function updateBoundariesFromSlider():void > { > leftBoundary = slider.values[0]; > rightBoundary = slider.values[1]; > updateMainData(); > } > > private function updateBoundariesFromDivider(event:DividerEvent):void > { > leftBoundary = > Math.abs(HDividedBox(event.target).getChildAt(0).width / > (event.target.width / chartData.length)); > rightBoundary = Math.abs(chartData.length - > (HDividedBox(event.target).getChildAt(2).width / (event.target.width / > chartData.length))); > updateMainData(); > } > > private function updateMainData():void > { > mainData.source = chartData.source.slice(leftBoundary, rightBoundary) > } > > private function setMouseDown(theChart:CartesianChart):void > { > mouseXRef = this.mouseX; > staticLeftBoundary = leftBoundary; > staticRightBoundary = rightBoundary; > if(theChart == bigChart) bigDrag = true; > if(theChart == smallChart) smallDrag = true; > this.systemManager.addEventListener(MouseEvent.MOUSE_MOVE, moveChart); > this.systemManager.addEventListener(MouseEvent.MOUSE_UP, stopDragging); > } > > private function stopDragging(event:MouseEvent):void > { > smallDrag = false; > bigDrag = false; > this.systemManager.removeEventListener(MouseEvent.MOUSE_MOVE, > moveChart); > this.systemManager.removeEventListener(MouseEvent.MOUSE_UP, > stopDragging); > } > > private function moveChart(event:MouseEvent):void > { > if(bigDrag) { > leftBoundary = staticLeftBoundary + (mouseXRef - this.mouseX) / > (bigChart.width / mainData.length); > rightBoundary = staticRightBoundary + (mouseXRef - this.mouseX) / > (bigChart.width / mainData.length); > } else if(smallDrag) { > leftBoundary = staticLeftBoundary - (mouseXRef - this.mouseX) / > (smallChart.width / chartData.length); > rightBoundary = staticRightBoundary - (mouseXRef - this.mouseX) / > (smallChart.width / chartData.length); > }} > > // Fin Codigo Slider > private function inicio():void > { > feedRequest.send(); > datosxmlweb.send(); > > } > private function agregar():void > { > acDataClean.addItem({first:muestra.text}); > > feedRequest.url="http://www.invertironline.com/graficador/cotizaciones.asp?tid_titulo= <http://www.invertironline.com/graficador/cotizaciones.asp?tid_titulo=> "+ > datosxml.selectedItem.numero; > feedRequest.send(); > > acDatos.removeItemAt(datosxml.selectedIndex); > addSeries(); > > } > public function borrar():void{ > if (datosxml2.selectedIndex >= 0){ > acDataClean.removeItemAt(datosxml2.selectedIndex); > > acDatos.addItem(datosxml2.selectedIndex); > } > } > /* ******************************************************* */ > private function addSeries():void { > > // create new array, populate, assign to series > > var newArr:Array = new Array(); > //for(var i=0; i<datosxml.selectedItems.length; i++){ > > var ls:LineSeries=new LineSeries(); > ls.yField='preculti'; > ls.displayName='Cotizacion'; > newArr.push (ls); > > bigChart.series = newArr; > //} > } > ]]> > </mx:Script> > > <mx:HTTPService id="feedRequest" > url="http://www.invertironline.com/graficador/cotizaciones.asp?tid_titulo=20441 <http://www.invertironline.com/graficador/cotizaciones.asp?tid_titulo=20441> " > > useProxy="false" > result="newData=ArrayCollection(feedRequest.lastResult.rss.channel.result);chartComplete();addSeries();"/> > > <mx:HTTPService id="datosxmlweb" > url="http://www.invertironline.com/graficador/datoscbx.xml <http://www.invertironline.com/graficador/datoscbx.xml> " > useProxy="false" > result="acData=ArrayCollection(datosxmlweb.lastResult.rss.channel.result);"/> > > <mx:ArrayCollection id="acDataClean"/> > <mx:ArrayCollection id="chartData"/> > <mx:ArrayCollection id="mainData"/> > > <mx:Panel title="Line Chart" right="10" bottom="10" top="10" > left="245" id="panel1"> > <mx:Legend dataProvider="{bigChart}" id="legend"/> > > <!-- Inicia Codigo Slider --> > <mx:LineChart id="bigChart" showDataTips="true" > dataProvider="{mainData}" width="100%" height="100%"> > <mx:horizontalAxis> > <mx:CategoryAxis categoryField="fechhora" ticksBetweenLabels="true" > title="Horarios"/> > </mx:horizontalAxis> > > <mx:verticalAxis> > <mx:LinearAxis baseAtZero="false" > title="Variaciones"/></mx:verticalAxis> > <mx:verticalAxisRenderer> > <mx:AxisRenderer visible="true" /></mx:verticalAxisRenderer> > > <mx:series> > <mx:Array></mx:Array> > </mx:series> > <!-- <mx:series> > <mx:LineSeries yField="preculti" displayName="Cotizacion"/> > <mx:LineSeries yField="precaper" displayName="Cotizacion"/> > <mx:LineSeries yField="precmini" displayName="Cotizacion"/> > <mx:LineSeries yField="precmaxi" displayName="Cotizacion"/> > </mx:series> --> > > <mx:annotationElements> > <mx:Canvas width="100%" height="100%" buttonMode="true" > mouseDown="setMouseDown(bigChart)" /> > </mx:annotationElements> > > </mx:LineChart> > > <mx:VBox verticalGap="0" width="100%" verticalScrollPolicy="off" > horizontalAlign="right"> > > <mx:CartesianChart id="smallChart" dataProvider="{chartData}" > width="100%" height="100"> > > <mx:horizontalAxis><mx:CategoryAxis > categoryField="fechhora"/></mx:horizontalAxis> > <mx:horizontalAxisRenderer><mx:AxisRenderer visible="false" > /></mx:horizontalAxisRenderer> > > <mx:verticalAxis><mx:LinearAxis baseAtZero="false" > title="Variaciones"/></mx:verticalAxis> > <mx:verticalAxisRenderer><mx:AxisRenderer visible="false" > /></mx:verticalAxisRenderer> > <mx:series> > <mx:AreaSeries name="preculti" yField="preculti" areaStroke="{new > Stroke(0x0033CC, 2)}" areaFill="{new SolidColor(0x0033CC, 0.5)}" /> > </mx:series> > > <mx:annotationElements> > <mx:HDividedBox id="overlayCanvas" width="100%" alpha="1" > dividerAffordance="5" liveDragging="true" horizontalGap="10" > verticalGap="0" horizontalScrollPolicy="off" > dividerDrag="updateBoundariesFromDivider(event)" > dividerSkin="{blankDividerClass}" > mouseOver="overlayCanvas.setStyle('dividerSkin', > dividerClass);" mouseOut="overlayCanvas.setStyle('dividerSkin', > blankDividerClass);"> > <mx:Canvas id="leftBox" height="100%" > width="{(overlayCanvas.width / chartData.length) * > leftBoundary}" > backgroundAlpha="0.8" backgroundColor="#EEEEEE" > borderThickness="1" borderColor="#999999" borderStyle="solid" /> > <mx:Canvas id="visibleBox" width="100%" height="100%" > buttonMode="true" mouseDown="setMouseDown(smallChart)" /> > <mx:Canvas id="rightBox" height="100%" > width="{(overlayCanvas.width / chartData.length) * > (chartData.length - rightBoundary)}" > backgroundAlpha="0.8" backgroundColor="#EEEEEE" > borderThickness="1" borderColor="#999999" borderStyle="solid"/> > </mx:HDividedBox> > </mx:annotationElements> > > </mx:CartesianChart> > <mx:Spacer height="-20" /> > <!-- width="{overlayCanvas.width}"--> > <mccune:HSlider id="slider" left="0" > width="{overlayCanvas.width}" > height="25" > > trackHighlightSkin="com.dougmccune.skins.SliderThumbHighlightSkin" > allowTrackClick="true" allowThumbOverlap="false" > liveDragging="true" > change="updateBoundariesFromSlider()" > showDataTip="true" dataTipPlacement="bottom" > dataTipOffset="3" > showTrackHighlight="true" > thumbCount="2" snapInterval="1" > values="{[leftBoundary, rightBoundary]}" > minimum="0" maximum="{chartData.length - 1}" > /> > </mx:VBox> > <!--- Fin Codigo Slider --> > </mx:Panel> > <mx:Panel x="10" width="227" layout="absolute" title="Lista de > papeles" bottom="10" top="10" id="panel2"> > > <mx:DataGrid x="0" y="0" width="207" > height="279" id="datosxml" > allowMultipleSelection="true" > dataProvider="{acDatos}" > dragEnabled="false" > dropEnabled="false" > dragMoveEnabled="false"> > <mx:columns> > <mx:DataGridColumn headerText="Column 1" dataField="nombre"/> > </mx:columns> > </mx:DataGrid> > > <mx:Button x="0" y="338" label="Agregar" width="58" > click="agregar();" id="btnA"/> > <mx:Button x="66" y="338" label="Borrar" width="50" id="btnB" > click="borrar();"/> > > <mx:Label x="1" y="299" id="muestra" > text="{datosxml.selectedItem.description}"/> > <mx:Label x="78.5" y="314" id="num" > text="{datosxml.selectedItem.numero}"/> > > <mx:DataGrid x="0" y="379" id="datosxml2" > allowMultipleSelection="false" > dataProvider="{acDataClean}" > dragEnabled="false" > dropEnabled="false" > dragMoveEnabled="false" width="207" height="117"> > <mx:columns> > <mx:DataGridColumn headerText="Column 2" dataField="first"/> > </mx:columns> > </mx:DataGrid> > <mx:Label x="10" y="513" > text="{datosxml2.selectedItem.description}" id="muestra2"/> > </mx:Panel> > > </mx:Application> >

