Back to Devexpress

TdxCustomChartControl.OnHotTrackElement Event

vcl-dxchartcontrol-dot-tdxcustomchartcontrol-4bda3006.md

latest4.4 KB
Original Source

TdxCustomChartControl.OnHotTrackElement Event

Allows you to respond to mouse pointer movement between visual elements within the Chart control client area.

Declaration

delphi
property OnHotTrackElement: TdxChartHotTrackElementEvent read; write;

Remarks

You can handle the OnHotTrackElement event to respond to mouse pointer movement between chart elements. For example, you can change the appearance of certain hot-track elements to complement hints and tooltips in the Chart control.

Event Occurrence

The OnHotTrackElement event occurs every time the mouse pointer crosses borders of visual Chart elements.

Event Parameters

The Sender parameter provides access to the Chart control that raised the OnHotTrackElement event. You can use AArgs.Element and AArgs.PreviousElement parameters to identify and access both current and previous hot-tracked elements.

Refer to the TdxChartHotTrackElementEvent procedural type description for detailed information on parameters accessible within an OnHotTrackElement event handler.

Code Example: Change Hot-Tracked Series Appearance

The following code example demonstrates an OnHotTrackElement event handler that applies a white diagonal crosshatch to the currently hot-tracked bar series:

delphi
procedure TMyForm.dxChartControl1HotTrackElement(Sender: TObject;
  const AArgs: TdxChartHotTrackElementEventArgs);
var
  ABarView: TdxChartXYSeriesBarView;
begin
  if ((AArgs.HitTest.Diagram = cdVisitors) and (AArgs.HitTest.HitCode = TdxChartHitCode.SeriesPoint)) then
  begin
    // Displays a white crosshatch on all bars of the hot-tracked series
    ABarView := AArgs.HitTest.SeriesPoint.Series.View as TdxChartXYSeriesBarView;
    ABarView.Appearance.FillOptions.Mode := TdxFillOptionsMode.Hatch;
    ABarView.Appearance.FillOptions.HatchStyle := TdxFillOptionsHatchStyle.DiagonalCross;
    ABarView.Appearance.FillOptions.Color2 := TdxAlphaColors.White;
  end;
  if ((AArgs.PreviousHitTest.Diagram = cdVisitors) and
      (AArgs.PreviousHitTest.HitCode = TdxChartHitCode.SeriesPoint)) then
  begin
    // Removes a white crosshatch from all bars of the previously hot-tracked series
    ABarView := AArgs.PreviousHitTest.SeriesPoint.Series.View as TdxChartXYSeriesBarView;
    ABarView.Appearance.FillOptions.Mode := TdxFillOptionsMode.Solid;
  end;
end;
cpp
void __fastcall TMyForm::dxChartControl1HotTrackElement(TObject *Sender,
      const TdxChartHotTrackElementEventArgs *&AArgs)
{
  TdxChartXYSeriesBarView *ABarView;
  if((AArgs->HitTest->Diagram == cdVisitors) && (AArgs->HitTest->HitCode == TdxChartHitCode::SeriesPoint))
  {
    // Displays a white crosshatch on all bars of the hot-tracked series
    ABarView = dynamic_cast<TdxChartXYSeriesBarView*>(AArgs->HitTest->SeriesPoint->Series->View);
    ABarView->Appearance->FillOptions->Mode = TdxFillOptionsMode::Hatch;
    ABarView->Appearance->FillOptions->HatchStyle = TdxFillOptionsHatchStyle::DiagonalCross;
    ABarView->Appearance->FillOptions->Color2 = TdxAlphaColors::White;
  }
  if((AArgs->PreviousHitTest->Diagram == cdVisitors) &&
     (AArgs->PreviousHitTest->HitCode == TdxChartHitCode::SeriesPoint))
  {
    // Removes a white crosshatch from all bars of the previously hot-tracked series
    ABarView = dynamic_cast<TdxChartXYSeriesBarView*>(AArgs->PreviousHitTest->SeriesPoint->Series->View);
    ABarView->Appearance->FillOptions->Mode = TdxFillOptionsMode::Solid;
  }
}

See Also

TdxCustomChartControl.HitTest Property

TdxCustomChartControl.ToolTips Property

TdxCustomChartControl Class

TdxCustomChartControl Members

dxChartControl Unit