Class JmixChart

java.lang.Object
com.vaadin.flow.component.Component
io.jmix.chartsflowui.kit.component.JmixChart
All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasStyle, Serializable
Direct Known Subclasses:
Chart

@Tag("jmix-chart") @NpmPackage(value="echarts", version="5.4.3") @JsModule("./src/chart/jmix-chart.js") public class JmixChart extends com.vaadin.flow.component.Component implements com.vaadin.flow.component.HasSize
See Also:
  • Field Details

    • PROPERTY_RENDERER

      protected static final String PROPERTY_RENDERER
      See Also:
    • PROPERTY_RENDERER_CHANGED_EVENT

      protected static final String PROPERTY_RENDERER_CHANGED_EVENT
      See Also:
    • options

      protected ChartOptions options
    • serializer

      protected JmixChartSerializer serializer
    • synchronizeChartOptionsExecution

      protected com.vaadin.flow.internal.StateTree.ExecutionRegistration synchronizeChartOptionsExecution
    • synchronizeChartDataExecution

      protected com.vaadin.flow.internal.StateTree.ExecutionRegistration synchronizeChartDataExecution
    • synchronizeChartIncrementalUpdateDataExecution

      protected com.vaadin.flow.internal.StateTree.ExecutionRegistration synchronizeChartIncrementalUpdateDataExecution
    • clientReady

      protected volatile boolean clientReady
    • functions

      protected final List<JmixChart.PendingJsFunction> functions
    • eventRegistrations

      protected Map<String,com.vaadin.flow.shared.Registration> eventRegistrations
    • changedItems

      protected Map<DataSet,ChartIncrementalChanges<? extends DataItem>> changedItems
    • dataItemKeys

      protected com.vaadin.flow.data.provider.KeyMapper<Object> dataItemKeys
  • Constructor Details

    • JmixChart

      public JmixChart()
  • Method Details

    • initComponent

      protected void initComponent()
    • setNativeJson

      public void setNativeJson(String json)
      Sets additional JSON options as a string. This JSON can override options loaded from XML or from component Java API if they overlap.
      Example of using nativeJson:
      
        <charts:chart height="100%" width="100%">
           <charts:title text="Title"/>
           <charts:nativeJson>
               <![CDATA[
                       {
                        "title": {
                           "subtext": 'Subtitle'
                        }
                       }
                ]]>
           </charts:nativeJson>
       </charts:chart>
       
      Parameters:
      json - additional JSON options
    • getNativeJson

      @Nullable public elemental.json.JsonValue getNativeJson()
      Returns:
      additional JSON options as a JsonValue
    • addSeries

      public void addSeries(AbstractSeries<?> series)
      Adds a series to the chart options.
      Parameters:
      series - series to add
      See Also:
    • removeSeries

      public void removeSeries(AbstractSeries<?> series)
      Removes an existing series from the chart options.
      Parameters:
      series - series to remove
    • getSeries

      @Nullable public List<AbstractSeries<?>> getSeries()
      Returns:
      immutable list of added series
    • getSeriesOrNull

      @Nullable public <S extends AbstractSeries<S>> S getSeriesOrNull(String seriesId)
      Type Parameters:
      S - series class
      Parameters:
      seriesId - ID of the series to find
      Returns:
      the series with the provided ID if it exists, null otherwise
    • getSeries

      public <S extends AbstractSeries<S>> S getSeries(String seriesId)
      Type Parameters:
      S - series class
      Parameters:
      seriesId - ID of the series to find
      Returns:
      the series with the provided ID
      Throws:
      IllegalArgumentException - when chart doesn't contain a series with the provided ID
    • addXAxis

      public void addXAxis(XAxis axis)
      Adds a XAxis in cartesian(rectangular) coordinate to the chart options.
      Parameters:
      axis - axis to add
    • removeAxis

      public void removeAxis(XAxis axis)
      Removes an existing XAxis from the chart options.
      Parameters:
      axis - axis to remove
    • getXAxes

      @Nullable public List<XAxis> getXAxes()
      Returns:
      immutable list of added XAxes
    • addYAxis

      public void addYAxis(YAxis axis)
      Adds a YAxis in cartesian(rectangular) coordinate to the chart options.
      Parameters:
      axis - axis to add
    • removeYAxis

      public void removeYAxis(YAxis axis)
      Removes an existing YAxis from the chart options.
      Parameters:
      axis - axis to remove
    • getYAxes

      @Nullable public List<YAxis> getYAxes()
      Returns:
      immutable list of added YAxes
    • setRadiusAxis

      public void setRadiusAxis(RadiusAxis axis)
      Sets a RadiusAxis of polar coordinate to the chart options or replaces existing one.
      Parameters:
      axis - axis to set
    • getRadiusAxis

      @Nullable public RadiusAxis getRadiusAxis()
      Returns:
      current RadiusAxis
    • setAngleAxis

      public void setAngleAxis(AngleAxis axis)
      Sets a AngleAxis of polar coordinate to the chart options or replaces existing one.
      Parameters:
      axis - axis to set
    • getAngleAxis

      @Nullable public AngleAxis getAngleAxis()
      Returns:
      current AngleAxis
    • addGrid

      public void addGrid(Grid grid)
      Adds a Grid to the chart options. Grid options is used to draw a grid in rectangular coordinate. In a single grid, at most two X and Y axes each is allowed. LineSeries, BarSeries, and ScatterSeries(EffectScatterSeries) can be drawn in the grid.
      Parameters:
      grid - grid to add
    • removeGrid

      public void removeGrid(Grid gird)
      Removes an existing Grid from the chart options.
      Parameters:
      gird - grid to remove
    • getGrids

      @Nullable public Collection<Grid> getGrids()
      Returns:
      immutable list of added grids
    • getDataZoom

      @Nullable public Collection<AbstractDataZoom<?>> getDataZoom()
      Returns:
      immutable list of added data zooms
    • addDataZoom

      public void addDataZoom(AbstractDataZoom<?> dataZoom)
      Adds a AbstractDataZoom component witch used for zooming a specific area in the chart.
      Parameters:
      dataZoom - data zoom to add
      See Also:
    • removeDataZoom

      public void removeDataZoom(AbstractDataZoom<?> dataZoom)
      Removes an existing AbstractDataZoom from the chart options.
      Parameters:
      dataZoom - data zoom to remove
    • getTitle

      @Nullable public Title getTitle()
      Returns:
      title component of the chart
    • setTitle

      public void setTitle(Title title)
      Sets a Title to the chart options or replaces existing one.
      Parameters:
      title - title to add
    • getLegend

      @Nullable public AbstractLegend<?> getLegend()
      Returns:
      legend component of the chart
    • setLegend

      public void setLegend(AbstractLegend<?> legend)
      Sets a AbstractLegend to the chart options or replaces existing one. Legend component shows symbol, color and name of different series. You can click legends to toggle displaying series in the chart.
      Parameters:
      legend - legend to add
      See Also:
    • getTooltip

      @Nullable public Tooltip getTooltip()
      Returns:
      global tooltip component of the chart
    • setTooltip

      public void setTooltip(Tooltip tooltip)
      Sets a global Tooltip options of the chart or replaces existing one. Tooltip can be configured on different places.
      Parameters:
      tooltip - global tooltip to set
      See Also:
    • getToolbox

      @Nullable public Toolbox getToolbox()
      Returns:
      toolbox of the chart
    • setToolbox

      public void setToolbox(Toolbox toolbox)
      Sets a Toolbox to the chart options or replaces existing one. Toolbox is a group of utility tools, which includes different features.
      Parameters:
      toolbox - toolbox to set
    • getAxisPointer

      @Nullable public AxisPointer getAxisPointer()
      Returns:
      global axis pointer of the chart
    • setAxisPointer

      public void setAxisPointer(AxisPointer axisPointer)
      Sets a AxisPointer to the chart options or replaces existing one. AxisPointer is a tool for displaying reference line and axis value under mouse pointer.
      Parameters:
      axisPointer - axis pointer to add
    • getPolar

      @Nullable public Polar getPolar()
      Returns:
      polar options of the chart
    • setPolar

      public void setPolar(Polar polar)
      Sets a Polar to the chart options or replaces existing one. Polar coordinate can be used in ScatterSeries and LineSeries. Every polar coordinate has an AngleAxis and a RadiusAxis.
      Parameters:
      polar - radar to add
    • getRadar

      @Nullable public Radar getRadar()
      Returns:
      radar options of the chart
    • setRadar

      public void setRadar(Radar radar)
      Sets a Radar to the chart options or replaces existing one. Radar chart coordinate is different from polar coordinate, in that every axis indicator of the radar chart coordinate is an individual dimension. Radar.Indicator are required to be displayed.
      Parameters:
      radar - radar to set
    • getDataSet

      @Nullable public DataSet getDataSet()
      Returns:
      data set of the chart
    • setDataSet

      public void setDataSet(DataSet dataSet)
      Sets a DataSet to the chart options or replaces existing one. Data set is the main data provider for the chart. All series added to the chart will use the data set. The only series that requires its own data set is the GaugeSeries.
      Parameters:
      dataSet - data set to set
    • getAria

      @Nullable public Aria getAria()
      Returns:
      aria of the chart
    • setAria

      public void setAria(Aria aria)
      Sets a Aria to the chart options or replaces existing one. Aria is options for the Accessible Rich Internet Applications Suite, which is dedicated to making web content and web applications accessible.
      Parameters:
      aria - aria to set
    • getBrush

      @Nullable public Brush getBrush()
      Returns:
      brush of the chart
    • setBrush

      public void setBrush(Brush brush)
      Sets a Brush to the chart options or replaces existing one. Brush is an area-selecting component, with which user can select part of data from a chart to display in detail.
      Parameters:
      brush - brush to set
    • getVisualMap

      @Nullable public List<AbstractVisualMap<?>> getVisualMap()
      Returns:
      immutable list of added visual maps
    • addVisualMap

      public void addVisualMap(AbstractVisualMap<?> visualMap)
      Adds a AbstractVisualMap to the chart options. Visual map is a type of component for visual encoding, which maps the data to visual channels.
      Parameters:
      visualMap - visual map to add
      See Also:
    • removeVisualMap

      public void removeVisualMap(AbstractVisualMap<?> visualMap)
      Removes an existing AbstractVisualMap from the chart options.
      Parameters:
      visualMap - visual map to remove
    • getColorPalette

      @Nullable public List<Color> getColorPalette()
      Returns:
      immutable list of colors in the charts color palette
    • setColorPalette

      public void setColorPalette(Color... palette)
      Sets a color list of palette for the chart.
      Parameters:
      palette - colors to set
    • addColorToPalette

      public void addColorToPalette(Color color)
      Adds a single color to the chart color palette.
      Parameters:
      color - color to add
    • clearColorPalette

      public void clearColorPalette()
      Clears the chart color palette of all colors.
    • getBackgroundColor

      @Nullable public Color getBackgroundColor()
      Returns:
      background color of the chart
    • setBackgroundColor

      public void setBackgroundColor(Color backgroundColor)
      Sets a background color for the chart or replaces existing one. No background color by default.
      Parameters:
      backgroundColor - color to set
    • getTextStyle

      @Nullable public TextStyle getTextStyle()
      Returns:
      global font style of the chart
    • setTextStyle

      public void setTextStyle(TextStyle textStyle)
      Sets a global TextStyle for the chart or replaces existing one. Text style can be configured on different places.
      Parameters:
      textStyle - global text style to set
    • getAnimation

      @Nullable public Boolean getAnimation()
      Returns:
      true if animation if enabled, false otherwise
    • setAnimation

      public void setAnimation(Boolean animation)
      Sets the animation of the chart. The animation is enabled by default.
      Parameters:
      animation - whether to enable the animation
    • getAnimationThreshold

      @Nullable public Integer getAnimationThreshold()
      Returns:
      graphic number threshold to animation
    • setAnimationThreshold

      public void setAnimationThreshold(Integer animationThreshold)
      Sets a graphic number threshold to animation. Animation will be disabled when graphic number is larger than threshold.
      Parameters:
      animationThreshold - number threshold to animation
    • getAnimationDuration

      @Nullable public Integer getAnimationDuration()
      Returns:
      duration of the first draw animation in milliseconds
    • setAnimationDuration

      public void setAnimationDuration(Integer animationDuration)
      Sets a duration of the first draw animation.
      Parameters:
      animationDuration - animation duration to set in milliseconds
    • getAnimationEasing

      @Nullable public String getAnimationEasing()
      Returns:
      easing method used for the first draw animation
    • setAnimationEasing

      public void setAnimationEasing(String animationEasing)
      Sets an animation easing method used for the first draw animation.
      Parameters:
      animationEasing - easing method to use
      See Also:
    • getAnimationDelay

      @Nullable public Integer getAnimationDelay()
      Returns:
      delay before updating the first draw animation in milliseconds
    • setAnimationDelay

      public void setAnimationDelay(Integer animationDelay)
      Sets a delay before updating the first draw animation.
      Parameters:
      animationDelay - delay to set in milliseconds
    • getAnimationDurationUpdate

      @Nullable public Integer getAnimationDurationUpdate()
      Returns:
      time for animation to complete in milliseconds
    • setAnimationDurationUpdate

      public void setAnimationDurationUpdate(Integer animationDurationUpdate)
      Sets a time for animation to complete.
      Parameters:
      animationDurationUpdate - time to set in milliseconds
    • getAnimationEasingUpdate

      @Nullable public String getAnimationEasingUpdate()
      Returns:
      easing method used for update animation
    • setAnimationEasingUpdate

      public void setAnimationEasingUpdate(String animationEasingUpdate)
      Sets an animation easing method used for update animation.
      Parameters:
      animationEasingUpdate - easing method to use
      See Also:
    • getAnimationDelayUpdate

      @Nullable public Integer getAnimationDelayUpdate()
      Returns:
      delay before updating animation in milliseconds
    • setAnimationDelayUpdate

      public void setAnimationDelayUpdate(Integer animationDelayUpdate)
      Sets a delay before updating animation.
      Parameters:
      animationDelayUpdate - delay to set in milliseconds
    • getStateAnimation

      @Nullable public ChartOptions.StateAnimation getStateAnimation()
      Returns:
      state switching animation configurations
    • setStateAnimation

      public void setStateAnimation(ChartOptions.StateAnimation stateAnimation)
      Sets a ChartOptions.StateAnimation for the chart.
      Parameters:
      stateAnimation - configuration to set
    • getBlendMode

      @Nullable public ChartOptions.BlendMode getBlendMode()
      Returns:
      the type of compositing operation to apply when drawing a new shape
    • setBlendMode

      public void setBlendMode(ChartOptions.BlendMode blendMode)
      Sets the type of compositing operation to apply when drawing a new shape. Blend mode is source-over by default.
      Parameters:
      blendMode - blend mode to set
      See Also:
    • getHoverLayerThreshold

      @Nullable public Integer getHoverLayerThreshold()
      Returns:
      the number of elements when exceeded, a separate hover layer is used to render hovered elements
    • setHoverLayerThreshold

      public void setHoverLayerThreshold(Integer hoverLayerThreshold)
      Sets the number of elements when exceeded, a separate hover layer is used to render hovered elements.
      Parameters:
      hoverLayerThreshold - number of elements to set
    • getUseUtc

      @Nullable public Boolean getUseUtc()
      Returns:
      true if UTC is used in display, false otherwise
    • setUseUtc

      public void setUseUtc(Boolean useUtc)
      Sets the use of UTC in display.
      • true: when axis.type is 'time', ticks is determined according to UTC, and axisLabel and tooltip use UTC by default.
      • false: when axis.type is 'time', ticks is determined according to local time, and axisLabel and tooltip use local time by default.
      Parameters:
      useUtc - whether to use UTC in display
    • getRenderer

      @Synchronize(property="renderer", value="renderer-changed") public ChartRenderer getRenderer()
      Returns:
      the current chart component renderer type
    • setRenderer

      public void setRenderer(ChartRenderer renderer)
      Sets the renderer type of the chart. The renderer type is ChartRenderer.CANVAS by default.
      Parameters:
      renderer - renderer type to be applied
      See Also:
    • initChartOptionsChangeListener

      protected void initChartOptionsChangeListener()
    • onChartOptionsChange

      protected void onChartOptionsChange(ChartObservableObject.ObjectChangeEvent event)
    • requestUpdateChartOptions

      protected void requestUpdateChartOptions()
    • requestUpdateChartDataSet

      protected void requestUpdateChartDataSet()
    • requestIncrementalUpdateChartDataSet

      protected <T extends DataItem> void requestIncrementalUpdateChartDataSet(ChartItems.ItemSetChangeEvent<T> event)
    • performUpdateChartOptions

      protected void performUpdateChartOptions(com.vaadin.flow.internal.ExecutionContext context)
    • performUpdateChartData

      protected void performUpdateChartData(com.vaadin.flow.internal.ExecutionContext context)
    • performIncrementalUpdateChartDataSet

      protected void performIncrementalUpdateChartDataSet(com.vaadin.flow.internal.ExecutionContext context)
    • onAttach

      protected void onAttach(com.vaadin.flow.component.AttachEvent attachEvent)
      Overrides:
      onAttach in class com.vaadin.flow.component.Component
    • ready

      @ClientCallable protected void ready()
    • onDetach

      protected void onDetach(com.vaadin.flow.component.DetachEvent detachEvent)
      Overrides:
      onDetach in class com.vaadin.flow.component.Component
    • callPendingJsFunction

      protected void callPendingJsFunction(String function, elemental.json.JsonObject resultJson)
      Execute JavaScript function with the resultJson passed. Execution will be delayed till the client-side is ready.
      Parameters:
      function - JavaScript function to execute
      resultJson - resultJson
    • callJsFunction

      protected void callJsFunction(String function, elemental.json.JsonObject resultJson)
    • addChangedDataItems

      protected <T extends DataItem> void addChangedDataItems(ChartItems.DataChangeOperation operation, Collection<T> items)
    • addClickEventListener

      public com.vaadin.flow.shared.Registration addClickEventListener(com.vaadin.flow.component.ComponentEventListener<ChartClickEvent> listener)
    • addDoubleClickEventListener

      public com.vaadin.flow.shared.Registration addDoubleClickEventListener(com.vaadin.flow.component.ComponentEventListener<ChartDoubleClickEvent> listener)
    • addMouseDownEventListener

      public com.vaadin.flow.shared.Registration addMouseDownEventListener(com.vaadin.flow.component.ComponentEventListener<ChartMouseDownEvent> listener)
    • addMouseMoveEventListener

      public com.vaadin.flow.shared.Registration addMouseMoveEventListener(com.vaadin.flow.component.ComponentEventListener<ChartMouseMoveEvent> listener)
    • addMouseOutEventListener

      public com.vaadin.flow.shared.Registration addMouseOutEventListener(com.vaadin.flow.component.ComponentEventListener<ChartMouseOutEvent> listener)
    • addMouseOverEventListener

      public com.vaadin.flow.shared.Registration addMouseOverEventListener(com.vaadin.flow.component.ComponentEventListener<ChartMouseOverEvent> listener)
    • addMouseUpEventListener

      public com.vaadin.flow.shared.Registration addMouseUpEventListener(com.vaadin.flow.component.ComponentEventListener<ChartMouseUpEvent> listener)
    • addGlobalOutEventListener

      public com.vaadin.flow.shared.Registration addGlobalOutEventListener(com.vaadin.flow.component.ComponentEventListener<ChartGlobalOutEvent> listener)
    • addLegendSelectChangedEventListener

      public com.vaadin.flow.shared.Registration addLegendSelectChangedEventListener(com.vaadin.flow.component.ComponentEventListener<ChartLegendSelectChangedEvent> listener)
    • addLegendSelectAllEventListener

      public com.vaadin.flow.shared.Registration addLegendSelectAllEventListener(com.vaadin.flow.component.ComponentEventListener<ChartLegendSelectAllEvent> listener)
    • addLegendInverseSelectEventListener

      public com.vaadin.flow.shared.Registration addLegendInverseSelectEventListener(com.vaadin.flow.component.ComponentEventListener<ChartLegendInverseSelectEvent> listener)
    • addLegendScrollEventListener

      public com.vaadin.flow.shared.Registration addLegendScrollEventListener(com.vaadin.flow.component.ComponentEventListener<ChartLegendScrollEvent> listener)
    • addDataZoomEventListener

      public com.vaadin.flow.shared.Registration addDataZoomEventListener(com.vaadin.flow.component.ComponentEventListener<ChartDataZoomEvent> listener)
    • addRestoreEventListener

      public com.vaadin.flow.shared.Registration addRestoreEventListener(com.vaadin.flow.component.ComponentEventListener<ChartRestoreEvent> listener)
    • addMagicTypeChangedEventListener

      public com.vaadin.flow.shared.Registration addMagicTypeChangedEventListener(com.vaadin.flow.component.ComponentEventListener<ChartMagicTypeChangedEvent> listener)
    • addGlobalCursorTakenEventListener

      public com.vaadin.flow.shared.Registration addGlobalCursorTakenEventListener(com.vaadin.flow.component.ComponentEventListener<ChartGlobalCursorTakenEvent> listener)
    • addRenderedEventListener

      public com.vaadin.flow.shared.Registration addRenderedEventListener(com.vaadin.flow.component.ComponentEventListener<ChartRenderedEvent> listener)
    • addFinishedEventListener

      public com.vaadin.flow.shared.Registration addFinishedEventListener(com.vaadin.flow.component.ComponentEventListener<ChartFinishedEvent> listener)
    • getRemovalCallback

      protected com.vaadin.flow.shared.Registration getRemovalCallback(String eventName, Class<? extends com.vaadin.flow.component.ComponentEvent<?>> eventClass)
    • createChartOptions

      protected ChartOptions createChartOptions()
    • createSerializer

      protected JmixChartSerializer createSerializer()