2 Replies Latest reply on Jun 18, 2010 1:36 PM by rtalton

    LineChart -> highlight current day

    PHANTOMIASA Level 1

      Hello!

       

      I have an ArrayCollection for the dataProvider for a Flex LineChart.

      Here is the source code:

      <s:Panel title="My Chart">
           <s:layout>
                <s:HorizontalLayout/>
           </s:layout>
           <mx:LineChart id="myChart" dataProvider="{myArrayCollection}" showDataTips="true">
                <mx:horizontalAxis>
                     <mx:CategoryAxis categoryField="month"/>
                </mx:horizontalAxis>
                <mx:series>
                     <mx:LineSeries yField="line1" displayName="First line"/>
                     <mx:LineSeries yField="line2" displayName="Second line"/>
                </mx:series>
           </mx:LineChart>
           <mx:Legend dataProvider="{myChart}"/>
      </s:Panel>
      

       

      Now I want to create a vertical line into the chart, so I can see, in my case, the current day. I want to highlight it with this vertical line.

      How can I do this? Or are there other possibilities to do this?

       

      Best Regards.

        • 1. Re: LineChart -> highlight current day
          PHANTOMIASA Level 1

          Hm, noone an idea how to solve this?

           

          Best Regards.

          • 2. Re: LineChart -> highlight current day
            rtalton Level 4

            I work with charts quite a bit but have never tried this. It may be more work than it is worth, but I would try adding a ColumnSeries to the chart with only one days' worth of data, using the maximum value in your LineSeries, and the current date. This would draw one vertical column at the current date. You will need to do some serious formatting to get the column width where you want it, suppress the data tip, make sure no label appears, etc. And since you wouldn't want this column series in the legend, you will probably need to create a legend from scratch so it won't be included.

             

            Another other option may be to use the graphics class to draw the line. Of course you will have to determine where the current date's data point is on the screen to do this. Perhaps you can grab the current date's LineRenderer and find the x/y coordinates to do this.

             

            Good luck!