[]
        
(Showing Draft Content)

Hit-Testing in FlexChart

You can use the hitTest method to determine what chart area is under the mouse. Call the hitTest method within a mouse event such as mousemove, mouseover, or mouseup.

 myChart.hostElement.addEventListener('mousemove', function (e) {
     // get hittest object
     var ht = myChart.hitTest(e);
     // get chart element
     var elem = ht.chartElement;
     // get series
     var series = ht.series;
     // get point index
     var index = (ht.pointIndex != null && series) ? ht.pointIndex : null;
     });

The hitTest method takes the point as a parameter. The chart elements you can obtain from the hit test are:

  • PlotArea: The area within the axes.
  • ChartArea: The area within the control but outside the axes.
  • Legend: The chart legend, usually on the right of the plot area.
  • Header: The chart header, above the plot area.
  • Footer: The chart footer, below the plot area.
  • AxisX: The X-axis, usually horizontal.
  • AxisY: The Y-axis, usually vertical.
  • Series: A collection of Series objects that can be used to customize the chart. The FlexChart populates the series collections automatically based on the chart's itemsSource.
  • SeriesSymbol: A symbol in a chart series.
  • DataLabel: A label attached to a data point.