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

    Create custom stroke on LineSeries?

    john isaacks Level 1

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


      <mx:LineSeries yField="apple">


      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">
      <result month="Feb-04">
      <result month="Mar-04">

      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??


        • 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



            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?