MYOB Exo Clarity

Hide NavigationShow Navigation

  • Contents
  • Index
  • Search
 
Display results with all search words

 

Chart Events

The following events may be useful when programming reports that include a chart. To enter code for a chart event, go to the Calc tab, ensure that the tree view is in Events mode and select the chart component from the tree. All available events for the chart appear on the right:

The OnClick, OnClickSeries, OnMouseMove and OnPrint events are specific to charts - these are discussed below.

OnClick Event

The OnClick event is useful if you just want to perform some action if a click is made anywhere on the chart component. This is particularly useful for line charts - you can add OnClickSeries events for a line chart, but it can be difficult for someone to move the mouse in the right place to actually click on the line. In this case, clicking anywhere on the chart may suffice (not if you want a particular data point though).

This event is used in the "Top" dashboards, e.g. DashTopCustByMargin.CLR, where if you are drilled into an item clicking on the line chart of the history will "drill" back up to the original view. It doesn't matter where on the line chart you click, the same event is fired.

Here is the procedure definition for an OnClick event handler:

procedure TeeChart1OnClick(ppCustomTeeChart: TppCustomTeeChart); begin
end;

Notice that a parameter is passed to the event handler which references the chart that was clicked. At this stage there is not much you can do with that parameter, but more functionality may be added in the future.

OnClickSeries Event

The OnClickSeries event is used whenever you want to perform a specific action when someone clicks on a data series element. Examples of data series elements are series lines in a line chart, bars in a bar chart, pie segments in a pie chart, and so on.

When an OnClickSeries event is fired, the event handler is passed a reference to the element which was clicked on. Here is the procedure definition for the event handler:

procedure TeeChart1OnClickSeries(SeriesIndex: Integer; ValueIndex: Integer; Button: TMouseButton; X: Integer; Y: Integer);
begin
end;

Here we are passed some more useful data:

The SeriesIndex value is the index of the series that was clicked (remember you can have multiple series in your chart). The first series is 0, the second is 1, and so on.

The ValueIndex value is the index of the value in the series that was clicked. While this may not mean much if you don't know what data is in your data source, there are some ways that this can be useful. In many of the standard dashboards, a description is stored in a list that is later referenced using this value.

The Button value is a reference to which mouse button was clicked. It is outside the scope of this document. For the purposes of this explanation, all mouse clicks will fire the event (left, middle and right).

The X and Y values give the coordinates where the click was made. This will likely be of little value.

OnMouseMove Event

The OnMouseMove event is used to trigger changes in the cursor. All the bar charts that use OnClickSeries events also use an OnMouseMove event to make the pointer change to a link pointer when one of the bars is hovered over. There are not many other uses for this event at this time. Here is the code snippet:

procedure DPTeeChart1OnMouseMove(X: Integer; Y: Integer);
var
 ClickedPart:TExoClickedPart;

begin
 ClickedPart:=DPTeeChart1.CalcClickedPart(X, Y);
 if ClickedPart.Part=cpSeries then
   DPTeeChart1.Cursor := -21
 else
 DPTeeChart1.Cursor := 0;
end;

Notice the use of the function DPTeeChart1.CalcClickedPart(X, Y) to return a value which indicates which part of the chart was "clicked" (a "mouse move" event is internally handled much like a click event – hundreds of little events fire every time you move your mouse). The cursor is then changed to -21 if it is part of the Series (i.e. a bar , pie slice, etc.). The value -21 represents the link pointer. The value 0 represents the regular arrow mouse pointer.