2 Replies Latest reply on Jan 19, 2010 9:29 AM by john isaacks

    Create custom stroke on LineSeries?

    john isaacks

      You can easily set a stroke on a line series like this:

       

      <mx:LineSeries yField="apple">
          <mx:lineStroke>
              <mx:Stroke 
                          color="0x6699FF" 
                          weight="4" 
                          alpha=".8"
              />
          </mx:lineStroke>
      </mx:LineSeries>
      
      

       


      This will set alpha for the entire stroke to .8

      But I want to be able to set a different alpha on the stoke for each plot based on something in the dataProvider.

      For example the yField in the lineSeries is "Apple" which is how it knows where to plot for the lineSeries. I want to be able to add something like alphaField which tells it what to set the stroke alpha for each plot.

      so if my dataProvider was:

       

      <result month="Jan-04">
          <apple>81768</apple>
          <alpha>1</alpha>
      </result>
      <result month="Feb-04">
          <apple>51156</apple>
          <alpha>1</alpha>
      </result>
      <result month="Mar-04">
          <apple>51156</apple>
          <alpha>.5</alpha>
      </result>
      
      


      And I set alphaField="alpha" then I would have a solid stroke from plot 0 to plot 1 and then a 50% alpha stroke from plot 1 to plot 2.

      How can I do this??? I am looking in the commitProperties() and updateDisplayList() methods of LineSeries and have no idea what would need to be added/changed to make this?

      I am pretty sure, this class has to use Graphics.lineTo() to draw each plot, so basically it would need to "get" the current alphaField value somehow, and apply a Graphics.lineStyle() with the correct alpha before drawing each line. But how??

      Thanks!!

        • 1. Re: Create custom stroke on LineSeries?
          msakrejda Level 4

          You may be able to do what you want with a custom lineSegmentRenderer (just extend the standard LineRenderer or ShadowLineRenderer), although I've never really worked with this style.

          • 2. Re: Create custom stroke on LineSeries?
            john isaacks Level 1

            @msakrejda

             

            You have gotten me much closer to my answer.

             

            When I extend LineRenderer I override updateDisplayList() which calls GraphicsUtilities.drawPolyLine()

             

            I extend GraphicsUtilities and override the method drawPolyLine() as this is where the line is actually drawn.

             

            I can call lineStyle() in here and change the alpha of the line...

             

             

            I still have 1 thing I cannot figure out, from within the drawPolyLine() method how can I access that data that dictates what the alpha should be?

             

            Thanks!!!!