2 Replies Latest reply on Nov 10, 2010 1:34 AM by selvakumar p

    Data Labels in line series

    selvakumar p Level 1

      Hi all,

       

      Is it possible to have data labels for line series as we have for column series.

      If it is  possible somebody help me on this.

       

      Thanks

        • 1. Re: Data Labels in line series
          BhaskerChari Level 4

          Hi Selvakumar,

           

          Data Labels are different from data tips. I dont think we can specify data labels for LineSeries. But we can make all the data tips to display by default by setting the showAllDataTips="true" on LineChart which might serve your need.

           

          Check the link below:

           

          http://livedocs.adobe.com/flex/3/html/help.html?content=charts_types_09.html

           

           

           

          You can also check this sample code...

           

          <?xml version="1.0"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
            <mx:Script><![CDATA[
               import mx.collections.ArrayCollection;

               [Bindable]
                public var SMITH:ArrayCollection = new ArrayCollection([
                  {date:"22-Aug-05", close:41.87},
                  {date:"23-Aug-05", close:45.74},
                  {date:"24-Aug-05", close:42.77},
                  {date:"25-Aug-05", close:48.06},
               ]);

               [Bindable]
                public var DECKER:ArrayCollection = new ArrayCollection([
                  {date:"22-Aug-05", close:157.59},
                  {date:"23-Aug-05", close:160.3},
                  {date:"24-Aug-05", close:150.71},
                  {date:"25-Aug-05", close:156.88},
               ]);

              [Bindable]
              public var deckerColor:Number = 0x224488;

              [Bindable]
              public var smithColor:Number = 0x884422;
            ]]></mx:Script>

            <mx:Stroke id="h1Stroke" color="{smithColor}" weight="8" alpha=".75" caps="square"/>

            <mx:Stroke id="h2Stroke" color="{deckerColor}" weight="8" alpha=".75" caps="square"/>

            <mx:Panel title="Column Chart With Multiple Axes">
               <mx:LineChart id="myChart" showAllDataTips="true" showDataTips="true">
                  <mx:horizontalAxis>
                     <mx:CategoryAxis id="h1" categoryField="date"/>
                  </mx:horizontalAxis>

                  <mx:horizontalAxisRenderers>
                      <mx:AxisRenderer placement="bottom" axis="{h1}"/>
                  </mx:horizontalAxisRenderers>

                  <mx:verticalAxisRenderers>
                      <mx:AxisRenderer canDropLabels="true" placement="left" axis="{v1}">
                          <mx:axisStroke>{h1Stroke}</mx:axisStroke>
                      </mx:AxisRenderer>
                      <mx:AxisRenderer placement="left" axis="{v2}">
                          <mx:axisStroke>{h2Stroke}</mx:axisStroke>
                      </mx:AxisRenderer>
                      <mx:AxisRenderer placement="left" axis="{v3}">
                          <mx:axisStroke>{h2Stroke}</mx:axisStroke>
                      </mx:AxisRenderer>
                  </mx:verticalAxisRenderers>

                  <mx:series>
                     <mx:LineSeries id="cs1" horizontalAxis="{h1}" dataProvider="{SMITH}" yField="close" displayName="SMITH">
                          <mx:fill>
                              <mx:SolidColor color="{smithColor}"/>
                          </mx:fill>
                          <mx:verticalAxis>
                             <mx:LinearAxis id="v1" minimum="40" maximum="50"/>
                          </mx:verticalAxis>
                     </mx:LineSeries>
                     <mx:LineSeries id="cs2" horizontalAxis="{h1}" dataProvider="{DECKER}" yField="close" displayName="DECKER">
                          <mx:verticalAxis>
                              <mx:LinearAxis id="v2" minimum="150" maximum="170"/>          
                          </mx:verticalAxis>
                          <mx:lineStroke>
                              <mx:Stroke color="{deckerColor}" weight="4" alpha="1"/>
                          </mx:lineStroke>
                     </mx:LineSeries>
                     <mx:LineSeries id="cs3" horizontalAxis="{h1}" dataProvider="{DECKER}" yField="close" displayName="DECKER">
                          <mx:verticalAxis>
                              <mx:LinearAxis id="v3" minimum="100" maximum="170"/>          
                          </mx:verticalAxis>
                          <mx:lineStroke>
                              <mx:Stroke color="{deckerColor}" weight="4" alpha="1"/>
                          </mx:lineStroke>
                     </mx:LineSeries>
                  </mx:series>
               </mx:LineChart>
               <mx:Legend dataProvider="{myChart}"/>
            </mx:Panel>
          </mx:Application>

           

           

          Thanks,

          Bhasker

          • 2. Re: Data Labels in line series
            selvakumar p Level 1

            Hi ,

             

            Thanks for ur reply

            I have a column chart which is having line series i want to display labels only for line series .

            If iam giving showalldatatips to true then the columnsereis datatip is also shown, i want only the line series datatip to be shown like labels