Class DefaultDataConverter

java.lang.Object
com.vaadin.flow.component.ai.chart.DefaultDataConverter
All Implemented Interfaces:
DataConverter, Serializable

public class DefaultDataConverter extends Object implements DataConverter
Default implementation of DataConverter that handles common data conversion patterns for various chart types.

This converter uses column-name-based pattern matching to determine the appropriate series type and data structure. All expected column names are defined in ColumnNames and prefixed with "_" to avoid collisions with real data columns. Patterns are checked in priority order from most-specific to least-specific:

  1. OHLC/Candlestick (_open, _high, _low, _close)
  2. BoxPlot (_low, _q1, _median, _q3, _high)
  3. Organization (_id, _name, _parent, _title; optionally _description, _image, _color)
  4. Gantt (_name, _start, _end; optionally _id, _parent, _dependency, _completed, _color)
  5. Treemap (_id, _parent, _value)
  6. Sankey (_from, _to, _weight)
  7. Heatmap (_x, _y, _value)
  8. XRange (_x, _x2, _y)
  9. Timeline (_name, _label, _description)
  10. Bubble (_x, _y, _z)
  11. Flags (_title, optionally _text; requires absence of _parent to avoid matching Organization/Treemap data)
  12. Range (_low, _high)
  13. Bullet (_y, _target)
  14. Waterfall (_y, _waterfall_type; type values are "sum" and "intermediate", case-insensitive; null or absent for regular data points)
  15. Fallback: first non-numeric column as category, first numeric column as value

Additionally, any pattern that produces a DataSeriesItem (or subclass) supports an optional _color column. If present, the value is used to set the item's color via SolidColor(String).

Column name matching is case-insensitive. Column names are determined from the first row; subsequent rows with missing keys will yield null for those columns.

If the data contains a _series column, rows are automatically grouped by that column's value and each group is converted into a separate named series. The _series column is removed before pattern matching so it does not interfere with chart type detection.

Author:
Vaadin Ltd
See Also:
  • Constructor Details

    • DefaultDataConverter

      public DefaultDataConverter()
  • Method Details

    • convertToSeries

      public List<Series> convertToSeries(List<Map<String,Object>> data)
      Description copied from interface: DataConverter
      Converts tabular data into one or more chart series.

      Each element in the input list represents a single row, with column names as keys and column values as values.

      Specified by:
      convertToSeries in interface DataConverter
      Parameters:
      data - the tabular data to convert, not null
      Returns:
      a list of series ready for use in a chart, never null and never empty