Adobe Flex 3 Help

Changing mouse sensitivity

You use the mouseSensitivity property of the chart control to determine when the mouse pointer is considered to be over a data point; for example:

<mx:ColumnChart id="chart" dataProvider="{dataSet}" mouseSensitivity="30">

The current data point is the nearest data point to the mouse pointer that is less than or equal to the number of pixels that the mouseSensitivity property specifies.

The default value of the mouseSensitivity property is 3 pixels. If the mouse pointer is 4 or more pixels away from a data point, Flex does not trigger a ChartItemEvent (of types such as itemRollOver or itemClick). Flex still responds to events such as mouseOver and click by generating a ChartEvent object of type chartClick or chartDoubleClick.

The following example initially sets the mouseSensitivity property to 20, but lets the user change this value with the HSlider control:

<?xml version="1.0"?>
<!-- charts/MouseSensitivity.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
  <mx:Script><![CDATA[
     import mx.collections.ArrayCollection;
     [Bindable]
     public var expenses:ArrayCollection = new ArrayCollection([
        {Month:"January", Profit:2000, Expenses:1500, Amount:450},
        {Month:"February", Profit:1000, Expenses:200, Amount:600},
        {Month:"March", Profit:1500, Expenses:500, Amount:300},
        {Month:"April", Profit:500, Expenses:300, Amount:500},
        {Month:"May", Profit:1000, Expenses:450, Amount:250},
        {Month:"June", Profit:2000, Expenses:500, Amount:700}
     ]);

  ]]></mx:Script>
  <mx:Panel title="Mouse Sensitivity">
     <mx:PlotChart id="myChart" 
        dataProvider="{expenses}" 
        showDataTips="true"
        mouseSensitivity="{mySlider.value}"
    >
        <mx:series>
           <mx:PlotSeries 
                xField="Expenses" 
                yField="Profit"
                displayName="P 1"
           />
           <mx:PlotSeries 
                xField="Amount" 
                yField="Expenses"
                displayName="P 2"
           />
           <mx:PlotSeries 
                xField="Profit" 
                yField="Amount" 
                displayName="P 3"
           />
        </mx:series>
     </mx:PlotChart>

     <mx:HBox>
         <mx:Legend dataProvider="{myChart}"/>
         <mx:VBox>
             <mx:Label text="Mouse Sensitivity:"/>
             <mx:HSlider id="mySlider"
                minimum="0"
                maximum="300"
                value="20"
                dataTipPlacement="top"
                tickColor="black"
                snapInterval="1"
                tickInterval="20"
                labels="['0','300']"
                allowTrackClick="true"
                liveDragging="true"
             />
        </mx:VBox>
      </mx:HBox>
  </mx:Panel>

</mx:Application>

The executing SWF file for the previous example is shown below:

You can use the mouseSensitivity property to increase the area that triggers DataTip events or emits chart-related events. If the mouse pointer is within the range of multiple data points, Flex chooses the closest data point. For DataTip events, if you have multiple DataTip controls enabled, Flex displays all DataTip controls within range. For more information, see Showing multiple DataTip objects.