Class UIChartEvent

All Implemented Interfaces:
IMessageBox

public class UIChartEvent extends UIBaseEvent<UIChart>
The UI Chart Event is fired for a chart component when the user clicks or taps a data element of the chart - a marker, a column, a bar, a pie slice, a bubble - and, when the chart asks for it, when the mouse pointer rests on one or leaves it. The chart sends the events it asks for only: ChartOption.CLICK_EVENTS and ChartOption.HOVER_EVENTS, both off by default.

The event names the plot, the series and the index of the value in the series as the client drew them, the value's x and y as the client drew them, and the value property itself when it is still in the series: a live series may have dropped it by the time the event arrives, so getSeriesValue() may be null while the index and numbers stay what the user saw. For a pie, the index is the slice, x is the index and y the slice's value.

The event is fired on the client session's worker, the method tagged with OnUIChart after the listeners of the chart.

Author:
Christopher Mindus
  • Constructor Details

    • UIChartEvent

      public UIChartEvent(UIChart source, UIChartEvent.Type type, Plot2D plot, Series series, SeriesValue value, int index, double x, double y, String element)
      Constructs the event.
      Parameters:
      source - The source.
      type - The type.
      plot - The plot.
      series - The series.
      value - The value property, or null if no longer in the series.
      index - The index of the value in the series as the client drew it.
      x - The x of the value as drawn, NaN if none.
      y - The y of the value as drawn, NaN if none.
      element - The kind of element: "marker", "column", "bar", "slice", "circle", "candlestick"...
      Throws:
      NullPointerException - If the source is null.
  • Method Details

    • getSource

      public UIChart getSource()
      Gets the UI component that is the source of the event.
      Overrides:
      getSource in class BaseEvent<UIChart>
      Returns:
      The chart.
    • getType

      public UIChartEvent.Type getType()
      Gets the type of the event.
      Returns:
      The type.
    • getPlot

      public Plot2D getPlot()
      Gets the plot of the element.
      Returns:
      The plot.
    • getSeries

      public Series getSeries()
      Gets the series of the element.
      Returns:
      The series.
    • getSeriesValue

      public SeriesValue getSeriesValue()
      Gets the value property of the element.
      Returns:
      The value property, or null if the series no longer holds it (a live series that dropped it, a value removed meanwhile).
    • getIndex

      public int getIndex()
      Gets the index of the value in the series as the client drew it; for a pie, the slice.

      The index, like getX() and getY(), is what the client reports: the server checks that it is not negative, not that the series still holds a value there (a live series may have dropped values since). Code that reads the series with it checks it against the series first, or uses getSeriesValue(), which the server looks up itself.

      Returns:
      The index, zero-based.
    • getX

      public double getX()
      Gets the x of the value as the client drew it: the x of an X/Y value, the position (one-based) of a simple value, the index for a pie.
      Returns:
      The x, or NaN if none.
    • getY

      public double getY()
      Gets the y of the value as the client drew it: the value of a simple value or of a slice, the y of an X/Y value.
      Returns:
      The y, or NaN if none.
    • getElement

      public String getElement()
      Gets the kind of element as dojox names it: "marker", "column", "bar", "slice", "circle" (bubble), "candlestick", "spider_poly"...
      Returns:
      The kind, never null.
    • paramString

      protected String paramString()
      Gets the parameter string.
      Overrides:
      paramString in class BaseEvent<UIChart>