import type { GaugeChartSubTypes, SizePolicyScaleTypes, WebChartCalendarDatePartsUnits, WebChartClassBreakTypes, WebChartDataTransformations, WebChartDirectionalDataOrder, WebChartHeatChartHeatRulesTypes, WebChartHeatChartViewTypes, WebChartLabelBehavior, WebChartLegendPositions, WebChartMultiAxesDataOrder, WebChartNullPolicyTypes, WebChartOrderSeriesBy, WebChartPredefinedLabelsDataOrder, WebChartRadarChartAxisLabelsOrientation, WebChartStackedKinds, WebChartTemporalBinningUnits, WebChartTimeAggregationTypes, WebChartTypes } from "./chart-object-literals.js";
import type { TimeIntervalInfo } from "./data-source.js";
import type { RESTUnits } from "./rest-js-object-literals.js";
import type { Color, IDrawingInfo, IEnvelope, IExtent, IFeatureLayer, IPoint, IPolygon, IPolygonWithCurves, IPolyline, ISimpleFillSymbol, ISimpleLineSymbol, ISimpleMarkerSymbol, IStatisticDefinition, ITextSymbol } from "./rest-js-types.js";

/** Version of the current specification. */
export const WebChartCurrentVersion: "25.0.0";

/** Stores information regarding a numeric conversion. */
export interface ValueConversion {
  /** A numeric value multiplying the value to convert. */
  factor?: number;
  /** A numeric offset to apply to the value to convert. */
  offset?: number;
}

/** Describes the properties of an axis scrollbar. */
export interface WebChartAxisScrollBar {
  /**
   * Scrollbar visibility.
   *
   * @default false
   */
  visible?: boolean;
  /** Scrollbar width in pixels. */
  width?: number;
  /** Scrollbar color. */
  color?: Color;
  /** Grip size in pixels. */
  gripSize?: number;
  /** Margin between the scrollbar and the series container in pixels. */
  margin?: number;
}

/** Represents a text symbol. */
export type WebChartTextSymbol = Omit<ITextSymbol, "angle" | "style" | "xoffset" | "yoffset">
  & {
  /**
   * Horizontal offset. Can be a number for a fixed value in pixels, or a string such as `25%` for a value
   * relative to the label's container width.
   */
  xoffset?: number | string;
  /**
   * Vertical offset. Can be a number for a fixed value in pixels, or a string such as `25%` for a value
   * relative to the label's container height.
   */
  yoffset?: number | string;
  /** Rotation angle of the label. */
  angle?: number;
  /** Label style. */
  style?: string;
};

/** Stores information on how some text is rendered on the chart and whether it is visible or not. */
export interface WebChartText {
  /** A unique string identifier for the `ChartText` object. This value is `chartText`. */
  type: typeof WebChartTypes.Text;
  /**
   * Determines the visibility of the content.
   *
   * @default true
   */
  visible?: boolean;
  /** Contains the styling information and text content. */
  content: WebChartTextSymbol;
}

/** JSON representation of the cursor's crosshair for a chart. */
export interface WebChartCursorCrosshair {
  /** Represents a unique string identifier for the chart cursor's crosshair. */
  type: typeof WebChartTypes.CursorCrosshair;
  /** Contains styling information on how the chart cursor's crosshair should be rendered. */
  style?: ISimpleLineSymbol;
  /**
   * Indicates whether the vertical crosshair line should be displayed.
   *
   * @default false
   */
  verticalLineVisible?: boolean;
  /**
   * Indicates whether the horizontal crosshair line should be displayed.
   *
   * @default false
   */
  horizontalLineVisible?: boolean;
}

/** JSON representation of the chart's legend. */
export interface WebChartLegend {
  /** A unique string identifier for the `ChartLegend` object. This value is `chartLegend`. */
  type: typeof WebChartTypes.Legend;
  /**
   * Determines the visibility of the content.
   *
   * @default true
   */
  visible?: boolean;
  /** Contains styling information on how the title of the legend box should be rendered. */
  title?: WebChartText;
  /**
   * Contains styling information on how legend body (excluding the `title`) should be rendered.
   * Will use default styling if not provided.
   */
  body?: WebChartTextSymbol;
  /**
   * Positions the legends at `"right"`, `"left"`, `"top"`, or `"bottom"` of the chart.
   *
   * @default `right`
   */
  position?: WebChartLegendPositions;
  /**
   * Legend's maximum height. If not set the legend will occupy the same height as the series container.
   *
   * @default null
   */
  maxHeight?: number | null;
  /**
   * Allows the legend markers to be displayed as circles.
   * - `false` or `undefined`: rounded rectangles
   * - `true`: circles
   *
   * @default false
   */
  roundMarkers?: boolean;
}

export interface WebChartNullCategory {
  /**
   * Specifies the text to use for the null category.
   * If none is provided, the default `null` text will be used.
   */
  text?: string;
  /**
   * Contains styling information on how the overlay should be rendered.
   * If not provided a default style is applied.
   *
   * @default 1 - symbol.outline.width
   */
  symbol?: ISimpleFillSymbol;
}

/** Specific legend for pie charts */
export interface WebChartPieChartLegend extends WebChartLegend {
  /**
   * Indicates whether the category associated to a slice is to be displayed in the legend.
   *
   * @default true
   */
  displayCategory?: boolean;
  /**
   * Indicates whether the numeric value associated to a slice is to be displayed in the legend.
   * If both `displayNumericValue` and `displayPercentage` are true on a same label, they will be displayed as `percentage (value)`
   *
   * @default false
   */
  displayNumericValue?: boolean;
  /**
   * Indicates whether the percentage to a slice is to be displayed in the legend.
   * If both `displayNumericValue` and `displayPercentage` are true on a same label, they will be displayed as `percentage (value)`
   *
   * @default false
   */
  displayPercentage?: boolean;
  /**
   * Maximum width in pixels of the label displaying the slice name. If the label is larger than the maximum width, it will automatically wrap.
   *
   * @default 200
   */
  labelMaxWidth?: number;
  /**
   * Maximum width in pixels of the value label displaying the slice value. If the label is larger than the maximum width, it will automatically wrap.
   *
   * @default 200
   */
  valueLabelMaxWidth?: number;
}

/** JSON representation of the chart's overlays such as the trendline in scatterplot, and the median overlay in histogram. */
export interface WebChartOverlay {
  /** A unique string identifier for the `ChartOverlay` object. This value is `chartOverlay`. */
  type: typeof WebChartTypes.Overlay;
  /**
   * Determines whether the overlay is created under the hood. It may or may not be visible.
   *
   * @default false
   */
  created?: boolean;
  /**
   * Determines the visibility of the content.
   *
   * @default true
   */
  visible?: boolean;
  /**
   * Contains styling information on how the overlay should be rendered.
   * If not provided a default style is applied.
   */
  symbol?: ISimpleLineSymbol;
}

/** Defines how the numerical(value) axis data should be formatted. */
export interface NumberFormatOptions {
  /** Represents a unique string identifier for the `NumberFormatOptions` object. For the `NumberFormatOptions` object, it is `number`. It can help to differentiate numerical (value) axis from other types of axes such as date-time axis and category axis. */
  type: typeof WebChartTypes.NumberAxisFormat;
  /** Represents the JS native [Intl.NumberFormatOptions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat), which is based on [CLDR](http://cldr.unicode.org/translation/numbers-currency/number-patterns) specifications. */
  intlOptions: Intl.NumberFormatOptions;
}

/**
 * Interface used by the axis `valueFormat` property to describe how to format specific date and time units when displayed on the axis.
 *
 * @example
 * ```json
 * "year": { year: "numeric" }
 * "month": { month: "numeric" }
 * "day": { day: "2-digit" }
 * "hour": { day: "numeric" }
 * "minute": { minute: "numeric" }
 * "second": { second: "numeric" }
 * ```
 */
export interface WebChartDateTimeUnitFormatOptions {
  year?: Intl.DateTimeFormatOptions;
  month?: Intl.DateTimeFormatOptions;
  day?: Intl.DateTimeFormatOptions;
  hour?: Intl.DateTimeFormatOptions;
  minute?: Intl.DateTimeFormatOptions;
  second?: Intl.DateTimeFormatOptions;
}

/** Defines how the `DateTime` axis data should be formatted. */
export interface DateTimeFormatOptions {
  /** Represents a unique string identifier for the `NumberFormatOptions` object. For the `NumberFormatOptions` object, it is `date`. It can help to differentiate date-time axis from other types of axes such as numeric (value) axis and category axis. */
  type: typeof WebChartTypes.DateAxisFormat;
  /** Represent the JS native [Intl.DateTimeFormatOptions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat), which is based on [CLDR](http://cldr.unicode.org/translation/date-time-1/date-time-patterns) specifications. */
  intlOptions: Intl.DateTimeFormatOptions;
  /** Represents how to format specific date and time units when displayed on the axis, independently from the `intlOptions`. */
  formatPerDateTimeUnit?: WebChartDateTimeUnitFormatOptions;
}

/** Defines how the category axis data (categories) should be formatted. */
export interface CategoryFormatOptions {
  /** Represents a unique string identifier for the `CategoryFormatOptions` object. For the `CategoryFormatOptions` object, it is `category`. It can help to differentiate category axis from other types of axes such as date-time axis and numeric (value) axis. */
  type: typeof WebChartTypes.CategoryAxisFormat;
  /** Represents a positive integer which represents the limit on the number of characters to be displayed for all the category strings. The truncated string are appended with `...`. If property is not present or `null`, no truncation is done. */
  characterLimit?: number | null;
}

/** JSON representation of the chart's guide object. Can be used to represent both line and fill guides. */
export interface WebChartGuide {
  /** Represents a unique string identifier for the `Guide` object. For the `Guide` class, it is `chartGuide`. */
  type: typeof WebChartTypes.Guide;
  /** Determines the value where the guide should begin. */
  start: Date | number | string | null;
  /** Determines the value where the guide should end. If it is not specified, a line guide is used, otherwise a fill/rectangular guide is used. */
  end?: Date | number | string | null;
  /** Determines how the guide should be rendered. */
  style: ISimpleFillSymbol | ISimpleLineSymbol;
  /** A unique string identifier which is used to refer to a particular guide. It is displayed in the charts config UI to differentiate between different guides. */
  name: string;
  /** Defines a text label for the given guide. It is displayed on the chart next to the concerned guide and is styled using **esriTS** format. */
  label?: WebChartTextSymbol;
  /**
   * Determines the visibility of the content.
   *
   * @default true
   */
  visible?: boolean;
  /**
   * Determines whether the guide should be rendered on top of (overlapping) the series or under the series.
   *
   * @default false
   */
  above?: boolean;
  /**
   * Indicates whether to apply the hovered element's color to the guide's tooltip background (false) or its outline (true).
   *
   * @default false
   */
  tooltipReverseColor?: boolean;
}

/** JSON representation of the chart's axis object */
export interface WebChartAxis {
  /** Represents a unique string identifier for the `WebChartAxis` object. For `ChartAxis` object, it is `chartAxis`. */
  type: typeof WebChartTypes.Axis;
  /**
   * Determines the visibility of the content.
   *
   * @default true
   */
  visible?: boolean;
  /**
   * Specifies whether the axis has a logarithmic scale or not.
   *
   * @default false
   */
  isLogarithmic?: boolean;
  /** Contains styling information on how the title of the axis should be rendered */
  title?: WebChartText;
  /** Specifies how numerical/categorical/date-time values should be formatted. */
  valueFormat: CategoryFormatOptions | DateTimeFormatOptions | NumberFormatOptions;
  /** The minimum value which the axis should represent, when it is not defined or null, then the minimum value for the corresponding axis is automatically calculated. */
  minimum?: number | null;
  /** The maximum value which the axis should represent, when it is not defined or null, then the maximum value for the corresponding axis is automatically calculated. */
  maximum?: number | null;
  /** Dictates how the grid lines associated with a particular axis should be rendered. */
  grid?: ISimpleLineSymbol;
  /** Represent an array of guides that should be rendered onto the axis. */
  guides?: WebChartGuide[];
  /**
   * Contains styling information on how the axis line should be rendered.
   * If not provided a default style is applied.
   */
  lineSymbol?: ISimpleLineSymbol;
  /** Contains styling information on how the axis labels should be rendered. */
  labels: WebChartText;
  /** Represents the axis scrollbar style and visibility. */
  scrollbar?: WebChartAxisScrollBar;
  /**
   * Represents an option to hide/un-hide the zero line on value axis.
   *
   * @default false
   */
  displayZeroLine?: boolean;
  /**
   * Represents an option to show `integer-only` values for a value axis
   *
   * @default false
   */
  integerOnlyValues?: boolean;
  /**
   * Specifies whether cursor tooltip should be displayed.
   *
   * @default false
   */
  displayCursorTooltip?: boolean;
  /**
   * Allows setting a buffer to a **value axis** to provide some space around the series.
   *
   * @default false
   */
  buffer?: boolean;
  /**
   * The desired minimum distance between two adjacent axis ticks. The actual distance may fluctuate depending on the chart's size.
   * When not provided a default value is assigned according to the axis type and axis labels behavior.
   *
   * **Note**: This property is not applicable to gauge charts.
   *
   * @minimum 1
   */
  tickSpacing?: number;
  /**
   * Specifies the base interval on a date axis. Will be ignored on the other axis types.
   * It will be overridden by the properties from the series `binTemporalData` when provided.
   */
  dateBaseInterval?: TimeIntervalInfo;
}

/** JSON representation of the gauge axis ticks. Currently only used by `WebChartGaugeAxis`. */
export interface WebChartGaugeAxisTick {
  /** Represents a unique string identifier for the `GaugeAxisTick` object. For `WebChartGaugeAxisTick` object, it is `gaugeAxisTick`. */
  type: typeof WebChartTypes.GaugeAxisTick;
  /**
   * Determines the visibility of the axis ticks.
   *
   * @default true
   */
  visible?: boolean;
}

/** JSON representation of a gauge needle. */
export interface WebChartNeedle {
  /** Represents a unique string identifier for the `ChartNeedle` object. For `WebChartNeedle` object, it is `gaugeNeedle`. */
  type: typeof WebChartTypes.GaugeNeedle;
  /**
   * Hides or shows the needle.
   *
   * @default true
   */
  visible?: boolean;
  /** Contains styling information on how the needle should be rendered. */
  symbol?: ISimpleFillSymbol;
  /**
   * Represents the needle's thickness at the bottom (chart's center) in pixels.
   *
   * @default 10
   * @minimum 1
   */
  startWidth?: number | null;
  /**
   * Represents the needle's thickness at the top in pixels.
   *
   * @default 1
   * @minimum 1
   */
  endWidth?: number | null;
  /**
   * Represents the size of the hole in the middle of the chart. Can be visualized when guides are displayed.
   *
   * @default 25
   * @minimum 0
   * @maximum 100
   */
  innerRadius?: number | null;
  /**
   * Hides or shows the needle's pin (centroid circle).
   *
   * @default false
   */
  displayPin?: boolean;
}

/** JSON representation of the gauge chart's axis object. Inherits from the `WebChartAxis` properties. */
export interface WebChartGaugeAxis extends WebChartAxis {
  /** Specifies how the axis' inner label needs to be displayed. */
  innerLabel?: WebChartText;
  /** Specifies how the axis' needle needs to be displayed. */
  needle?: WebChartNeedle;
  /** Specifies how the axis' ticks need to be displayed. */
  ticks?: WebChartGaugeAxisTick;
  /**
   * If a label has a value being a multiple of that property, it will be displayed. Otherwise it will be hidden.
   *
   * If the property is `undefined` or `0`, the chart will be displayed with 6 axis labels distributed evenly along the axis min and max.
   *
   * If the property has a value that results in more than a set limit of axis labels (`25` as defined in `ChartDefaults.gauge.maximumNumberOfLabelIntervals`)
   * this property value will be ignored and the chart will be displayed with only axis min/max with 4 ticks in between.
   *
   * @default undefined
   * @min 0
   */
  labelsIncrement?: number;
  /**
   * Specifies if only the first and last labels need to be displayed. If set to `true` all the other labels will be hidden.
   * Their visibility still depends on the axis labels visibility (`WebChartAxis.labels.visible`).
   *
   * @default false
   */
  onlyShowFirstAndLastLabels?: boolean;
  /** Defines how to convert the axis minimum. */
  minimumValueConversion?: ValueConversion;
  /** Defines how to convert the axis maximum. */
  maximumValueConversion?: ValueConversion;
  /**
   * With a gauge by feature:
   * - `minimumFromField` is expected to be a field name. The value from that field for the given feature is mapped to the axis minimum value.
   *
   * With a statistic gauge:
   * - If `minimumFromField` is set to a field name (string), the minimum from that field is mapped to the axis minimum value.
   * - If it is set to an `IStatisticDefinition` the statistic (min, max, avg...) from the given field is mapped to the axis minimum value.
   *
   * When `minimumFromField` is not provided or when it leads to an invalid value, the `minimum` value from the axis config, if provided, or the default value of 0, in that order, will be used.
   */
  minimumFromField?: IStatisticDefinition | string;
  /**
   * With a gauge by feature:
   * - `maximumFromField` is expected to be a field name. The value from that field for the given feature is mapped to the axis maximum value.
   *
   * With a statistic gauge:
   * - If `maximumFromField` is set to a field name (string), the maximum from that field is mapped to the axis maximum value.
   * - If it is set to an `IStatisticDefinition` the statistic (min, max, avg...) from the given field is mapped to the axis maximum value.
   *
   * When `maximumFromField` is not provided or when it leads to an invalid value, the `maximum` value from the axis config, if provided, or the default value of 0, in that order, will be used.
   */
  maximumFromField?: IStatisticDefinition | string;
}

/** JSON representation of the radar chart's axis object. */
export interface WebChartRadarChartAxis extends WebChartAxis {
  /**
   * Defines the labels orientation.
   *
   * @default WebChartRadarChartAxisLabelsOrientation.Circular
   */
  labelsOrientation?: WebChartRadarChartAxisLabelsOrientation;
}

/** Chart's query object. */
export interface WebChartQuery {
  /** Attribute fields to include in the `FeatureSet`. Will have an effect on chart with no aggregation. */
  outFields?: string[];
  /** Acts as a filter on the base data for attribute-based filtering, expect for bar/line charts for which is is used to handle the split-by field values. */
  where?: string;
  /**
   * An array of fields which determine how the base data is grouped. Only one **groupBy** field is supported,
   *
   * @maxItems 1
   */
  groupByFieldsForStatistics?: string[];
  /** Represents an array of statistics definitions which dictate how a particular field should be aggregated. */
  outStatistics?: IStatisticDefinition[];
  /**
   * Represents the sorting order of the output result.
   *
   * It's recommended to use the `orderByFields` property of the chart's `orderOptions` object instead of this one.
   * If both are used, the `orderByFields` property of the chart's `orderOptions` object will take precedence.
   *
   * The format of any entry in this array is `field_name sorting_order`. When `sorting_order` is not defined, it is assumed to be ascending.
   *
   * @example
   * ```
   * ["STATE_NAME DESC", "CITY_NAME ASC", "CITY_NAME"]
   * ```
   */
  orderByFields?: string[];
  /** Specifies the geodatabase version to display for feature service queries. */
  gdbVersion?: string;
  /** The geometry to apply to the spatial filter. A buffer can be applied to it by setting the properties `distance` and `units`. */
  geometry?: IEnvelope | IExtent | IPoint | IPolygon | IPolygonWithCurves | IPolyline;
  /** For spatial filters, this parameter defines the spatial relationship to filter features in the layer view against the filter geometry. */
  spatialRelationship?: "contains" | "crosses" | "disjoint" | "envelope-intersects" | "index-intersects" | "intersects" | "overlaps" | "relation" | "touches" | "within";
  /** Specifies a search distance for the `geometry`. To be associated with the `units` property. For compatible layers only. */
  distance?: number;
  /**
   * The unit for calculating the buffer distance when `distance` and `geometry` are provided.
   * If not specified, the unit is derived from the geometry spatial reference.
   */
  units?: RESTUnits;
  /** A time extent `[timestamp, timestamp]` for a temporal query against time-aware layers. */
  timeExtent?: [number, number];
  /** The zero-based index indicating where to begin retrieving features. */
  start?: number;
  /** The number of features to retrieve. */
  num?: number;
  /**
   * If true then the query returns distinct values based on the field(s) specified in outFields. Available for count-based aggregations only.
   *
   * @default false
   */
  returnDistinctValues?: boolean;
  /**
   * Indicates whether to fetch null values for them to be counted or displayed as categories on the chart.
   *
   * @default false
   */
  fetchNullValues?: boolean;
  /** An array of objectIds or uniqueIds of the features to be filtered. */
  objectIds?: (number | string)[];
}

/**
 * Subset of the `WebChartQuery`, used at the series level.
 *
 * **Note**: The former `orderByFields` property is replaced by the `orderOptions` property of `WebChart`.
 */
export type WebChartSeriesQuery = Omit<WebChartQuery, "distance" | "gdbVersion" | "geometry" | "num" | "objectIds" | "orderByFields" | "spatialRelationship" | "start" | "timeExtent" | "units">;

/** JSON representation of filters applied to the data. */
export type WebChartDataFilters = Pick<WebChartQuery, "distance" | "gdbVersion" | "geometry" | "objectIds" | "spatialRelationship" | "timeExtent" | "units" | "where">;

/** JSON representation of the chart's series object. All other series extends this interface. */
export interface WebChartSeries {
  type: string;
  /** A unique string used to differentiate the series on a chart. */
  id: string;
  /**
   * Hides or shows the series. If the series is has **visible** set to `false`, the corresponding legend is grayed out in the legend box.
   *
   * @default true
   */
  visible?: boolean;
  /**
   * Hides or shows data tooltips.
   * **Note**: Not applicable to gauge.
   *
   * @default true
   */
  dataTooltipVisible?: boolean;
  /**
   * Indicates whether to apply the hovered element's color to the background (`false`) or the outline (`true`).
   * **Note**: Not applicable to gauge.
   *
   * @default false
   */
  dataTooltipReverseColor?: boolean;
  /** Defines how to render numeric values in tooltips. */
  dataTooltipValueFormat?: NumberFormatOptions;
  /**
   * Defines how to render percent values in tooltips.
   * Used for stacked 100% bar and line charts, as well as pie charts.
   */
  dataTooltipPercentFormat?: NumberFormatOptions;
  /**
   * Defines how to render dates in tooltips.
   * Used for bar and line charts using a date x-axis with no time binning.
   */
  dataTooltipDateFormat?: DateTimeFormatOptions;
  /** Specifies the name of the series. It would be reflected in the chart's legend. */
  name: string;
  /** Specifies a query object associated with a particular series containing information on what data to fetch for that series. */
  query?: WebChartSeriesQuery;
  /**
   * Specifies which field represents the x-coordinates of this series. Empty string or one with just white spaces is not allowed. At least 1 or more word characters (a-z, A-Z, _) is needed.
   *
   * @minLength 1
   */
  x: string;
  /** Specifies how the data labels should be rendered. */
  dataLabels?: WebChartText;
  /**
   * Specifies whether the series should be assigned to the second value axis, when the `axes` property defines it.
   * Supported by bar and line series.
   *
   * @default false
   */
  assignToSecondValueAxis?: boolean;
}

export interface WebChartCalendarDatePartsBinning extends WebChartTemporalBinningBase {
  /** Represents a unique string identifier for the `CalendarDatePartsBinning` object. `For CalendarDatePartsBinning` object, it is `calendarDateParts`. */
  type: typeof WebChartTypes.CalendarDateParts;
  /** Represents the unit to use to bin the data. */
  unit: WebChartCalendarDatePartsUnits;
}

/** Describes the properties available for a temporal binning for bar charts and line charts. */
export interface WebChartTemporalBinning extends WebChartTemporalBinningBase, WebChartTemporalBinningExtras {
  /**
   * The unit of time to use to bin the temporal data.
   *
   * Current limitation: the "quarters" unit is only supported if the provided layer supports the `queryBins` operation.
   */
  unit?: WebChartTemporalBinningUnits;
  /** The span of time that will be binned or aggregated together. Works in coordination with `unit`. */
  size?: number;
  /**
   * The time interval alignment type. Valid options include `equalIntervalsFromStartTime` and `equalIntervalsFromEndTime`.
   *
   * When specific the binning will start at the first or last date of the dataset.
   *
   * @default "equalIntervalsFromStartTime"
   */
  timeAggregationType?: WebChartTimeAggregationTypes;
}

/** Describes the properties related to a temporal series. */
export interface WebChartTemporalSeries {
  /**
   * Whether to use the time properties to bin the temporal data.
   *
   * `false` - the `binCount` and `unit` properties can be used to set the date axis base interval.
   *
   * @default true
   */
  binTemporalData?: boolean;
  /** Describes how to bin the temporal data. */
  temporalBinning?: WebChartTemporalBinning;
}

/** Bar chart shows the categorical distribution of `String` or `DateTime` data. */
export interface WebChartBarChartSeries extends WebChartSeries, WebChartTemporalSeries {
  /** Represents a unique string identifier for the `BarChartSeries` object. For `BarSeries` object, it is `barSeries`. */
  type: typeof WebChartTypes.BarSeries;
  /**
   * Specifies which field represents the y-coordinates of this series. Empty string or one with just white spaces is not allowed. At least 1 or more word characters (a-z, A-Z, _) are needed.
   *
   * @minLength 1
   */
  y: string;
  /** Contains styling information on how the columns/bars should be rendered. */
  fillSymbol?: ISimpleFillSymbol;
  /**
   * `true` or `undefined` - the labels displayed within a small stacked column are hidden to avoid cluttering.
   * `false` - all the data labels are displayed.
   *
   * @default true
   */
  hideOversizedStackedLabels?: boolean;
  /**
   * When `true`, the labels displayed within a small column for sideBySide bar series are hidden to avoid cluttering.
   * When `false` or `undefined` (default), all the data labels are displayed.
   *
   * @default false
   */
  hideOversizedSideBySideLabels?: boolean;
  /**
   * Specifies how to display the category with null value.
   * Setting this property will ensure that the item with no data is displayed on the chart with the specified text and color.
   */
  nullCategory?: WebChartNullCategory;
}

/** Object containing histogram overlays. */
export interface HistogramOverlays {
  /** Represents a unique string identifier for the `HistogramOverlays` object. For `HistogramOverlays` object, it is `chartOverlays`. */
  type: typeof WebChartTypes.Overlays;
  /**
   * Specifies the mean overlay for histogram.
   *
   * If not provided, the mean overlay is not displayed.
   */
  mean?: WebChartOverlay;
  /**
   * Specifies the median overlay for histogram.
   *
   * If not provided, the median overlay is not displayed.
   */
  median?: WebChartOverlay;
  /**
   * Specifies the standard deviation overlay for histogram.
   *
   * If not provided, the standard deviation overlay is not displayed.
   */
  standardDeviation?: WebChartOverlay;
  /**
   * Specifies the comparison distribution overlay for histogram.
   *
   * If not provided, the comparison distribution overlay is not displayed.
   */
  comparisonDistribution?: WebChartOverlay;
}

/** Histogram shows the frequency distribution of a numerical field. */
export interface WebChartHistogramSeries extends WebChartSeries {
  /** Represents a unique string identifier for the `HistogramSeries` object. For `HistogramSeries` object, it is `histogramSeries`. */
  type: typeof WebChartTypes.HistogramSeries;
  /**
   * Bin count must be a positive integer.
   *
   * @default 32
   * @minimum 1
   * @multipleOf 1
   */
  binCount?: number | null;
  /**
   * Specifies the chart overlays. Histogram supports 4 overlays: **mean**, **median**, **standardDeviation** and **comparisonDistribution**.
   * The overlays won't show if the property is not defined.
   */
  overlays?: HistogramOverlays;
  /** Specifies how the data should be transformed (e.g. square root, log, etc.) before binning. */
  dataTransformationType?: WebChartDataTransformations;
  /** Contains styling information on how the columns should be rendered. */
  fillSymbol?: ISimpleFillSymbol;
}

/** Object containing scatterplot overlays. */
export interface ScatterplotOverlays {
  /** Represents a unique string identifier for the `ScatterplotOverlays` object. For the `ScatterplotOverlays` object, it is `chartOverlays`. */
  type: typeof WebChartTypes.Overlays;
  /**
   * Specifies the trend line overlay for scatterplot.
   *
   * The trend line won't show if the property is not defined.
   */
  trendLine?: WebChartOverlay;
}

export interface SizePolicy {
  /** Represents a unique string identifier for the `sizePolicy` object. For the `sizePolicy` object, it is `sizeScale`. */
  type: typeof WebChartTypes.SizePolicy;
  /**
   * The type of scale to apply to the markers (`logarithmic` or `linear`).
   *
   * @default SizePolicyScaleTypes.Linear
   */
  scaleType?: SizePolicyScaleTypes;
  /** The field which determines the markers size. */
  field: string;
  /**
   * The minimum marker size.
   *
   * @default 5
   * @min 1
   * @multipleOf 1
   */
  minSize?: number;
  /**
   * The maximum marker size.
   *
   * @default 30
   * @min 1
   * @multipleOf 1
   */
  maxSize?: number;
}

/** Scatterplot shows the relationship between two numerical fields. */
export interface WebChartScatterplotSeries extends WebChartSeries {
  /** Represents a unique string identifier for the `ScatterSeries` object. For the `ScatterSeries` object, it is `scatterSeries`. */
  type: typeof WebChartTypes.ScatterSeries;
  /**
   * Empty string or one with just white spaces is not allowed. At least 1 or more word characters (a-z, A-Z, _) are needed.
   *
   * @minLength 1
   */
  y: string;
  /** Specifies how each data point in the scatterplot should be rendered. */
  markerSymbol?: ISimpleMarkerSymbol;
  /**
   * Specifies all the chart overlays. The scatterplot implements only 1 overlay, **trendLine**.
   * The overlays won't show if the property is not defined.
   */
  overlays?: ScatterplotOverlays;
  /** Specifies rules to use the scatterplot as bubble plot, by changing dynamically the markers size according to a specific field value. */
  sizePolicy?: SizePolicy;
  /** Specifies the additional numeric fields in the tooltip. */
  additionalTooltipFields?: string[];
}

/** JSON representation of the pie ticks. */
export interface WebChartPieChartTick {
  /** Represents a unique string identifier for the `WebChartPieChartTick` object. For the `WebChartPieChartTick` object, it is `pieTick`. */
  type: typeof WebChartTypes.PieTick;
  /**
   * Determines the visibility of the tick.
   *
   * Assigning the `true` value will only be considered when the data labels are visible (`series.dataLabels.visible`) and
   * when the data label associated to the tick is outside of the chart (`series.dataLabelsOffset` > 0).
   */
  visible?: boolean;
  /** Contains styling information on how the pie chart ticks should be rendered. */
  lineSymbol?: ISimpleLineSymbol;
}

/** JSON representation of the pie slices */
export interface WebChartPieChartSlice {
  /** A unique string used identify the slice of a pie chart. */
  readonly sliceId: string;
  /** The slice's original label. */
  readonly originalLabel?: Date | number | string | null;
  /**
   * Custom label for the slice.
   *
   * For grouped slice, the default value is `Other`.
   * For regular slice, it will be either the category or field name.
   */
  label?: string;
  /** Contains styling information on how the slice should be rendered. If not provided, the slice will be styled with default values. */
  fillSymbol?: ISimpleFillSymbol;
}

/** JSON representation of the pie grouped slice. */
export interface WebChartPieChartGroupSlice extends WebChartPieChartSlice {
  /**
   * Slices that have a percent value equal or lesser to this threshold are grouped into a unique slice.
   *
   * @min 0
   * @max 100
   */
  percentageThreshold: number;
  /**
   * Specifies how the grouped slice data labels should be rendered.
   *
   * If the property is not set the `series.dataLabels` will be used instead.
   */
  dataLabels?: WebChartText;
}

/** JSON representation of the pie chart series */
export interface WebChartPieChartSeries extends WebChartSeries {
  /** Represents a unique string identifier for the `WebChartPieChartSeries` object. For the `WebChartPieChartSeries` object, it is `pieSeries`. */
  type: typeof WebChartTypes.PieSeries;
  /**
   * Specifies which field represents the y-coordinates of this series. Empty string or one with just white spaces is not allowed. At least 1 or more word characters (a-z, A-Z, _) are needed.
   *
   * @minLength 1
   */
  y: string;
  /**
   * Represents the size of the hole in middle of the chart. The number is used as a percentage rather than a fixed value.
   *
   * @default 50
   * @minimum 0
   * @maximum 100
   */
  innerRadius?: number | null;
  /** @default -90 */
  startAngle?: number | null;
  /** @default 270 */
  endAngle?: number | null;
  /** Contains styling information on how the slices should be rendered. */
  fillSymbol?: ISimpleFillSymbol;
  /**
   * Indicates whether the category associated to a slice is to be displayed on its data label.
   * This property will be ignored if the chart options `dataLabelFormatter` is provided.
   *
   * @default true
   */
  displayCategoryOnDataLabel?: boolean;
  /**
   * Indicates whether the numeric value associated to a slice is to be displayed on its data label.
   *
   * If both displayNumericValue & displayPercentage are true on a same label, they will be displayed as `percentage (value)`.
   *
   * This property will be ignored if the chart options `dataLabelFormatter` is provided.
   *
   * @default true
   */
  displayNumericValueOnDataLabel?: boolean;
  /**
   * Indicates whether the percentage associated to a slice is to be displayed on its data label.
   *
   * If both displayNumericValue & displayPercentage are true on a same label, they will be displayed as `percentage (value)`
   *
   * This property will be ignored if the chart options `dataLabelFormatter` is provided.
   *
   * @default false
   */
  displayPercentageOnDataLabel?: boolean;
  /**
   * Indicates whether the category associated to a slice is to be displayed on its tooltip.
   *
   * This property will be ignored if the chart options `tooltipFormatter` is provided.
   *
   * @default true
   */
  displayCategoryOnTooltip?: boolean;
  /**
   * Indicates whether the numeric value associated to a slice is to be displayed on its tooltip.
   *
   * If both displayNumericValue & displayPercentage are true on a same label, they will be displayed as `percentage (value)`
   *
   * This property will be ignored if the chart options `tooltipFormatter` is provided.
   *
   * @default true
   */
  displayNumericValueOnTooltip?: boolean;
  /**
   * Indicates whether the percentage associated to a slice is to be displayed on its tooltip.
   *
   * If both displayNumericValue & displayPercentage are true on a same label, they will be displayed as `percentage (value)`
   *
   * This property will be ignored if the chart options `tooltipFormatter` is provided.
   *
   * @default true
   */
  displayPercentageOnTooltip?: boolean;
  /**
   * Specifies how the numerical values should be formatted (applied to label, tooltip and legend).
   *
   * Can be overridden for the tooltips by `series.dataTooltipValueFormat`.
   */
  numericValueFormat?: NumberFormatOptions;
  /**
   * Specifies how the percent values should be formatted (applied to label, tooltip and legend).
   *
   * Can be overridden for the tooltips by `series.dataTooltipPercentFormat`.
   */
  percentValueFormat?: NumberFormatOptions;
  /** Adds a prefix to all the values displayed on the pie chart: data labels, tooltips and legend. */
  valuePrefix?: string;
  /** Adds a suffix to all the values displayed on the pie chart: data labels, tooltips and legend. */
  valueSuffix?: string;
  /** Adds a prefix to all the percentages displayed on the pie chart: data labels, tooltips and legend. */
  percentagePrefix?: string;
  /** Adds a suffix to all the percentages displayed on the pie chart: data labels, tooltips and legend. */
  percentageSuffix?: string;
  /**
   * If set, the category on the data label is truncated to display only `characterLimit` characters, and an ellipsis ("...") is added to the end of the label.
   *
   * Does not affect the value or percentage displayed in labels. Not applicable to tooltips or legend labels.
   *
   * @default undefined
   * @minimum 1
   * @multipleOf 1
   */
  dataLabelsCharacterLimit?: number | null;
  /**
   * Specifies how to render the ticks shown on each slide.
   * Ticks will be displayed with default values if not provided.
   */
  ticks?: WebChartPieChartTick;
  /**
   * Whether to place the data labels inside the pie slices.
   *
   * When set to `true` the following properties will be ignored:
   * - `dataLabelsOffset`
   * - `alignDataLabels`
   * - `optimizeDataLabelsOverlapping`
   *
   * @default false
   */
  dataLabelsInside?: boolean;
  /**
   * Determines in pixel how far the data labels should be placed from their slice.
   * If a negative value is provided the label will be placed inside of the chart.
   *
   * Ignored when `dataLabelsInside` is set to `true`.
   *
   * @default 10
   */
  dataLabelsOffset?: number;
  /**
   * Aligns labels into columns to make them more readable and avoid them to overlap each other.
   *
   * Ignored when `dataLabelsInside` is set to `true`.
   *
   * @default false
   */
  alignDataLabels?: boolean;
  /**
   * Optimizes the data labels rendering to avoid them to be cut off on the edges or to overlap the legend by wrapping them and adding padding to the chart.
   *
   * Ignored when `dataLabelsInside` is set to `true`.
   *
   * @default false
   */
  optimizeDataLabelsOverlapping?: boolean;
  /** Specifies if and how the slices under a given percentage threshold are grouped into a unique slice. */
  sliceGrouping?: WebChartPieChartGroupSlice;
  /**
   * An array of `WebChartPieChartSlice` representing the ids, labels and styles of the pie slices.
   *
   * When this property is not defined, or when a pie slice does not have a matching slice in this array,
   * the series' fillSymbol will be used. If the series' fillSymbol does not contain color information, colors from the color ramps will be utilized.
   */
  slices?: WebChartPieChartSlice[];
}

/** JSON representation of the gauge series */
export interface WebChartGaugeSeries extends WebChartSeries {
  /** Represents a unique string identifier for the `WebChartGaugeSeries` object. For the `WebChartGaugeSeries` object, it is `gaugeSeries`. */
  type: typeof WebChartTypes.GaugeSeries;
  /** Defines the conversion to apply to the gauge value. */
  valueConversion?: ValueConversion;
  /**
   * Specifies the index of the feature to be rendered.
   *
   * This property will be ignored for a statistic gauge (indicated via `WebGaugeChart.subType` property).
   *
   * For feature-based gauge, if this property is not present, the first feature will be used (featureIndex = 0)
   */
  featureIndex?: number;
}

/** JSON representation of the line chart series. */
export interface WebChartLineChartSeries<SeriesType extends "lineSeries" | "radarSeries" = "lineSeries"> extends WebChartSeries, WebChartTemporalSeries {
  /** Represents a unique string identifier for the `WebChartLineChartSeries` object. For the `WebChartLineChartSeries` object, it is `lineSeries`. */
  type: SeriesType;
  /** Specifies the numeric field(s) used by the series. */
  y: string[] | string;
  /** Contains styling information on how the line or line segments should be rendered. */
  lineSymbol?: ISimpleLineSymbol;
  /**
   * Specifies whether line segments should be smoothed.
   *
   * @default false
   */
  lineSmoothed?: boolean;
  /**
   * Indicates whether line series show area.
   *
   * @default false
   */
  showArea?: boolean;
  /**
   * Indicates whether to show or hide the markers/bullets of the line series.
   *
   * @default true
   */
  markerVisible?: boolean;
  /** Contains styling information on how the marker should be rendered. */
  markerSymbol?: ISimpleMarkerSymbol;
  /**
   * Specifies the color of the filled area for line chart.
   *
   * `areaColor` will be applied only if `showArea` is true, and is defaulted to the line color if not provided.
   */
  areaColor?: Color;
  /**
   * Specifies how negative values are treated in stacked series.
   *  `true` - negative values will be stacked on the base line.
   *  `false` - negative values will be stacked in relation to their previous values in the stack.
   *
   * @default true
   */
  stackNegativeValuesToBaseline?: boolean;
  /**
   * Whether to connect the lines when there's a gap in the data.
   * Can be overridden by the temporal data setting `nullPolicy`.
   *
   * @default true
   */
  connectLines?: boolean;
  /**
   * Specifies how to display the category with null value.
   *
   * Setting this property will ensure that the item with no data is displayed on the chart with the specified text and color.
   */
  nullCategory?: WebChartNullCategory;
}

/** JSON representation of the box plot series */
export interface WebChartBoxPlotSeries extends WebChartSeries {
  type: typeof WebChartTypes.BoxPlotSeries;
  /**
   * Specifies the numeric field(s) used by the box plot series.
   *
   * @minLength 1
   * @minItems 1
   */
  y: string[] | string;
  /** Contains styling information on how the box and whiskers should be rendered. The whiskers use the `fillSymbol.outline`. */
  fillSymbol?: ISimpleFillSymbol;
}

/** JSON representation of the Heat chart with gradient heat rules. */
export interface WebChartHeatChartGradient {
  /** An array of 2 colors to use for the gradient. The first color represents the minimum value, the second color represents the maximum value. */
  colorList?: [Color, Color];
  /** Specifies the custom minimum value for the heat chart.  If none is provided, the minimum value from the dataset will be used. */
  minValue?: number;
  /** Specifies the custom maximum value for the heat chart.  If none is provided, the maximum value from the dataset will be used. */
  maxValue?: number;
  /**
   * Specifies the color to use for the items outside the lower range specified by `minValue`. If none is provided,
   * the default color will be used.
   *
   * @default `[250, 250, 250, 255] - white`
   */
  outsideRangeLowerColor?: Color;
  /**
   * Specifies the color to use for the items outside the upper range specified by `maxValue`. If none is provided,
   * the default color will be used.
   *
   * @default `[0, 0, 255, 255] - blue`
   */
  outsideRangeUpperColor?: Color;
}

/** JSON representation of the Heat chart with class breaks heat rules. */
export interface WebChartHeatChartHeatClassBreaks {
  /**
   * The number of class breaks to be used for the heat chart.
   *
   * @default 5
   */
  breaksCount?: number;
  /**
   * The classification method to be used for the heat chart.
   * `equal-interval` - divides the range of values into equal-sized intervals.
   * `quantile` - divides the range of values into intervals that contain an equal number of features.
   * `natural-breaks` - identifies natural groupings of values in the data by minimizing the variance within classes and maximizing the variance between classes.
   * `manual` - allows you to manually specify the class breaks.
   */
  classificationMethod?: WebChartClassBreakTypes;
}

/** JSON representation of the heat chart empty cell configuration. */
export interface WebChartHeatChartEmptyCell {
  /**
   * Specifies the text to use by the empty cells.
   * If none is provided, the default `null` text will be used.
   *
   * @default `null`
   */
  text?: string;
  /**
   * Specifies the symbol to use by the empty cells.
   * If none is provided, the default symbol will be used.
   */
  symbol?: ISimpleFillSymbol;
}

/** JSON representation of the heat chart series. */
export interface WebChartHeatChartSeries extends WebChartSeries {
  type: typeof WebChartTypes.HeatSeries;
  /**
   * Specifies which field represents the y-coordinates of this series. Empty string or one with just white spaces is not allowed. At least 1 or more word characters (a-z, A-Z, _) are needed.
   *
   * @minLength 1
   */
  y: string;
  /** Describes how to bin the temporal data when the x-axis field is a date. */
  xTemporalBinning?: WebChartCalendarDatePartsBinning;
  /** Describes how to bin the temporal data when the y-axis field is a date. */
  yTemporalBinning?: WebChartCalendarDatePartsBinning;
  /** Defines how the cells outline should render. */
  gridLine?: ISimpleLineSymbol;
  /**
   * Defines the type of rule to apply for the heat chart.
   *
   * @default WebChartHeatChartHeatRulesTypes.Gradient
   */
  heatRulesType?: WebChartHeatChartHeatRulesTypes;
  /** Specifies the details of the gradient rules for the heat chart. */
  gradientRules?: WebChartHeatChartGradient;
  /** Specifies the details of the class breaks rules for the heat chart. */
  classBreaksRules?: WebChartHeatChartHeatClassBreaks;
  /** Specifies how to display the empty cells, in terms of text and symbology. */
  emptyCells?: WebChartHeatChartEmptyCell;
}

export type WebChartRadarChartSeries = WebChartLineChartSeries<"radarSeries">;

/** Type containing all the series types available */
export type WebChartSeriesType = WebChartBarChartSeries | WebChartBoxPlotSeries | WebChartGaugeSeries | WebChartHeatChartSeries | WebChartHistogramSeries | WebChartLineChartSeries | WebChartPieChartSeries | WebChartRadarChartSeries | WebChartScatterplotSeries;

/** JSON representation of the web chart object. */
export interface WebChart {
  /** Version of the specification. Used to identify when a saved config was created. */
  version: typeof WebChartCurrentVersion;
  /** Represents a unique string identifier for the `WebChart` object. For the `WebChart` object, it is `chart`. */
  type: typeof WebChartTypes.Chart;
  /** Can be used to uniquely identify a chart. */
  id?: string;
  /** Property representing the layer to be used by the chart. If not provided we expect a layer object to be set on the component. */
  iLayer?: IFeatureLayer;
  /** Used to filter the chart's data while in layer mode. */
  dataFilters?: WebChartDataFilters;
  /** Specifies title of the chart. */
  title?: WebChartText;
  /** Specifies subtitle of the chart. */
  subtitle?: WebChartText;
  /** Specifies footer of the chart. */
  footer?: WebChartText;
  /**
   * Specifies the background color of the chart.
   *
   * @default `[255, 255, 255, 255]`
   */
  background?: Color;
  /** Specifies cursor's crosshair information for the chart. Only for XY charts. */
  cursorCrosshair?: WebChartCursorCrosshair;
  /** Specifies the Legend information for the chart. */
  legend?: WebChartLegend | WebChartPieChartLegend;
  /**
   * Represents an array of **at least 1 or at most 3** chart axes accompanying the chart.
   * The third axis config is used when a series `assignToSecondValueAxis` is set to `true`.
   * Some of the axis features won't apply to the third axis (e.g. labels behaviors).
   */
  axes?: [WebChartAxis, WebChartAxis?, WebChartAxis?];
  /**
   * Represents the way the labels should behave when the horizontal axis can't display them all.
   *
   * Applicable to XY charts only. Histograms support `none` and `rotate` only. The default horizontal axis value is `rotate`, except for histograms, where it is `none`.
   *
   * @default "rotate"
   */
  horizontalAxisLabelsBehavior?: WebChartLabelBehavior;
  /**
   * Represents the way the labels should behave when the vertical axis can't display them all.
   *
   * For XY Chart only.
   *
   * @default "wrap"
   */
  verticalAxisLabelsBehavior?: WebChartLabelBehavior;
  /**
   * Represents an array of various chart series to be plot inside the chart.
   *
   * Empty array is not allowed.
   *
   * @minItems 1
   */
  series: WebChartSeriesType[];
  /**
   * Specifies whether or not the chart is rotated.
   *
   * @default false
   */
  rotated?: boolean;
  /**
   * Specifies how the bars/lines should be placed when multiple series are rendered in the same chart.
   *
   * Only applicable to bar and line series.
   *
   * @default sideBySide
   */
  stackedType?: WebChartStackedKinds;
  /**
   * Specifies whether to first try matching the colors from the layer renderer or the chart renderer
   * for coloring the chart elements, like markers, line segments, columns, etc.
   *
   * To do so, this property needs to be set to `true`.
   *
   * When there is no matching color found (for when `colorMatch = true`) or when `colorMatch = false`,
   * the colors from the config, and then from the color ramps will be used, in that order.
   *
   * @default false
   */
  colorMatch?: boolean;
  /**
   * Renderer to use to style the series when the chart uses the color match mode.
   *
   * Considered before the layer's renderer.
   */
  chartRenderer?: IDrawingInfo["renderer"];
  /** Chart order options for data and series. */
  orderOptions?: {
      series?: WebChartOrderSeriesBy;
      data?: WebChartDirectionalDataOrder | WebChartMultiAxesDataOrder | WebChartPredefinedLabelsDataOrder;
      orderByFields?: string[];
  };
}

/** JSON representation of the gauge chart. */
export interface WebGaugeChart extends WebChart {
  /**
   * Represents the size of the hole in middle of the chart. The number is used as a percentage rather than a fixed value.
   *
   * @default 50
   */
  innerRadius?: number | null;
  /**
   * Represents where is the chart's starting point
   *
   * @default -180
   */
  startAngle?: number | null;
  /**
   * Represents where is the chart's ending point. To be related with `startAngle`. If `endAngle-startAngle` is 360 the chart will render as a full circle.
   *
   * @default 180
   */
  endAngle?: number | null;
  /** Array of one `WebChartGaugeAxis`. */
  axes: [WebChartGaugeAxis];
  /**
   * The type of gauge, like `FeatureGauge` or `StatisticGauge`.
   *
   * When this property is not specified, it will be defaulted to `GaugeChartSubTypes.StatisticGauge`.
   */
  subType?: GaugeChartSubTypes;
}

/** JSON representation of the box plot. */
export interface WebBoxPlot extends WebChart {
  /** Whether to show the outliers on the chart. */
  showOutliers?: boolean;
  /** Whether to standardize the values by calculating the series z-score. */
  standardizeValues?: boolean;
  /**
   * Whether to show the mean lines on the chart. Applies only if a split-by field is set.
   *
   * Additionally the chart will render with that option enabled only if the the series array contains one box plot series and N lines series.
   *
   * @default false
   */
  showMean?: boolean;
  /** The box plot series can be of type `boxPlotSeries` or `lineSeries`. */
  series: (WebChartBoxPlotSeries | WebChartLineChartSeries)[];
}

/** Gives a JSON representation of the radar chart object. */
export interface WebRadarChart extends WebChart {
  /**
   * The radar chart series.
   *
   * @minItems 1
   */
  series: WebChartRadarChartSeries[];
  /** Array of two axes, one specific to the radar chart and the other one common to all charts. */
  axes: [WebChartRadarChartAxis, WebChartAxis];
}

/** Gives a JSON representation of the heat chart object. */
export interface WebHeatChart extends WebChart, WebChartTemporalBinningExtras {
  /**
   * The heat chart series.
   *
   * @minItems 1
   */
  series: WebChartHeatChartSeries[];
  orderOptions?: Omit<WebChart["orderOptions"], "data" | "orderByFields"> & { data?: WebChartMultiAxesDataOrder; };
  /**
   * Whether to hide entire rows or columns that are empty (i.e. contain no valid data).
   *
   * @default false
   */
  hideEmptyRowsAndColumns?: boolean;
  /**
   * The calendar view type for the heat chart.
   *
   * **NOTE**: This property is only applicable to the calendar heat chart.
   */
  viewType?: WebChartHeatChartViewTypes;
  /**
   * Whether to include leap day (Feb. 29th) in queries.
   *
   * @default false
   */
  includeLeapDay?: boolean;
}

/** Describes the basic properties available for a temporal binning */
export interface WebChartTemporalBinningBase {
  /**
   * Determines whether incomplete time intervals at the start or end of the data span (depending on the `timeAggregationType`) will be removed from the chart.
   *
   * Incomplete intervals on a chart can cause misleading results in which the period in question is under- or over reported due to a different amount of time in the interval.
   *
   * `true` - trim the incomplete intervals.
   * `false` - does not trim the incomplete intervals.
   *
   * @default true
   */
  trimIncompleteTimeInterval?: boolean;
  /**
   * The binning start date.
   *
   * Current limitation: this is applied only when the provided layer supports the `queryBins` operation.
   */
  start?: number;
  /**
   * The binning end date.
   *
   * Current limitation: this is applied only when the provided layer supports the `queryBins` operation.
   */
  end?: number;
  /**
   * Offset to apply to the results.
   *
   * Current limitation: this is applied only when the provided layer supports the `queryBins` operation.
   */
  offset?: {
      unit: WebChartTemporalBinningUnits;
      size: number;
  };
}

/** Describes the extra properties available for a temporal series and for the heat chart. */
export interface WebChartTemporalBinningExtras {
  /**
   * Defines the [IANA time zone](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) used for temporal bin calculations.
   *
   * Current limitation: this is applied only when the provided layer supports the `queryBins` operation.
   */
  outTimeZone?: string;
  /**
   * The first day of the week. This property is used to determine the start of the week for date-based bins. The default value depends on the user locale (e.g. `7` as Sunday for US, `1` as Monday for France).
   *
   * Current limitation: this is applied only when the provided layer supports the `queryBins` operation.
   *
   * @minimum 1
   * @maximum 7
   * @multipleOf 1
   */
  firstDayOfWeek?: number;
  /**
   * How summarized bins returning a null value are displayed. Supported options are:
   * - `null`, `zero`, and `interpolate` for line series.
   * - `null` and `zero` for bar series.
   *
   * @default "null"
   */
  nullPolicy?: WebChartNullPolicyTypes;
}