4 Replies Latest reply on Oct 12, 2015 3:42 PM by dpark1113

    FB3 handle click on column chart

    martinjconnolly Level 1

      Hi all,

      if I click on one column in a column chart, the event.hitData.item property shows me everything that makes up the total column - i.e the data for every segment. Is there any way of determining which individual segment of the column has been clicked on?

      Thanks

        • 1. Re: FB3 handle click on column chart
          Tejas S Patel Level 1

          Chart Control: ( this is just simple example. Bold face text is important)

           

          <mx:ColumnChart id="CChart" itemClick="columnchartClicked(event)" showDataTips="true" dataProvider="{arrData}">
          <mx:verticalAxis>
               <mx:LinearAxis interval="1" />
          </mx:verticalAxis>
          <mx:horizontalAxis>
               <mx:CategoryAxis id="xname" categoryField="name" title="NAME" />
          </mx:horizontalAxis>
          <mx:horizontalAxisRenderers>
               <mx:AxisRenderer axis="{xname}" tickLength="5.0" tickPlacement="outside" labelRotation="90.0"/>
          </mx:horizontalAxisRenderers>
          <mx:series>
               <mx:ColumnSeries  xField="name" yField="count" displayName=""  />
          </mx:series>
          </mx:ColumnChart>

           

           

          Chart Clicked Event Handler:

          import mx.charts.HitData;
          import mx.charts.events.ChartItemEvent;

          public function columnchartClicked(event:ChartItemEvent) : void
          {

               var str : String = toString(event.hitData.item.name);

          }

          • 2. Re: FB3 handle click on column chart
            martinjconnolly Level 1

            My chart has 4 ColumnSeries:

             

            <mx:ColumnSeries  displayName="Booked" xField="fcdate" yField="Booked" />
            <mx:ColumnSeries  displayName="Solid" xField="fcdate" yField="FC" />
            <mx:ColumnSeries  displayName="At risk" xField="fcdate" yField="FCR" />
            <mx:ColumnSeries  displayName="Stretch" xField="fcdate" yField="Upside"/>-

            what I need to know is the variable used in the yField that has been clicked on. I think your example just shows me the xField, doesn't it? Which is what I have been able to get so far.

             

            Thanks

            • 3. Re: FB3 handle click on column chart
              martinjconnolly Level 1

              I gave up on this... as far as I can see nothing indicates which segment of a stacked column has been clicked - you get the same hitData.item no matter which bit you click on.

              • 4. Re: FB3 handle click on column chart
                dpark1113 Level 1

                I know this post is 5 years ago and I had the same issue.  I finally figured out the workaround.

                 

                To findout which series was clicked in stacked column:

                 

                <mx:ColumnSeries  displayName="Booked" xField="fcdate" yField="Booked" name='Booked' />


                Using e.hitData.element.name will give you 'Booked' if that was clicked.  Or if you want to use displayName then


                import mx.charts.chartClasses.Series;

                Series(e.hitData.element).displayName.


                Hope this helps.