@deephaven/embed-chart 0.30.1-beta.0 → 0.30.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +0,0 @@
1
- {"version":3,"file":"App.730dc7d8.js","sources":["../../../utils/src/Asserts.ts","../../../utils/src/TextUtils.ts","../../../components/src/context-actions/ContextMenuRoot.tsx","../../../jsapi-utils/src/formatters/TableColumnFormatter.ts","../../../jsapi-utils/src/formatters/BooleanColumnFormatter.ts","../../../jsapi-utils/src/formatters/CharColumnFormatter.ts","../../../jsapi-shim/src/dh.ts","../../../jsapi-shim/src/PropTypes.js","../../../jsapi-types/src/index.ts","../../../jsapi-utils/src/formatters/DateTimeColumnFormatter.ts","../../../jsapi-utils/src/formatters/DecimalColumnFormatter.ts","../../../jsapi-utils/src/formatters/DefaultColumnFormatter.ts","../../../jsapi-utils/src/formatters/IntegerColumnFormatter.ts","../../../jsapi-utils/src/formatters/StringColumnFormatter.ts","../../../jsapi-utils/src/DateUtils.ts","../../../filters/src/Operator.ts","../../../filters/src/Type.ts","../../../jsapi-utils/src/TableUtils.ts","../../../jsapi-utils/src/Formatter.ts","../../../jsapi-utils/src/FormatterUtils.ts","../../../chart/src/plotly/Plotly.js","../../../chart/src/plotly/Plot.js","../../../chart/src/ChartModel.ts","../../../chart/src/ChartTheme.ts","../../../chart/src/ChartUtils.ts","../../../chart/src/Chart.tsx","../../../chart/src/FigureChartModel.ts","../../../chart/src/ChartModelFactory.ts","../../src/App.tsx"],"sourcesContent":["// eslint-disable-next-line import/prefer-default-export\nexport function assertNotNull<T>(\n value: T | null | undefined\n): asserts value is T {\n if (value == null) throw new Error('Value is null or undefined');\n}\n","class TextUtils {\n /**\n * Joins a list of strings with a comma, keeping the oxford comma and adding \"and\" as appropriate.\n * Eg.\n * One\n * One and Two\n * One, Two, and Three\n * @param items The items to join in a list\n * @param conjunction Conjunction to use between the last two items\n */\n static join(items: string[] | null, conjunction = 'and'): string {\n if (items == null || items.length === 0) {\n return '';\n }\n\n if (items.length === 1) {\n return items[0];\n }\n\n if (items.length === 2) {\n return `${items[0]} ${conjunction} ${items[1]}`;\n }\n\n const itemText = items.slice(0, items.length - 1).join(', ');\n const lastItem = items[items.length - 1];\n return `${itemText}, ${conjunction} ${lastItem}`;\n }\n\n /**\n * Converts text to lower case, handling null if necessary and returning an empty string\n * @param text The text to convert to lower case\n * @param isNullAllowed True if a null string should return an empty string from this function. If false an error is thrown if null is passed in.\n */\n static toLower(text: string | null, isNullAllowed = true): string {\n if (text == null) {\n if (isNullAllowed) {\n return '';\n }\n\n throw new Error('Null string passed in to TextUtils.toLower');\n }\n\n return text.toLowerCase();\n }\n\n /**\n *\n * @param a The string to sort\n * @param b Second string to sort\n * @param isAscending Whether to sort ascending or descending\n */\n static sort(a: string, b: string, isAscending = true): number {\n if (a < b) {\n return isAscending ? -1 : 1;\n }\n if (a > b) {\n return isAscending ? 1 : -1;\n }\n return 0;\n }\n}\n\nexport default TextUtils;\n","import React, { Component } from 'react';\nimport classNames from 'classnames';\nimport ContextMenu from './ContextMenu';\nimport ContextActionUtils, { MenuItem } from './ContextActionUtils';\n\ntype ContextMenuRootProps = Record<string, never> & {\n 'data-testid'?: string;\n};\n\ninterface ContextMenuRootState {\n actions: MenuItem[] | null;\n left: number;\n top: number;\n}\n\n/**\n * Put at your root container, any contextmenu events that are unhandled in the root container will be handled by this\n */\nclass ContextMenuRoot extends Component<\n ContextMenuRootProps,\n ContextMenuRootState\n> {\n constructor(props: ContextMenuRootProps) {\n super(props);\n\n this.handleMenuClose = this.handleMenuClose.bind(this);\n this.handleContextMenu = this.handleContextMenu.bind(this);\n this.container = React.createRef();\n this.openMenu = React.createRef();\n\n this.state = {\n actions: null,\n left: 0,\n top: 0,\n };\n }\n\n componentDidMount(): void {\n if (this.container.current?.parentElement) {\n this.container.current.parentElement.addEventListener(\n 'contextmenu',\n this.handleContextMenu\n );\n }\n }\n\n componentWillUnmount(): void {\n if (this.container.current?.parentElement) {\n this.container.current.parentElement.removeEventListener(\n 'contextmenu',\n this.handleContextMenu\n );\n }\n }\n\n container: React.RefObject<HTMLDivElement>;\n\n openMenu: React.RefObject<ContextMenu>;\n\n handleContextMenu(e: MouseEvent): void {\n if (!ContextActionUtils.isContextActionEvent(e)) {\n return;\n }\n\n if (!this.container.current) {\n return;\n }\n\n if (e.metaKey || e.ctrlKey) {\n // debug escape hatch to native menu\n return;\n }\n\n const contextActions = ContextActionUtils.getMenuItems(e.contextActions);\n\n const parentRect = this.container.current.getBoundingClientRect();\n const top = e.clientY - parentRect.top;\n const left = e.clientX - parentRect.left;\n\n if (contextActions.length === 0) {\n // This code path seems to only exist for Chrome on Mac\n // Mac appears to trigger contextmenu events on mousedown vs. mouseup on Windows\n // Mouseup on Windows triggers blur before contextmenu which effectively does what this path does\n if (e.target === this.container.current) {\n // re-emit right clicks that hit the context-root blocking layer\n e.preventDefault();\n\n // Set actions to null removes the menu\n // That allows a new menu to be opened on a different element so initial position is set properly\n // Otherwise the instance of this menu may be reused\n // A new contextmenu event is triggered on the element at the location the user clicked on the blocking layer\n this.setState({ actions: null }, () => {\n const element = document.elementFromPoint(left, top); // x y\n\n const mouseEvent = new MouseEvent('contextmenu', {\n clientX: e.clientX,\n clientY: e.clientY,\n bubbles: true,\n cancelable: true,\n });\n\n element?.dispatchEvent(mouseEvent);\n });\n return;\n }\n\n // target was a menu item\n return;\n }\n\n // new clicks, set actions\n e.preventDefault();\n this.setState({\n actions: contextActions,\n top,\n left,\n });\n }\n\n handleMenuClose(menu: ContextMenu): void {\n if (menu === this.openMenu.current) {\n this.setState({ actions: null });\n }\n }\n\n render(): JSX.Element {\n let menu = null;\n const { 'data-testid': dataTestId } = this.props;\n const { actions, top, left } = this.state;\n if (actions) {\n menu = (\n <ContextMenu\n ref={this.openMenu}\n actions={actions}\n onMenuClosed={this.handleMenuClose}\n top={top}\n left={left}\n updatePosition={(verifiedTop, verifiedLeft) => {\n this.setState({ top: verifiedTop, left: verifiedLeft });\n }}\n data-testid={dataTestId}\n />\n );\n }\n return (\n <div\n className={classNames('context-menu-root', { active: actions })}\n ref={this.container}\n >\n {menu}\n </div>\n );\n }\n}\n\nexport default ContextMenuRoot;\n","/* eslint class-methods-use-this: \"off\" */\n/**\n * Default column data formatter. Just interpolates the value as a string and returns.\n * Extend this class and register with TableUtils to make use of it.\n */\n\nexport type TableColumnFormatType =\n | 'type-global'\n | 'type-context-preset'\n | 'type-context-custom';\n\nexport type TableColumnFormat = {\n label: string;\n formatString: string;\n type: TableColumnFormatType;\n};\n\nexport class TableColumnFormatter<T = unknown> {\n static TYPE_GLOBAL: TableColumnFormatType = 'type-global';\n\n static TYPE_CONTEXT_PRESET: TableColumnFormatType = 'type-context-preset';\n\n static TYPE_CONTEXT_CUSTOM: TableColumnFormatType = 'type-context-custom';\n\n /**\n * Validates format object\n * @param format Format object\n * @returns true for valid object\n */\n static isValid(format: TableColumnFormat): boolean {\n return true;\n }\n\n /**\n * Check if the given formats match\n * @param formatA format object to check\n * @param formatB format object to check\n * @returns True if the formats match\n */\n static isSameFormat(\n formatA: TableColumnFormat | null,\n formatB: TableColumnFormat | null\n ): boolean {\n throw new Error('isSameFormat not implemented');\n }\n\n /**\n * Create and return a Format object\n * @param label The label of the format object\n * @param formatString Format string to use for the format\n * @param type The type of column to use for this format\n * @returns A format object\n */\n static makeFormat(\n label: string,\n formatString: string,\n type: TableColumnFormatType\n ): TableColumnFormat {\n return { label, formatString, type };\n }\n\n /**\n * @param value The value to format\n * @param format Optional format object with value transformation options\n * @returns String the formatted text string of the value passed in.\n */\n format(value: T, format?: Partial<TableColumnFormat>): string {\n return '';\n }\n}\n\nexport default TableColumnFormatter;\n","/* eslint class-methods-use-this: \"off\" */\n/* eslint no-unused-vars: \"off\" */\nimport TableColumnFormatter from './TableColumnFormatter';\n\n/** Column formatter for chars */\nclass BooleanColumnFormatter extends TableColumnFormatter<boolean | number> {\n format(value: boolean | number): string {\n switch (value) {\n case 1:\n case true:\n return 'true';\n case 0:\n case false:\n return 'false';\n default:\n return '';\n }\n }\n}\n\nexport default BooleanColumnFormatter;\n","/* eslint class-methods-use-this: \"off\" */\n/* eslint no-unused-vars: \"off\" */\nimport TableColumnFormatter from './TableColumnFormatter';\n\n/** Column formatter for chars */\nclass CharColumnFormatter extends TableColumnFormatter<number> {\n format(value: number): string {\n return String.fromCharCode(value);\n }\n}\n\nexport default CharColumnFormatter;\n","// The Deephaven API script isn't packaged as a module (yet), and is just included in index.html, exported to the global namespace\n// This include file is simply a wrapper so that it behaves like a module, and can be mocked easily for unit tests\nimport type dhType from '@deephaven/jsapi-types';\n\ndeclare global {\n // eslint-disable-next-line vars-on-top,no-var\n var dh: dhType;\n}\n\nconst { dh } = globalThis;\n\nexport default dh;\n","import PropTypes from 'prop-types';\n\nconst Column = PropTypes.shape({\n name: PropTypes.string.isRequired,\n type: PropTypes.string.isRequired,\n description: PropTypes.string,\n constituentType: PropTypes.string,\n});\n\nconst FilterCondition = PropTypes.shape({\n not: PropTypes.func.isRequired,\n and: PropTypes.func.isRequired,\n or: PropTypes.func.isRequired,\n});\n\nconst Sort = PropTypes.shape({\n asc: PropTypes.func.isRequired,\n desc: PropTypes.func.isRequired,\n abs: PropTypes.func.isRequired,\n column: Column.isRequired,\n direction: PropTypes.string.isRequired,\n isAbs: PropTypes.bool.isRequired,\n});\n\nconst Table = PropTypes.shape({\n columns: PropTypes.arrayOf(Column).isRequired,\n customColumns: PropTypes.arrayOf(PropTypes.string).isRequired,\n filter: PropTypes.arrayOf(FilterCondition),\n addEventListener: PropTypes.func.isRequired,\n removeEventListener: PropTypes.func.isRequired,\n size: PropTypes.number.isRequired,\n sort: PropTypes.arrayOf(PropTypes.any),\n copy: PropTypes.func.isRequired,\n applyFilter: PropTypes.func.isRequired,\n applySort: PropTypes.func.isRequired,\n applyCustomColumns: PropTypes.func.isRequired,\n description: PropTypes.string,\n});\n\nconst TreeTable = PropTypes.shape({\n columns: PropTypes.arrayOf(Column),\n filter: PropTypes.arrayOf(PropTypes.any),\n isExpanded: PropTypes.func.isRequired,\n saveExpandedState: PropTypes.func.isRequired,\n addEventListener: PropTypes.func.isRequired,\n removeEventListener: PropTypes.func.isRequired,\n size: PropTypes.number.isRequired,\n sort: PropTypes.arrayOf(PropTypes.any),\n applyFilter: PropTypes.func.isRequired,\n applySort: PropTypes.func.isRequired,\n});\n\nconst VariableDefinition = PropTypes.shape({\n name: PropTypes.string.isRequired,\n type: PropTypes.string.isRequired,\n});\n\nconst VariableChanges = PropTypes.shape({\n created: PropTypes.arrayOf(VariableDefinition).isRequired,\n updated: PropTypes.arrayOf(VariableDefinition).isRequired,\n removed: PropTypes.arrayOf(VariableDefinition).isRequired,\n});\n\nconst RollupConfig = PropTypes.shape({\n groupingColumns: PropTypes.arrayOf(PropTypes.string),\n aggregations: PropTypes.shape({}),\n includeConstituents: PropTypes.bool,\n includeOriginalColumns: PropTypes.bool,\n includeDescriptions: PropTypes.bool,\n});\n\nconst IdeSession = PropTypes.shape({\n addEventListener: PropTypes.func.isRequired,\n removeEventListener: PropTypes.func.isRequired,\n onLogMessage: PropTypes.func,\n getTable: PropTypes.func.isRequired,\n runCode: PropTypes.func.isRequired,\n});\n\nconst DhPropTypes = Object.freeze({\n Column,\n FilterCondition,\n IdeSession,\n RollupConfig,\n Sort,\n Table,\n TreeTable,\n VariableChanges,\n VariableDefinition,\n});\n\nexport default DhPropTypes;\n","import type dh from './dh.types';\n\nexport * from './dh.types';\nexport default dh;\n","/* eslint class-methods-use-this: \"off\" */\nimport dh, { DateWrapper, TimeZone } from '@deephaven/jsapi-shim';\nimport Log from '@deephaven/log';\nimport TableColumnFormatter, {\n TableColumnFormat,\n} from './TableColumnFormatter';\n\nconst log = Log.module('DateTimeColumnFormatter');\n\nexport type DateTimeColumnFormatterOptions = {\n // Time zone\n timeZone?: string;\n\n // Show time zone in DateTime values\n showTimeZone?: boolean;\n\n // Show 'T' separator in DateTime values\n showTSeparator?: boolean;\n\n // DateTime format to use if columnFormats for DateTime isn't set\n defaultDateTimeFormatString?: string;\n};\n\nexport class DateTimeColumnFormatter extends TableColumnFormatter<\n Date | DateWrapper | number\n> {\n /**\n * Validates format object\n * @param format Format object\n * @returns true for valid object\n */\n static isValid(format: Pick<TableColumnFormat, 'formatString'>): boolean {\n try {\n dh.i18n.DateTimeFormat.format(format.formatString, new Date());\n return true;\n } catch (e) {\n return false;\n }\n }\n\n static makeFormat(\n label: string,\n formatString: string,\n type = TableColumnFormatter.TYPE_CONTEXT_PRESET\n ): TableColumnFormat {\n return {\n label,\n formatString,\n type,\n };\n }\n\n /**\n * Check if the given formats match\n * @param formatA format object to check\n * @param formatB format object to check\n * @returns True if the formats match\n */\n static isSameFormat(\n formatA: TableColumnFormat | null,\n formatB: TableColumnFormat | null\n ): boolean {\n return (\n formatA === formatB ||\n (formatA !== null &&\n formatB !== null &&\n formatA.type === formatB.type &&\n formatA.formatString === formatB.formatString)\n );\n }\n\n static DEFAULT_DATETIME_FORMAT_STRING = 'yyyy-MM-dd HH:mm:ss.SSS';\n\n static DEFAULT_TIME_ZONE_ID = 'America/New_York';\n\n static makeGlobalFormatStringMap(\n showTimeZone: boolean,\n showTSeparator: boolean\n ): Map<string, string> {\n const separator = showTSeparator ? `'T'` : ' ';\n const tz = showTimeZone ? ' z' : '';\n return new Map([\n ['yyyy-MM-dd HH:mm:ss', `yyyy-MM-dd${separator}HH:mm:ss${tz}`],\n ['yyyy-MM-dd HH:mm:ss.SSS', `yyyy-MM-dd${separator}HH:mm:ss.SSS${tz}`],\n [\n 'yyyy-MM-dd HH:mm:ss.SSSSSSSSS',\n `yyyy-MM-dd${separator}HH:mm:ss.SSSSSSSSS${tz}`,\n ],\n ]);\n }\n\n static getGlobalFormats(\n showTimeZone: boolean,\n showTSeparator: boolean\n ): string[] {\n const formatStringMap = DateTimeColumnFormatter.makeGlobalFormatStringMap(\n showTimeZone,\n showTSeparator\n );\n return [...formatStringMap.keys()];\n }\n\n static makeFormatStringMap(\n showTimeZone?: boolean,\n showTSeparator?: boolean\n ): Map<string, string> {\n const separator =\n showTSeparator !== undefined && showTSeparator ? `'T'` : ' ';\n const tz = showTimeZone !== undefined && showTimeZone ? ' z' : '';\n return new Map([\n ['yyyy-MM-dd', `yyyy-MM-dd${tz}`],\n ['MM-dd-yyyy', `MM-dd-yyyy${tz}`],\n ['HH:mm:ss', `HH:mm:ss${tz}`],\n ['HH:mm:ss.SSS', `HH:mm:ss.SSS${tz}`],\n ['HH:mm:ss.SSSSSSSSS', `HH:mm:ss.SSSSSSSSS${tz}`],\n ['yyyy-MM-dd HH:mm:ss', `yyyy-MM-dd${separator}HH:mm:ss${tz}`],\n ['yyyy-MM-dd HH:mm:ss.SSS', `yyyy-MM-dd${separator}HH:mm:ss.SSS${tz}`],\n [\n 'yyyy-MM-dd HH:mm:ss.SSSSSSSSS',\n `yyyy-MM-dd${separator}HH:mm:ss.SSSSSSSSS${tz}`,\n ],\n ]);\n }\n\n static getFormats(\n showTimeZone?: boolean,\n showTSeparator?: boolean\n ): string[] {\n const formatStringMap = DateTimeColumnFormatter.makeFormatStringMap(\n showTimeZone,\n showTSeparator\n );\n return [...formatStringMap.keys()];\n }\n\n dhTimeZone: TimeZone;\n\n defaultDateTimeFormatString: string;\n\n showTimeZone: boolean;\n\n showTSeparator: boolean;\n\n formatStringMap: Map<string, string>;\n\n constructor({\n timeZone: timeZoneParam = '',\n showTimeZone = true,\n showTSeparator = false,\n defaultDateTimeFormatString = DateTimeColumnFormatter.DEFAULT_DATETIME_FORMAT_STRING,\n }: DateTimeColumnFormatterOptions = {}) {\n super();\n\n const timeZone =\n timeZoneParam || DateTimeColumnFormatter.DEFAULT_TIME_ZONE_ID;\n\n try {\n this.dhTimeZone = dh.i18n.TimeZone.getTimeZone(timeZone);\n } catch (e) {\n log.error('Unsupported time zone id', timeZone);\n this.dhTimeZone = dh.i18n.TimeZone.getTimeZone(\n DateTimeColumnFormatter.DEFAULT_TIME_ZONE_ID\n );\n }\n\n this.defaultDateTimeFormatString = defaultDateTimeFormatString;\n this.showTimeZone = showTimeZone;\n this.showTSeparator = showTSeparator;\n this.formatStringMap = DateTimeColumnFormatter.makeFormatStringMap(\n showTimeZone,\n showTSeparator\n );\n }\n\n getEffectiveFormatString(baseFormatString: string): string {\n return this.formatStringMap.get(baseFormatString) ?? baseFormatString;\n }\n\n format(\n value: Date | DateWrapper | number,\n format: Partial<TableColumnFormat> = {}\n ): string {\n const baseFormatString =\n format.formatString != null && format.formatString !== ''\n ? format.formatString\n : this.defaultDateTimeFormatString;\n const formatString = this.getEffectiveFormatString(baseFormatString);\n try {\n return dh.i18n.DateTimeFormat.format(\n formatString,\n value,\n this.dhTimeZone\n );\n } catch (e) {\n log.error('Invalid format arguments');\n }\n return '';\n }\n}\n\nexport default DateTimeColumnFormatter;\n","/* eslint class-methods-use-this: \"off\" */\nimport dh from '@deephaven/jsapi-shim';\nimport Log from '@deephaven/log';\nimport TableColumnFormatter, {\n TableColumnFormat,\n} from './TableColumnFormatter';\n\nconst log = Log.module('DecimalColumnFormatter');\n\nexport type DecimalColumnFormat = TableColumnFormat & {\n multiplier?: number;\n};\n\nexport type DecimalColumnFormatterOptions = {\n // Default format string to use. Defaults to DecimalColumnFormatter.DEFAULT_FORMAT_STRING\n defaultFormatString?: string;\n};\n\nexport class DecimalColumnFormatter extends TableColumnFormatter<number> {\n /**\n * Validates format object\n * @param format Format object\n * @returns true for valid object\n */\n static isValid(format: Pick<TableColumnFormat, 'formatString'>): boolean {\n try {\n dh.i18n.NumberFormat.format(format.formatString, 0);\n return true;\n } catch (e) {\n return false;\n }\n }\n\n /**\n * Create a DecimalColumnFormat object with the parameters specified\n * @param label Label for the format\n * @param formatString Format string for the format\n * @param multiplier Optional multiplier for the formatter\n * @param type Type of format created\n * @returns DecimalColumnFormat object\n */\n static makeFormat(\n label: string,\n formatString: string,\n type = TableColumnFormatter.TYPE_CONTEXT_PRESET,\n multiplier?: number\n ): DecimalColumnFormat {\n return {\n label,\n type,\n formatString,\n multiplier,\n };\n }\n\n /**\n * Convenient function to create a DecimalFormatObject with Preset type set\n * @param label Label for this format object\n * @param formatString Format string to use\n * @param multiplier Multiplier to use\n * @returns DecimalColumnFormat object\n */\n static makePresetFormat(\n label: string,\n formatString = '',\n multiplier?: number\n ): DecimalColumnFormat {\n return DecimalColumnFormatter.makeFormat(\n label,\n formatString,\n TableColumnFormatter.TYPE_CONTEXT_PRESET,\n multiplier\n );\n }\n\n /**\n * Convenient function to create a DecimalFormatObject with a default 'Custom Format' label and Custom type\n * @param formatString Format string to use\n * @param multiplier Multiplier to use\n * @returns DecimalColumnFormat object\n */\n static makeCustomFormat(\n formatString = '',\n multiplier?: number\n ): DecimalColumnFormat {\n return DecimalColumnFormatter.makeFormat(\n 'Custom Format',\n formatString,\n TableColumnFormatter.TYPE_CONTEXT_CUSTOM,\n multiplier\n );\n }\n\n static DEFAULT_FORMAT_STRING = '###,##0.0000';\n\n static FORMAT_PERCENT = DecimalColumnFormatter.makePresetFormat(\n 'Percent',\n '##0.00%'\n );\n\n static FORMAT_BASIS_POINTS = DecimalColumnFormatter.makePresetFormat(\n 'Basis Points',\n '###,##0 bp',\n 10000\n );\n\n static FORMAT_MILLIONS = DecimalColumnFormatter.makePresetFormat(\n 'Millions',\n '###,##0.000 mm',\n 0.000001\n );\n\n static FORMAT_SCIENTIFIC_NOTATION = DecimalColumnFormatter.makePresetFormat(\n 'Scientific Notation',\n '0.0000E0'\n );\n\n static FORMAT_ROUND = DecimalColumnFormatter.makePresetFormat(\n 'Round',\n '###,##0'\n );\n\n static FORMAT_ROUND_TWO_DECIMALS = DecimalColumnFormatter.makePresetFormat(\n '0.00',\n '###,##0.00'\n );\n\n static FORMAT_ROUND_FOUR_DECIMALS = DecimalColumnFormatter.makePresetFormat(\n '0.0000',\n '###,##0.0000'\n );\n\n /**\n * Check if the given formats match\n * @param formatA format object to check\n * @param formatB format object to check\n * @returns True if the formats match\n */\n static isSameFormat(\n formatA: DecimalColumnFormat | null,\n formatB: DecimalColumnFormat | null\n ): boolean {\n return (\n formatA === formatB ||\n (formatA != null &&\n formatB != null &&\n formatA.type === formatB.type &&\n formatA.formatString === formatB.formatString &&\n formatA.multiplier === formatB.multiplier)\n );\n }\n\n defaultFormatString: string;\n\n constructor({\n defaultFormatString = DecimalColumnFormatter.DEFAULT_FORMAT_STRING,\n }: DecimalColumnFormatterOptions = {}) {\n super();\n\n this.defaultFormatString = defaultFormatString;\n }\n\n /**\n * Format a value with the provided format object\n * @param valueParam Value to format\n * @param format Format object\n * @returns Formatted string\n */\n format(\n valueParam: number,\n format: Partial<DecimalColumnFormat> = {}\n ): string {\n const formatString =\n format.formatString != null && format.formatString !== ''\n ? format.formatString\n : this.defaultFormatString;\n const value =\n format.multiplier !== undefined && format.multiplier !== 0\n ? valueParam * format.multiplier\n : valueParam;\n try {\n return dh.i18n.NumberFormat.format(formatString, value);\n } catch (e) {\n log.error('Invalid format arguments');\n }\n return '';\n }\n}\n\nexport default DecimalColumnFormatter;\n","/* eslint class-methods-use-this: \"off\" */\n/* eslint no-unused-vars: \"off\" */\nimport TableColumnFormatter from './TableColumnFormatter';\n\nclass DefaultColumnFormatter extends TableColumnFormatter {\n format(value: unknown): string {\n return `${value}`;\n }\n}\n\nexport default DefaultColumnFormatter;\n","/* eslint class-methods-use-this: \"off\" */\nimport dh from '@deephaven/jsapi-shim';\nimport Log from '@deephaven/log';\nimport TableColumnFormatter, {\n TableColumnFormat,\n} from './TableColumnFormatter';\n\nconst log = Log.module('IntegerColumnFormatter');\n\nexport type IntegerColumnFormat = TableColumnFormat & {\n multiplier?: number;\n};\n\nexport type IntegerColumnFormatterOptions = {\n // Default format string to use. Defaults to IntegerColumnFormatter.DEFAULT_FORMAT_STRING\n defaultFormatString?: string;\n};\n\n/** Column formatter for integers/whole numbers */\nexport class IntegerColumnFormatter extends TableColumnFormatter<number> {\n /**\n * Validates format object\n * @param format Format object\n * @returns true for valid object\n */\n static isValid(format: Pick<TableColumnFormat, 'formatString'>): boolean {\n try {\n dh.i18n.NumberFormat.format(format.formatString, 0);\n return true;\n } catch (e) {\n return false;\n }\n }\n\n /**\n * Create an IntegerColumnFormat object with the parameters specified\n * @param label Label for the format\n * @param formatString Format string for the format\n * @param multiplier Optional multiplier for the formatter\n * @param type Type of format created\n * @returns IntegerColumnFormat object\n */\n static makeFormat(\n label: string,\n formatString: string,\n type = TableColumnFormatter.TYPE_CONTEXT_PRESET,\n multiplier?: number\n ): IntegerColumnFormat {\n return {\n label,\n type,\n formatString,\n multiplier,\n };\n }\n\n /**\n * Convenient function to create a IntegerFormatObject with Preset type set\n * @param label Label for this format object\n * @param formatString Format string to use\n * @param multiplier Multiplier to use\n * @returns IntegerColumnFormat object\n */\n static makePresetFormat(\n label: string,\n formatString = '',\n multiplier?: number\n ): IntegerColumnFormat {\n return IntegerColumnFormatter.makeFormat(\n label,\n formatString,\n TableColumnFormatter.TYPE_CONTEXT_PRESET,\n multiplier\n );\n }\n\n /**\n * Convenient function to create a IntegerFormatObject with a default 'Custom Format' label and Custom type\n * @param formatString Format string to use\n * @param multiplier Multiplier to use\n * @returns IntegerColumnFormat object\n */\n static makeCustomFormat(\n formatString = '',\n multiplier?: number\n ): IntegerColumnFormat {\n return IntegerColumnFormatter.makeFormat(\n 'Custom Format',\n formatString,\n TableColumnFormatter.TYPE_CONTEXT_CUSTOM,\n multiplier\n );\n }\n\n /**\n * Check if the given formats match\n * @param formatA format object to check\n * @param formatB format object to check\n * @returns True if the formats match\n */\n static isSameFormat(\n formatA: IntegerColumnFormat | null,\n formatB: IntegerColumnFormat | null\n ): boolean {\n return (\n formatA === formatB ||\n (formatA != null &&\n formatB != null &&\n formatA.type === formatB.type &&\n formatA.formatString === formatB.formatString &&\n formatA.multiplier === formatB.multiplier)\n );\n }\n\n static DEFAULT_FORMAT_STRING = '###,##0';\n\n static FORMAT_MILLIONS = IntegerColumnFormatter.makePresetFormat(\n 'Millions',\n '###,##0.000 mm',\n 0.000001\n );\n\n static FORMAT_SCIENTIFIC_NOTATION = IntegerColumnFormatter.makePresetFormat(\n 'Scientific Notation',\n '0.0000E0'\n );\n\n defaultFormatString: string;\n\n constructor({\n defaultFormatString = IntegerColumnFormatter.DEFAULT_FORMAT_STRING,\n }: IntegerColumnFormatterOptions = {}) {\n super();\n\n this.defaultFormatString = defaultFormatString;\n }\n\n /**\n * Format a value with the provided format object\n * @param valueParam Value to format\n * @param format Format object\n * @returns Formatted string\n */\n format(\n valueParam: number,\n format: Partial<IntegerColumnFormat> = {}\n ): string {\n const formatString =\n format.formatString != null && format.formatString !== ''\n ? format.formatString\n : this.defaultFormatString;\n const value =\n format.multiplier !== undefined && format.multiplier !== 0\n ? valueParam * format.multiplier\n : valueParam;\n try {\n return dh.i18n.NumberFormat.format(formatString, value);\n } catch (e) {\n log.error('Invalid format arguments');\n }\n return '';\n }\n}\n\nexport default IntegerColumnFormatter;\n","/* eslint class-methods-use-this: \"off\" */\nimport TableColumnFormatter from './TableColumnFormatter';\n\n/** Column formatter for strings */\nexport class StringColumnFormatter extends TableColumnFormatter<string> {\n format(value: string): string {\n return value;\n }\n}\n\nexport default StringColumnFormatter;\n","import dh from '@deephaven/jsapi-shim';\nimport type { DateWrapper } from '@deephaven/jsapi-shim';\n\ninterface DateParts<T> {\n year: T;\n month: T;\n date: T;\n hours: T;\n minutes: T;\n seconds: T;\n nanos: T;\n}\n\nexport class DateUtils {\n static FULL_DATE_FORMAT = 'yyyy-MM-dd HH:mm:ss.SSSSSSSSS';\n\n static months = [\n 'january',\n 'february',\n 'march',\n 'april',\n 'may',\n 'june',\n 'july',\n 'august',\n 'september',\n 'october',\n 'november',\n 'december',\n ];\n\n /**\n *\n * @param timeZone The time zone to parse this time in. E.g. America/New_York\n * @param year The year for the date\n * @param month The month, starting at 0\n * @param day The day, starting at 1\n * @param hour The hours\n * @param minute The minutes\n * @param second The seconds\n * @param ns The nanoseconds\n */\n static makeDateWrapper(\n timeZone: string,\n year: number,\n month = 0,\n day = 1,\n hour = 0,\n minute = 0,\n second = 0,\n ns = 0\n ): DateWrapper {\n if (!timeZone) {\n throw new Error('No timezone provided');\n }\n const yearString = `${year}`.padStart(4, '0');\n const monthString = `${month + 1}`.padStart(2, '0');\n const dayString = `${day}`.padStart(2, '0');\n const hourString = `${hour}`.padStart(2, '0');\n const minuteString = `${minute}`.padStart(2, '0');\n const secondString = `${second}`.padStart(2, '0');\n const nanoString = `${ns}`.padStart(9, '0');\n\n const dateString = `${yearString}-${monthString}-${dayString} ${hourString}:${minuteString}:${secondString}.${nanoString}`;\n return dh.i18n.DateTimeFormat.parse(\n DateUtils.FULL_DATE_FORMAT,\n dateString,\n dh.i18n.TimeZone.getTimeZone(timeZone)\n );\n }\n\n /**\n * Takes the string the user entered and returns the next nanos value\n * @param nanoString The nano string to get the next one of\n * @returns The value of the next nanos\n */\n static getNextNanos(nanoString: string): number {\n const sigNanos = parseInt(nanoString, 10);\n // Get the zeroes needed for padding before adding one so we handle overflow properly.\n const zeros = '0'.repeat(9 - nanoString.length);\n const nextNanoString = `${sigNanos + 1}${zeros}`;\n return parseInt(nextNanoString, 10);\n }\n\n /**\n * @param components The string components that were parsed from the original string\n * @param values The values that were parsed from the components\n * @param timeZone The time zone to parse the date in. E.g. America/New_York\n * @returns Returns the DateWrapper for the next date, or null if a full date was passed in\n */\n static getNextDate(\n components: DateParts<string>,\n values: DateParts<number>,\n timeZone: string\n ): DateWrapper | null {\n let { year, month, date, hours, minutes, seconds, nanos } = values;\n\n if (components.nanos != null) {\n if (components.nanos.length === 9) {\n // They want an exact match\n return null;\n }\n nanos = DateUtils.getNextNanos(components.nanos);\n if (nanos > 999999999) {\n // There's an overflow, add it to the seconds manually\n seconds += 1;\n nanos = 0;\n }\n } else if (components.seconds != null) {\n seconds += 1;\n } else if (components.minutes != null) {\n minutes += 1;\n } else if (components.hours != null) {\n hours += 1;\n } else if (components.date != null) {\n date += 1;\n } else if (components.month != null) {\n month += 1;\n } else {\n year += 1;\n }\n\n // Use the JS date to handle overflow rather than doing our own logic\n // Because handling leap years and stuff is a pain\n // Still need to add nanos after, and the overflow from that is already added to seconds above\n const jsDate = new Date(year, month, date, hours, minutes, seconds);\n return DateUtils.makeDateWrapper(\n timeZone,\n jsDate.getFullYear(),\n jsDate.getMonth(),\n jsDate.getDate(),\n jsDate.getHours(),\n jsDate.getMinutes(),\n jsDate.getSeconds(),\n nanos\n );\n }\n\n /**\n * Get the JS month value for the provided string.\n * Matches digits or a month name (eg. '1', '01', 'jan', 'january' should all work)\n * @param monthString The string to parse to a JS month value\n * @returns number The JS month value, which starts at 0 for january, or NaN if nothing could be parsed\n */\n static parseMonth(monthString: string): number {\n const month = parseInt(monthString, 10);\n if (!Number.isNaN(month)) {\n if (month >= 1 && month <= 12) {\n return month - 1;\n }\n return NaN;\n }\n\n const cleanMonthString = monthString.trim().toLowerCase();\n if (cleanMonthString.length >= 3) {\n for (let i = 0; i < DateUtils.months.length; i += 1) {\n if (DateUtils.months[i].startsWith(cleanMonthString)) {\n return i;\n }\n }\n }\n\n return NaN;\n }\n\n /**\n * Parse a date object out of the provided string segments.\n * Also using `parseMonth` to get month names like Aug/August rather than\n * simply doing `parseInt`.\n * @param yearString The year part of the string\n * @param monthString The month part of the string\n * @param dayString The day part of the string\n * @param hourString The hour part of the string\n * @param minuteString The minute part of the string\n * @param secondString The second part of the string\n * @param nanoString The milli part of the string\n */\n static parseDateValues(\n yearString: string,\n monthString: string,\n dayString: string,\n hourString: string,\n minuteString: string,\n secondString: string,\n nanoString: string\n ): DateParts<number> | null {\n const year = parseInt(yearString, 10);\n const month = monthString != null ? this.parseMonth(monthString) : 0;\n const date = dayString != null ? parseInt(dayString, 10) : 1;\n const hours = hourString != null ? parseInt(hourString, 10) : 0;\n const minutes = minuteString != null ? parseInt(minuteString, 10) : 0;\n const seconds = secondString != null ? parseInt(secondString, 10) : 0;\n const nanos =\n nanoString != null ? parseInt(nanoString.padEnd(9, '0'), 10) : 0;\n if (\n Number.isNaN(year) ||\n Number.isNaN(month) ||\n Number.isNaN(date) ||\n Number.isNaN(hours) ||\n Number.isNaN(minutes) ||\n Number.isNaN(seconds) ||\n Number.isNaN(nanos)\n ) {\n return null;\n }\n\n return { year, month, date, hours, minutes, seconds, nanos };\n }\n\n /**\n * Parse out a date time string into it's string components.\n * Anything that is not captured in the string will be undefined.\n *\n * @param dateTimeString The date time string to parse\n * @returns Containing the date time components\n */\n static parseDateTimeString(dateTimeString: string): DateParts<string> {\n const regex = /\\s*(\\d{4})([-./]([\\da-z]+))?([-./](\\d{1,2}))?([tT\\s](\\d{2})([:](\\d{2}))?([:](\\d{2}))?([.](\\d{1,9}))?)?(.*)/;\n const result = regex.exec(dateTimeString);\n if (result == null) {\n throw new Error(`Unexpected date string: ${dateTimeString}`);\n }\n\n const [\n ,\n year,\n ,\n month,\n ,\n date,\n ,\n hours,\n ,\n minutes,\n ,\n seconds,\n ,\n nanos,\n overflow,\n ] = result;\n if (overflow != null && overflow.length > 0) {\n throw new Error(\n `Unexpected characters after date string '${dateTimeString}': ${overflow}`\n );\n }\n\n return { year, month, date, hours, minutes, seconds, nanos };\n }\n\n /**\n * Parses the date range provided from a string of text.\n * @param text The string to parse the date from. Can be a keyword like \"today\", or in the format \"2018-08-04\"\n * @param timeZone The time zone to parse this range in. E.g. America/New_York\n * @returns A tuple with the start and end value/null for that date range, or both null\n */\n static parseDateRange(\n text: string,\n timeZone: string\n ): [DateWrapper, DateWrapper | null] | [null, null] {\n const cleanText = text.trim().toLowerCase();\n if (cleanText.length === 0) {\n throw new Error('Cannot parse date range from empty string');\n }\n\n if (cleanText === 'null') {\n return [null, null];\n }\n\n if (cleanText === 'today') {\n const now = new Date(Date.now());\n const startDate = DateUtils.makeDateWrapper(\n timeZone,\n now.getFullYear(),\n now.getMonth(),\n now.getDate()\n );\n const endDate = DateUtils.makeDateWrapper(\n timeZone,\n now.getFullYear(),\n now.getMonth(),\n now.getDate() + 1\n );\n return [startDate, endDate];\n }\n\n if (cleanText === 'yesterday') {\n const now = new Date(Date.now());\n const startDate = DateUtils.makeDateWrapper(\n timeZone,\n now.getFullYear(),\n now.getMonth(),\n now.getDate() - 1\n );\n const endDate = DateUtils.makeDateWrapper(\n timeZone,\n now.getFullYear(),\n now.getMonth(),\n now.getDate()\n );\n return [startDate, endDate];\n }\n\n if (cleanText === 'now') {\n const now = new Date(Date.now());\n const date = dh.DateWrapper.ofJsDate(now);\n return [date, null];\n }\n\n const components = DateUtils.parseDateTimeString(cleanText);\n if (\n components.year == null &&\n components.month == null &&\n components.date == null\n ) {\n throw new Error(`Unable to extract year, month, or day ${cleanText}`);\n }\n\n const values = DateUtils.parseDateValues(\n components.year,\n components.month,\n components.date,\n components.hours,\n components.minutes,\n components.seconds,\n components.nanos\n );\n\n if (values == null) {\n throw new Error(`Unable to extract date values from ${components}`);\n }\n\n const startDate = DateUtils.makeDateWrapper(\n timeZone,\n values.year,\n values.month,\n values.date,\n values.hours,\n values.minutes,\n values.seconds,\n values.nanos\n );\n\n const endDate = DateUtils.getNextDate(components, values, timeZone);\n return [startDate, endDate];\n }\n\n /**\n * Gets the Js Date object from the provided DateWrapper.\n * In unit test, DateWrapper is just a number provided in millis, so handles that case.\n * @param dateWrapper The DateWrapper object, or time in millis\n */\n static getJsDate(dateWrapper: DateWrapper | number): Date {\n if (typeof dateWrapper === 'number') {\n return new Date(dateWrapper);\n }\n return dateWrapper.asDate();\n }\n}\n\nexport default DateUtils;\n","export class Operator {\n static readonly not = 'not';\n\n static readonly and = 'and';\n\n static readonly or = 'or';\n}\n\nexport type OperatorValue = typeof Operator[Exclude<\n keyof typeof Operator,\n 'prototype'\n>];\n\nexport function assertOperatorValue(\n operator?: string\n): asserts operator is OperatorValue {\n if (!(operator === 'not' || operator === 'and' || operator === 'or')) {\n throw new Error('operator is not a valid FilterOperatorValue');\n }\n}\n","/** Different filter conditions user can select */\nexport class Type {\n static readonly eq = 'eq';\n\n static readonly eqIgnoreCase = 'eqIgnoreCase';\n\n static readonly notEq = 'notEq';\n\n static readonly notEqIgnoreCase = 'notEqIgnoreCase';\n\n static readonly greaterThan = 'greaterThan';\n\n static readonly greaterThanOrEqualTo = 'greaterThanOrEqualTo';\n\n static readonly lessThan = 'lessThan';\n\n static readonly lessThanOrEqualTo = 'lessThanOrEqualTo';\n\n static readonly in = 'in';\n\n static readonly inIgnoreCase = 'inIgnoreCase';\n\n static readonly notIn = 'notIn';\n\n static readonly notInIgnoreCase = 'notInIgnoreCase';\n\n static readonly isTrue = 'isTrue';\n\n static readonly isFalse = 'isFalse';\n\n static readonly isNull = 'isNull';\n\n static readonly invoke = 'invoke';\n\n static readonly contains = 'contains';\n\n static readonly notContains = 'notContains';\n\n static readonly startsWith = 'startsWith';\n\n static readonly endsWith = 'endsWith';\n\n static readonly containsAny = 'containsAny';\n}\n\nexport type TypeValue = typeof Type[Exclude<keyof typeof Type, 'prototype'>];\n","import {\n Type as FilterType,\n Operator as FilterOperator,\n TypeValue as FilterTypeValue,\n OperatorValue as FilterOperatorValue,\n} from '@deephaven/filters';\nimport Log from '@deephaven/log';\nimport dh, {\n Column,\n FilterCondition,\n FilterValue,\n LongWrapper,\n RemoverFn,\n Sort,\n Table,\n TreeTable,\n} from '@deephaven/jsapi-shim';\nimport {\n CancelablePromise,\n PromiseUtils,\n TextUtils,\n TimeoutError,\n} from '@deephaven/utils';\nimport DateUtils from './DateUtils';\nimport { ColumnName } from './Formatter';\n\nconst log = Log.module('TableUtils');\n\ntype Values<T> = T[keyof T];\nexport type DataType = Values<typeof TableUtils.dataType>;\nexport type SortDirection = Values<typeof TableUtils.sortDirection>;\nexport type ReverseType = Values<typeof TableUtils.REVERSE_TYPE>;\nexport type AdvancedFilterItemType = {\n selectedType: FilterTypeValue;\n value: string;\n};\n\nexport interface FilterItem {\n selectedType: FilterTypeValue;\n value: string;\n}\n\nexport type AdvancedFilterOptions = {\n filterItems: FilterItem[];\n filterOperators: FilterOperatorValue[];\n invertSelection: boolean;\n selectedValues: unknown[];\n};\n\nexport type RowDataMapValue = {\n type: string;\n text: string;\n value: unknown;\n isExpandable: boolean;\n isGrouped: boolean;\n visibleIndex: number;\n};\n\nexport type RowDataMap = Record<ColumnName, RowDataMapValue>;\n\n/** Utility class to provide some functions for working with tables */\nexport class TableUtils {\n static dataType = {\n BOOLEAN: 'boolean',\n CHAR: 'char',\n DATETIME: 'datetime',\n DECIMAL: 'decimal',\n INT: 'int',\n STRING: 'string',\n UNKNOWN: 'unknown',\n } as const;\n\n static sortDirection = {\n ascending: 'ASC',\n descending: 'DESC',\n reverse: 'REVERSE',\n none: null,\n } as const;\n\n static REVERSE_TYPE = Object.freeze({\n NONE: 'none',\n PRE_SORT: 'pre-sort',\n POST_SORT: 'post-sort',\n } as const);\n\n // Regex looking for a negative or positive integer or decimal number\n static NUMBER_REGEX = /^-?\\d+(\\.\\d+)?$/;\n\n static getSortIndex(\n sort: readonly Sort[],\n columnIndex: number\n ): number | null {\n for (let i = 0; i < sort.length; i += 1) {\n const s = sort[i];\n if (s.column?.index === columnIndex) {\n return i;\n }\n }\n\n return null;\n }\n\n /**\n * @param tableSort The sorts from the table to get the sort from\n * @param columnIndex The index of the column to get the sort for\n * @returns The sort for the column, or null if it's not sorted\n */\n static getSortForColumn(\n tableSort: readonly Sort[],\n columnIndex: number\n ): Sort | null {\n const sortIndex = TableUtils.getSortIndex(tableSort, columnIndex);\n if (sortIndex != null) {\n return tableSort[sortIndex];\n }\n return null;\n }\n\n static getFilterText(filter?: FilterCondition | null): string | null {\n if (filter) {\n return filter.toString();\n }\n return null;\n }\n\n /** Return the valid filter types for the column */\n static getFilterTypes(columnType: string): FilterTypeValue[] {\n if (TableUtils.isBooleanType(columnType)) {\n return [FilterType.isTrue, FilterType.isFalse, FilterType.isNull];\n }\n if (\n TableUtils.isCharType(columnType) ||\n TableUtils.isNumberType(columnType) ||\n TableUtils.isDateType(columnType)\n ) {\n return [\n FilterType.eq,\n FilterType.notEq,\n FilterType.greaterThan,\n FilterType.greaterThanOrEqualTo,\n FilterType.lessThan,\n FilterType.lessThanOrEqualTo,\n ];\n }\n if (TableUtils.isTextType(columnType)) {\n return [\n FilterType.eq,\n FilterType.eqIgnoreCase,\n FilterType.notEq,\n FilterType.notEqIgnoreCase,\n FilterType.contains,\n FilterType.notContains,\n FilterType.startsWith,\n FilterType.endsWith,\n ];\n }\n return [];\n }\n\n static getNextSort(\n columns: readonly Column[],\n sorts: readonly Sort[],\n columnIndex: number\n ): Sort | null {\n if (columns == null || columnIndex < 0 || columnIndex >= columns.length) {\n return null;\n }\n\n const sort = TableUtils.getSortForColumn(sorts, columnIndex);\n if (sort === null) {\n return columns[columnIndex].sort().asc();\n }\n if (sort.direction === TableUtils.sortDirection.ascending) {\n return sort.desc();\n }\n return null;\n }\n\n static makeColumnSort(\n columns: readonly Column[],\n columnIndex: number,\n direction: SortDirection,\n isAbs: boolean\n ): Sort | null {\n if (columns == null || columnIndex < 0 || columnIndex >= columns.length) {\n return null;\n }\n\n if (direction === TableUtils.sortDirection.none) {\n return null;\n }\n\n let sort = columns[columnIndex].sort();\n\n switch (direction) {\n case TableUtils.sortDirection.ascending:\n sort = sort.asc();\n break;\n case TableUtils.sortDirection.descending:\n sort = sort.desc();\n break;\n default:\n break;\n }\n if (isAbs) {\n sort = sort.abs();\n }\n return sort;\n }\n\n /**\n * Toggles the sort for the specified column\n * @param sorts The current sorts from IrisGrid.state\n * @param columns The columns to apply the sort to\n * @param columnIndex The column index to apply the sort to\n * @param addToExisting Add this sort to the existing sort\n */\n static toggleSortForColumn(\n sorts: readonly Sort[],\n columns: readonly Column[],\n columnIndex: number,\n addToExisting = false\n ): Sort[] {\n if (columnIndex < 0 || columnIndex >= columns.length) {\n return [];\n }\n\n const newSort = TableUtils.getNextSort(columns, sorts, columnIndex);\n\n return TableUtils.setSortForColumn(\n sorts,\n columnIndex,\n newSort,\n addToExisting\n );\n }\n\n static sortColumn(\n sorts: readonly Sort[],\n columns: readonly Column[],\n modelColumn: number,\n direction: SortDirection,\n isAbs: boolean,\n addToExisting: boolean\n ): Sort[] {\n if (sorts == null || modelColumn < 0 || modelColumn >= columns.length) {\n return [];\n }\n\n const newSort = TableUtils.makeColumnSort(\n columns,\n modelColumn,\n direction,\n isAbs\n );\n\n return TableUtils.setSortForColumn(\n sorts,\n modelColumn,\n newSort,\n addToExisting\n );\n }\n\n /**\n * Sets the sort for the given column *and* removes any reverses\n * @param tableSort The current sorts from IrisGrid.state\n * @param columnIndex The column index to apply the sort to\n * @param sort The sort object to add\n * @param addToExisting Add this sort to the existing sort\n * @returns Returns the modified array of sorts - removing reverses\n */\n static setSortForColumn(\n tableSort: readonly Sort[],\n columnIndex: number,\n sort: Sort | null,\n addToExisting = false\n ): Sort[] {\n const sortIndex = TableUtils.getSortIndex(tableSort, columnIndex);\n let sorts: Sort[] = [];\n if (addToExisting) {\n sorts = sorts.concat(\n tableSort.filter(\n ({ direction }) => direction !== TableUtils.sortDirection.reverse\n )\n );\n if (sortIndex !== null) {\n sorts.splice(sortIndex, 1);\n }\n }\n\n if (sort !== null) {\n sorts.push(sort);\n }\n\n return sorts;\n }\n\n static getNormalizedType(columnType?: string | null): DataType {\n switch (columnType) {\n case 'boolean':\n case 'java.lang.Boolean':\n case TableUtils.dataType.BOOLEAN:\n return TableUtils.dataType.BOOLEAN;\n case 'char':\n case 'java.lang.Character':\n case TableUtils.dataType.CHAR:\n return TableUtils.dataType.CHAR;\n case 'java.lang.String':\n case TableUtils.dataType.STRING:\n return TableUtils.dataType.STRING;\n case 'io.deephaven.db.tables.utils.DBDateTime':\n case 'io.deephaven.time.DateTime':\n case 'com.illumon.iris.db.tables.utils.DBDateTime':\n case TableUtils.dataType.DATETIME:\n return TableUtils.dataType.DATETIME;\n case 'double':\n case 'java.lang.Double':\n case 'float':\n case 'java.lang.Float':\n case 'java.math.BigDecimal':\n case TableUtils.dataType.DECIMAL:\n return TableUtils.dataType.DECIMAL;\n case 'int':\n case 'java.lang.Integer':\n case 'long':\n case 'java.lang.Long':\n case 'short':\n case 'java.lang.Short':\n case 'byte':\n case 'java.lang.Byte':\n case 'java.math.BigInteger':\n case TableUtils.dataType.INT:\n return TableUtils.dataType.INT;\n default:\n return TableUtils.dataType.UNKNOWN;\n }\n }\n\n static isLongType(columnType: string): boolean {\n switch (columnType) {\n case 'long':\n case 'java.lang.Long':\n return true;\n default:\n return false;\n }\n }\n\n static isDateType(columnType: string): boolean {\n switch (columnType) {\n case 'io.deephaven.db.tables.utils.DBDateTime':\n case 'io.deephaven.time.DateTime':\n case 'com.illumon.iris.db.tables.utils.DBDateTime':\n return true;\n default:\n return false;\n }\n }\n\n static isNumberType(columnType: string): boolean {\n return (\n TableUtils.isIntegerType(columnType) ||\n TableUtils.isDecimalType(columnType)\n );\n }\n\n static isIntegerType(columnType: string): boolean {\n switch (columnType) {\n case 'int':\n case 'java.lang.Integer':\n case 'java.math.BigInteger':\n case 'long':\n case 'java.lang.Long':\n case 'short':\n case 'java.lang.Short':\n case 'byte':\n case 'java.lang.Byte':\n return true;\n default:\n return false;\n }\n }\n\n static isDecimalType(columnType: string): boolean {\n switch (columnType) {\n case 'double':\n case 'java.lang.Double':\n case 'java.math.BigDecimal':\n case 'float':\n case 'java.lang.Float':\n return true;\n default:\n return false;\n }\n }\n\n static isBigDecimalType(columnType: string): boolean {\n switch (columnType) {\n case 'java.math.BigDecimal':\n return true;\n default:\n return false;\n }\n }\n\n static isBigIntegerType(columnType: string): boolean {\n switch (columnType) {\n case 'java.math.BigInteger':\n return true;\n default:\n return false;\n }\n }\n\n static isBooleanType(columnType: string): boolean {\n switch (columnType) {\n case 'boolean':\n case 'java.lang.Boolean':\n return true;\n default:\n return false;\n }\n }\n\n static isCharType(columnType: string): boolean {\n switch (columnType) {\n case 'char':\n case 'java.lang.Character':\n return true;\n default:\n return false;\n }\n }\n\n static isStringType(columnType: string): boolean {\n switch (columnType) {\n case 'java.lang.String':\n return true;\n default:\n return false;\n }\n }\n\n static isTextType(columnType: string): boolean {\n return this.isStringType(columnType) || this.isCharType(columnType);\n }\n\n /**\n * Get base column type\n * @param columnType Column type\n * @returns Element type for array columns, original type for non-array columns\n */\n static getBaseType(columnType: string): string {\n return columnType.split('[]')[0];\n }\n\n /**\n * Check if the column types are compatible\n * @param type1 Column type to check\n * @param type2 Column type to check\n * @returns True, if types are compatible\n */\n static isCompatibleType(\n type1?: string | null,\n type2?: string | null\n ): boolean {\n return (\n TableUtils.getNormalizedType(type1) ===\n TableUtils.getNormalizedType(type2)\n );\n }\n\n /**\n * Create filter with the provided column and text. Handles multiple filters joined with && or ||\n * @param column The column to set the filter on\n * @param text The text string to create the filter from\n * @param timeZone The time zone to make this value in if it is a date type. E.g. America/New_York\n * @returns Returns the created filter, null if text could not be parsed\n */\n static makeQuickFilter(\n column: Column,\n text: string,\n timeZone?: string\n ): FilterCondition | null {\n const orComponents = text.split('||');\n let orFilter = null;\n for (let i = 0; i < orComponents.length; i += 1) {\n const orComponent = orComponents[i];\n const andComponents = orComponent.split('&&');\n let andFilter = null;\n for (let j = 0; j < andComponents.length; j += 1) {\n const andComponent = andComponents[j].trim();\n if (andComponent.length > 0) {\n const filter = TableUtils.makeQuickFilterFromComponent(\n column,\n andComponent,\n timeZone\n );\n if (filter) {\n if (andFilter) {\n andFilter = andFilter.and(filter);\n } else {\n andFilter = filter;\n }\n } else {\n throw new Error(`Unable to parse quick filter from text ${text}`);\n }\n }\n }\n\n if (orFilter && andFilter) {\n orFilter = orFilter.or(andFilter);\n } else {\n orFilter = andFilter;\n }\n }\n\n return orFilter;\n }\n\n /**\n * Create filter with the provided column and text of one component (no multiple conditions)\n * @param column The column to set the filter on\n * @param text The text string to create the filter from\n * @param timeZone The time zone to make this filter in if it is a date type. E.g. America/New_York\n * @returns Returns the created filter, null if text could not be parsed\n */\n static makeQuickFilterFromComponent(\n column: Column,\n text: string,\n timeZone?: string\n ): FilterCondition | null {\n const { type } = column;\n if (TableUtils.isNumberType(type)) {\n return this.makeQuickNumberFilter(column, text);\n }\n if (TableUtils.isBooleanType(type)) {\n return this.makeQuickBooleanFilter(column, text);\n }\n if (timeZone != null && TableUtils.isDateType(type)) {\n return this.makeQuickDateFilter(column, text, timeZone);\n }\n if (TableUtils.isCharType(type)) {\n return this.makeQuickCharFilter(column, text);\n }\n return this.makeQuickTextFilter(column, text);\n }\n\n static makeQuickNumberFilter(\n column: Column,\n text: string\n ): FilterCondition | null {\n if (text == null) {\n return null;\n }\n\n const columnFilter = column.filter();\n let filter = null;\n\n const regex = /\\s*(>=|<=|=>|=<|>|<|!=|=|!)?(\\s*-\\s*)?(\\s*\\d*(?:,\\d{3})*(?:\\.\\d*)?\\s*)?(null|nan|infinity|inf|\\u221E)?(.*)/i;\n const result = regex.exec(text);\n\n let operation = null;\n let negativeSign = null;\n let value = null;\n let abnormalValue = null; // includes nan, null and infinity(positive & negative)\n let overflow = null;\n\n if (result !== null && result.length > 3) {\n [, operation, negativeSign, value, abnormalValue, overflow] = result;\n }\n\n if (overflow != null && overflow.trim().length > 0) {\n // Some bad characters after the number, bail out!\n return null;\n }\n\n if (operation == null) {\n operation = '=';\n }\n\n if (abnormalValue != null) {\n if (!(operation === '=' || operation === '!' || operation === '!=')) {\n // only equal and not equal operations are supported for abnormal value filter\n return null;\n }\n abnormalValue = abnormalValue.trim().toLowerCase();\n switch (abnormalValue) {\n case 'null':\n filter = columnFilter.isNull();\n break;\n case 'nan':\n filter = dh.FilterCondition.invoke('isNaN', columnFilter);\n break;\n case 'infinity':\n case 'inf':\n case '\\u221E':\n if (negativeSign != null) {\n filter = dh.FilterCondition.invoke('isInf', columnFilter).and(\n columnFilter.lessThan(dh.FilterValue.ofNumber(0))\n );\n } else {\n filter = dh.FilterCondition.invoke('isInf', columnFilter).and(\n columnFilter.greaterThan(dh.FilterValue.ofNumber(0))\n );\n }\n break;\n default:\n break;\n }\n if (filter !== null && (operation === '!' || operation === '!=')) {\n filter = filter.not();\n }\n return filter;\n }\n\n if (value == null) {\n return null;\n }\n\n value = TableUtils.removeCommas(value);\n if (TableUtils.isLongType(column.type)) {\n try {\n value = dh.FilterValue.ofNumber(\n dh.LongWrapper.ofString(`${negativeSign != null ? '-' : ''}${value}`)\n );\n } catch (error) {\n log.warn('Unable to create long filter', error);\n return null;\n }\n } else {\n value = parseFloat(value);\n if (value == null || Number.isNaN(value)) {\n return null;\n }\n\n value = dh.FilterValue.ofNumber(negativeSign != null ? 0 - value : value);\n }\n\n filter = column.filter();\n\n return TableUtils.makeRangeFilterWithOperation(filter, operation, value);\n }\n\n static makeQuickTextFilter(\n column: Column,\n text: string | null\n ): FilterCondition | null {\n if (text == null) {\n return null;\n }\n\n const cleanText = `${text}`.trim();\n const regex = /^(!~|!=|~|=|!)?(.*)/;\n const result = regex.exec(cleanText);\n\n let operation = null;\n let value = null;\n if (result !== null && result.length > 2) {\n [, operation, value] = result;\n if (value != null) {\n value = value.trim();\n }\n }\n\n if (value == null || value.length === 0) {\n return null;\n }\n\n if (operation == null) {\n operation = '=';\n }\n\n const filter = column.filter();\n if (value.toLowerCase() === 'null') {\n // Null is a special case!\n switch (operation) {\n case '=':\n return filter.isNull();\n case '!=':\n case '!':\n return filter.isNull().not();\n default:\n return null;\n }\n }\n\n let prefix = null;\n let suffix = null;\n if (value.startsWith('*')) {\n prefix = '*';\n value = value.substring(1);\n } else if (value.endsWith('*') && !value.endsWith('\\\\*')) {\n suffix = '*';\n value = value.substring(0, value.length - 1);\n }\n\n value = value.replace('\\\\', '');\n\n switch (operation) {\n case '~': {\n return filter\n .isNull()\n .not()\n .and(\n filter.invoke(\n 'matches',\n dh.FilterValue.ofString(`(?s)(?i).*\\\\Q${value}\\\\E.*`)\n )\n );\n }\n case '!~':\n return filter\n .isNull()\n .or(\n filter\n .invoke(\n 'matches',\n dh.FilterValue.ofString(`(?s)(?i).*\\\\Q${value}\\\\E.*`)\n )\n .not()\n );\n case '!=':\n if (prefix === '*') {\n // Does not end with\n return filter\n .isNull()\n .or(\n filter\n .invoke(\n 'matches',\n dh.FilterValue.ofString(`(?s)(?i).*\\\\Q${value}\\\\E$`)\n )\n .not()\n );\n }\n if (suffix === '*') {\n // Does not start with\n return filter\n .isNull()\n .or(\n filter\n .invoke(\n 'matches',\n dh.FilterValue.ofString(`(?s)(?i)^\\\\Q${value}\\\\E.*`)\n )\n .not()\n );\n }\n return filter.notEqIgnoreCase(\n dh.FilterValue.ofString(value.toLowerCase())\n );\n\n case '=':\n if (prefix === '*') {\n // Ends with\n return filter\n .isNull()\n .not()\n .and(\n filter.invoke(\n 'matches',\n dh.FilterValue.ofString(`(?s)(?i).*\\\\Q${value}\\\\E$`)\n )\n );\n }\n if (suffix === '*') {\n // Starts with\n return filter\n .isNull()\n .not()\n .and(\n filter.invoke(\n 'matches',\n dh.FilterValue.ofString(`(?s)(?i)^\\\\Q${value}\\\\E.*`)\n )\n );\n }\n return filter.eqIgnoreCase(\n dh.FilterValue.ofString(value.toLowerCase())\n );\n\n default:\n break;\n }\n\n return null;\n }\n\n static makeQuickBooleanFilter(\n column: Column,\n text: string | number\n ): FilterCondition | null {\n if (text == null) {\n return null;\n }\n\n const regex = /^(!=|=|!)?(.*)/;\n const result = regex.exec(`${text}`.trim());\n if (result === null) {\n return null;\n }\n const [, operation, value] = result;\n const notEqual = operation === '!' || operation === '!=';\n const cleanValue = value.trim().toLowerCase();\n\n let filter: FilterCondition | FilterValue = column.filter();\n\n try {\n const boolValue = TableUtils.makeBooleanValue(cleanValue);\n if (boolValue != null && boolValue) {\n filter = filter.isTrue();\n } else if (boolValue === null) {\n filter = filter.isNull();\n } else {\n filter = filter.isFalse();\n }\n\n return notEqual ? filter.not() : filter;\n } catch (e) {\n return null;\n }\n }\n\n /**\n * Builds a date filter parsed from the text string which may or may not include an operator.\n * @param column The column to build the filter from, with or without a leading operator.\n * @param text The date string text to parse.\n * @param timeZone The time zone to make this filter in if it is a date type. E.g. America/New_York\n */\n static makeQuickDateFilter(\n column: Column,\n text: string,\n timeZone: string\n ): FilterCondition {\n const cleanText = text.trim();\n const regex = /\\s*(>=|<=|=>|=<|>|<|!=|!|=)?(.*)/;\n const result = regex.exec(cleanText);\n if (result == null || result.length <= 2) {\n throw new Error(`Unable to parse date filter: ${text}`);\n }\n\n let operation = null;\n let dateText = null;\n\n [, operation, dateText] = result;\n\n let filterOperation: FilterTypeValue = FilterType.eq;\n switch (operation) {\n case '<':\n filterOperation = FilterType.lessThan;\n break;\n case '<=':\n case '=<':\n filterOperation = FilterType.lessThanOrEqualTo;\n break;\n case '>':\n filterOperation = FilterType.greaterThan;\n break;\n case '>=':\n case '=>':\n filterOperation = FilterType.greaterThanOrEqualTo;\n break;\n case '!=':\n case '!':\n filterOperation = FilterType.notEq;\n break;\n case '=':\n case '==':\n default:\n filterOperation = FilterType.eq;\n break;\n }\n\n return TableUtils.makeQuickDateFilterWithOperation(\n column,\n dateText,\n filterOperation,\n timeZone\n );\n }\n\n /**\n * Builds a date filter parsed from the text string with the provided filter.\n * @param column The column to build the filter from.\n * @param text The date string text to parse, without an operator.\n * @param operation The filter operation to use.\n * @param timeZone The time zone to make this filter with. E.g. America/New_York\n */\n static makeQuickDateFilterWithOperation(\n column: Column,\n text: string,\n operation: FilterTypeValue,\n timeZone: string\n ): FilterCondition {\n if (column == null) {\n throw new Error('Column is null');\n }\n\n const [startDate, endDate] = DateUtils.parseDateRange(text, timeZone);\n\n const startValue =\n startDate != null ? dh.FilterValue.ofNumber(startDate) : null;\n const endValue = endDate != null ? dh.FilterValue.ofNumber(endDate) : null;\n\n const filter = column.filter();\n if (startValue == null) {\n return operation === FilterType.notEq\n ? filter.isNull().not()\n : filter.isNull();\n }\n\n switch (operation) {\n case FilterType.eq: {\n if (endValue != null) {\n const startFilter = filter.greaterThanOrEqualTo(startValue);\n const endFilter = filter.lessThan(endValue);\n return startFilter.and(endFilter);\n }\n return filter.eq(startValue);\n }\n case FilterType.lessThan: {\n return filter.lessThan(startValue);\n }\n case FilterType.lessThanOrEqualTo: {\n if (endValue != null) {\n return filter.lessThan(endValue);\n }\n return filter.lessThanOrEqualTo(startValue);\n }\n case FilterType.greaterThan: {\n if (endValue != null) {\n return filter.greaterThanOrEqualTo(endValue);\n }\n return filter.greaterThan(startValue);\n }\n case FilterType.greaterThanOrEqualTo:\n return filter.greaterThanOrEqualTo(startValue);\n case FilterType.notEq: {\n if (endValue != null) {\n const startFilter = filter.lessThan(startValue);\n const endFilter = filter.greaterThanOrEqualTo(endValue);\n return startFilter.or(endFilter);\n }\n return filter.notEq(startValue);\n }\n\n default:\n throw new Error(`Invalid operator: ${operation}`);\n }\n }\n\n /**\n * Adds quotes to a value if they're not already added\n * @param value Value to add quotes around\n */\n static quoteValue(value: string): string {\n if (\n value.length >= 2 &&\n ((value.charAt(0) === '\"' && value.charAt(value.length - 1) === '\"') ||\n (value.charAt(0) === \"'\" && value.charAt(value.length - 1) === \"'\"))\n ) {\n return value;\n }\n return `\"${value}\"`;\n }\n\n static isRangeOperation(operation: string): boolean {\n switch (operation) {\n case '<':\n case '<=':\n case '=<':\n case '>':\n case '>=':\n case '=>':\n return true;\n default:\n return false;\n }\n }\n\n static makeQuickCharFilter(\n column: Column,\n text: string\n ): FilterCondition | null {\n if (text == null) {\n return null;\n }\n\n const cleanText = `${text}`.trim();\n const regex = /^(>=|<=|=>|=<|>|<|!=|=|!)?(null|\".\"|'.'|.)?(.*)/;\n const result = regex.exec(cleanText);\n\n let operation = null;\n let value = null;\n let overflow = null;\n if (result !== null && result.length > 3) {\n [, operation, value, overflow] = result;\n }\n if (overflow != null && overflow.trim().length > 0) {\n // Some bad characters after the number, bail out!\n return null;\n }\n\n if (value == null || value.length === 0) {\n return null;\n }\n\n if (operation == null) {\n operation = '=';\n }\n\n const filter = column.filter();\n if (value.toLowerCase() === 'null') {\n // Null is a special case!\n switch (operation) {\n case '=':\n return filter.isNull();\n case '!=':\n case '!':\n return filter.isNull().not();\n default:\n return null;\n }\n }\n\n // We need to put quotes around range operations or else the API fails\n const filterValue = dh.FilterValue.ofString(\n TableUtils.isRangeOperation(operation)\n ? TableUtils.quoteValue(value)\n : value\n );\n return TableUtils.makeRangeFilterWithOperation(\n filter,\n operation,\n filterValue\n );\n }\n\n /**\n * @param filter The column filter to apply the range operation to\n * @param operation The range operation to run\n * @param value The value to use for the operation\n * @returns The condition with the specified operation\n */\n static makeRangeFilterWithOperation(\n filter: FilterValue,\n operation: string,\n value: FilterValue\n ): FilterCondition | null {\n switch (operation) {\n case '=':\n return filter.eq(value);\n case '<':\n return filter.lessThan(value);\n case '<=':\n case '=<':\n return filter.lessThanOrEqualTo(value);\n case '>':\n return filter.greaterThan(value);\n case '>=':\n case '=>':\n return filter.greaterThanOrEqualTo(value);\n case '!=':\n case '!':\n return filter.notEq(value);\n default:\n return null;\n }\n }\n\n /**\n * Wraps a table promise in a cancelable promise that will close the table if the promise is cancelled.\n * Use in a component that loads a table, and call cancel when unmounting.\n * @param table The table promise to wrap\n */\n static makeCancelableTablePromise(\n table: Promise<Table> | Table\n ): CancelablePromise<Table> {\n return PromiseUtils.makeCancelable(table, resolved => {\n resolved.close();\n });\n }\n\n /**\n * Make a cancelable promise for a one-shot table event with a timeout.\n * @param table Table to listen for events on\n * @param eventName Event to listen for\n * @param timeout Event timeout in milliseconds, defaults to 0\n * @param matcher Optional function to determine if the promise can be resolved or stays pending\n * @returns Resolves with the event data\n */\n static makeCancelableTableEventPromise(\n table: Table | TreeTable,\n eventName: string,\n timeout = 0,\n matcher: ((event: CustomEvent) => boolean) | null = null\n ): CancelablePromise<CustomEvent> {\n let eventCleanup: RemoverFn;\n let timeoutId: ReturnType<typeof setTimeout>;\n let isPending = true;\n const wrappedPromise = new Promise((resolve, reject) => {\n timeoutId = setTimeout(() => {\n eventCleanup();\n isPending = false;\n reject(new TimeoutError(`Event \"${eventName}\" timed out.`));\n }, timeout);\n eventCleanup = table.addEventListener(eventName, event => {\n if (matcher != null && !matcher(event)) {\n log.debug2('Event triggered, but matcher returned false.');\n return;\n }\n log.debug2('Event triggered, resolving.');\n eventCleanup();\n clearTimeout(timeoutId);\n isPending = false;\n resolve(event);\n });\n }) as CancelablePromise<CustomEvent>;\n wrappedPromise.cancel = () => {\n if (isPending) {\n log.debug2('Pending promise cleanup.');\n eventCleanup();\n clearTimeout(timeoutId);\n isPending = false;\n return;\n }\n log.debug2('Ignoring non-pending promise cancel.');\n };\n return wrappedPromise;\n }\n\n static makeAdvancedFilter(\n column: Column,\n options: AdvancedFilterOptions,\n timeZone: string\n ): FilterCondition | null {\n const {\n filterItems,\n filterOperators,\n invertSelection,\n selectedValues,\n } = options;\n let filter = null;\n for (let i = 0; i < filterItems.length; i += 1) {\n const filterItem = filterItems[i];\n const { selectedType, value } = filterItem;\n if (\n selectedType != null &&\n selectedType.length > 0 &&\n value != null &&\n value.length > 0\n ) {\n try {\n const newFilter = TableUtils.makeAdvancedValueFilter(\n column,\n selectedType,\n value,\n timeZone\n );\n if (newFilter != null) {\n if (i === 0) {\n filter = newFilter;\n } else if (filter !== null && i - 1 < filterOperators.length) {\n const filterOperator = filterOperators[i - 1];\n if (filterOperator === FilterOperator.and) {\n filter = filter.and(newFilter);\n } else if (filterOperator === FilterOperator.or) {\n filter = filter.or(newFilter);\n } else {\n log.error(\n 'Unexpected filter operator',\n filterOperator,\n newFilter\n );\n filter = null;\n break;\n }\n }\n } else {\n log.debug2('Empty filter ignored for', selectedType, value);\n }\n } catch (err) {\n log.error('Unable to create filter', err);\n filter = null;\n break;\n }\n }\n }\n\n const selectValueFilter = TableUtils.makeSelectValueFilter(\n column,\n selectedValues,\n invertSelection\n );\n if (selectValueFilter != null) {\n if (filter != null) {\n filter = filter.and(selectValueFilter);\n } else {\n filter = selectValueFilter;\n }\n }\n\n return filter;\n }\n\n static removeCommas(value: string): string {\n return value.replace(/[\\s|,]/g, '');\n }\n\n /**\n * @param columnType The column type to make the filter value from.\n * @param value The value to make the filter value from.\n * @returns The FilterValue item for this column/value combination\n */\n static makeFilterValue(columnType: string, value: string): FilterValue {\n const type = TableUtils.getBaseType(columnType);\n if (TableUtils.isTextType(type)) {\n return dh.FilterValue.ofString(value);\n }\n if (TableUtils.isLongType(type)) {\n return dh.FilterValue.ofNumber(\n dh.LongWrapper.ofString(TableUtils.removeCommas(value))\n );\n }\n\n return dh.FilterValue.ofNumber(TableUtils.removeCommas(value));\n }\n\n /**\n * Takes a value and converts it to an `dh.FilterValue`\n *\n * @param columnType The column type to make the filter value from.\n * @param value The value to actually set\n * @returns The FilterValue item for this column/value combination\n */\n static makeFilterRawValue(\n columnType: string,\n rawValue: unknown\n ): FilterValue {\n if (TableUtils.isTextType(columnType)) {\n return dh.FilterValue.ofString(rawValue);\n }\n\n if (TableUtils.isBooleanType(columnType)) {\n return dh.FilterValue.ofBoolean(rawValue);\n }\n\n return dh.FilterValue.ofNumber(rawValue);\n }\n\n /**\n * Converts a string value to a value appropriate for the column\n * @param columnType The column type to make the value for\n * @param text The string value to make a type for\n * @param timeZone The time zone to make this value in if it is a date type. E.g. America/New_York\n */\n static makeValue(\n columnType: string,\n text: string,\n timeZone: string\n ): string | number | boolean | LongWrapper | null {\n if (text == null || text === 'null') {\n return null;\n }\n if (TableUtils.isTextType(columnType)) {\n return text;\n }\n if (TableUtils.isLongType(columnType)) {\n return dh.LongWrapper.ofString(TableUtils.removeCommas(text));\n }\n if (TableUtils.isBooleanType(columnType)) {\n return TableUtils.makeBooleanValue(text, true);\n }\n if (TableUtils.isDateType(columnType)) {\n const [date] = DateUtils.parseDateRange(text, timeZone);\n return date;\n }\n\n if (TableUtils.isNumberType(columnType)) {\n return TableUtils.makeNumberValue(text);\n }\n\n log.error('Unexpected column type', columnType);\n return null;\n }\n\n static makeBooleanValue(text: string, allowEmpty = false): boolean | null {\n if (text === '' && allowEmpty) {\n return null;\n }\n\n switch (text?.toLowerCase()) {\n case 'null':\n return null;\n case '0':\n case 'f':\n case 'fa':\n case 'fal':\n case 'fals':\n case 'false':\n case 'n':\n case 'no':\n return false;\n case '1':\n case 't':\n case 'tr':\n case 'tru':\n case 'true':\n case 'y':\n case 'ye':\n case 'yes':\n return true;\n default:\n throw new Error(`Invalid boolean '${text}'`);\n }\n }\n\n static makeNumberValue(text: string): number | null {\n if (text == null || text === 'null' || text === '') {\n return null;\n }\n\n const cleanText = text.toLowerCase().trim();\n if (cleanText === '∞' || cleanText === 'infinity' || cleanText === 'inf') {\n return Number.POSITIVE_INFINITY;\n }\n if (\n cleanText === '-∞' ||\n cleanText === '-infinity' ||\n cleanText === '-inf'\n ) {\n return Number.NEGATIVE_INFINITY;\n }\n\n const numberText = TableUtils.removeCommas(cleanText);\n if (TableUtils.NUMBER_REGEX.test(numberText)) {\n return parseFloat(numberText);\n }\n\n throw new Error(`Invalid number '${text}'`);\n }\n\n static getFilterOperatorString(operation: FilterTypeValue): string {\n switch (operation) {\n case FilterType.eq:\n return '=';\n case FilterType.notEq:\n return '!=';\n case FilterType.greaterThan:\n return '>';\n case FilterType.greaterThanOrEqualTo:\n return '>=';\n case FilterType.lessThan:\n return '<';\n case FilterType.lessThanOrEqualTo:\n return '<=';\n case FilterType.contains:\n return '~';\n case FilterType.notContains:\n return '!~';\n default:\n throw new Error(`Unexpected filter type ${operation}`);\n }\n }\n\n static makeAdvancedValueFilter(\n column: Column,\n operation: FilterTypeValue,\n value: string,\n timeZone: string\n ): FilterCondition | null {\n if (TableUtils.isDateType(column.type)) {\n return TableUtils.makeQuickDateFilterWithOperation(\n column,\n value,\n operation,\n timeZone\n );\n }\n\n if (\n TableUtils.isNumberType(column.type) ||\n TableUtils.isCharType(column.type)\n ) {\n return TableUtils.makeQuickFilter(\n column,\n `${TableUtils.getFilterOperatorString(operation)}${value}`\n );\n }\n\n const filterValue = TableUtils.makeFilterValue(column.type, value);\n const filter = column.filter();\n switch (operation) {\n case FilterType.eq:\n return filter.eq(filterValue);\n case FilterType.eqIgnoreCase:\n return filter.eqIgnoreCase(filterValue);\n case FilterType.notEq:\n return filter.notEq(filterValue);\n case FilterType.notEqIgnoreCase:\n return filter.notEqIgnoreCase(filterValue);\n case FilterType.greaterThan:\n return filter.greaterThan(filterValue);\n case FilterType.greaterThanOrEqualTo:\n return filter.greaterThanOrEqualTo(filterValue);\n case FilterType.lessThan:\n return filter.lessThan(filterValue);\n case FilterType.lessThanOrEqualTo:\n return filter.lessThanOrEqualTo(filterValue);\n case FilterType.isTrue:\n return filter.isTrue();\n case FilterType.isFalse:\n return filter.isFalse();\n case FilterType.isNull:\n return filter.isNull();\n case FilterType.contains:\n return filter\n .isNull()\n .not()\n .and(\n filter.invoke(\n 'matches',\n dh.FilterValue.ofString(`(?s)(?i).*\\\\Q${value}\\\\E.*`)\n )\n );\n case FilterType.notContains:\n return filter\n .isNull()\n .or(\n filter\n .invoke(\n 'matches',\n dh.FilterValue.ofString(`(?s)(?i).*\\\\Q${value}\\\\E.*`)\n )\n .not()\n );\n case FilterType.startsWith:\n return filter\n .isNull()\n .not()\n .and(\n filter.invoke(\n 'matches',\n dh.FilterValue.ofString(`(?s)(?i)^\\\\Q${value}\\\\E.*`)\n )\n );\n case FilterType.endsWith:\n return filter\n .isNull()\n .not()\n .and(\n filter.invoke(\n 'matches',\n dh.FilterValue.ofString(`(?s)(?i).*\\\\Q${value}\\\\E$`)\n )\n );\n case FilterType.in:\n case FilterType.inIgnoreCase:\n case FilterType.notIn:\n case FilterType.notInIgnoreCase:\n case FilterType.invoke:\n default:\n throw new Error(`Unexpected filter operation: ${operation}`);\n }\n }\n\n /**\n * Create a filter using the selected items\n * Has a flag for invertSelection as we start from a \"Select All\" state and a user just deselects items.\n * Since there may be millions of distinct items, it's easier to build an inverse filter.\n * @param column The column to set the filter on\n * @param selectedValues The values that are selected\n * @param invertSelection Invert the selection (eg. All items are selected, then you deselect items)\n * @returns Returns a `in` or `notIn` FilterCondition as necessary, or null if no filtering should be applied (everything selected)\n */\n static makeSelectValueFilter(\n column: Column,\n selectedValues: unknown[],\n invertSelection: boolean\n ): FilterCondition | null {\n if (selectedValues.length === 0) {\n if (invertSelection) {\n // No filter means select everything\n return null;\n }\n\n // KLUDGE: Return a conflicting filter to show no results.\n // Could recognize this situation at a higher or lower level and pause updates on the\n // table, but this situation should be rare and that wouldn't be much gains for some added complexity\n let value = null;\n\n if (TableUtils.isTextType(column.type)) {\n // Use 'a' so that it can work for String or Character types\n value = dh.FilterValue.ofString('a');\n } else if (TableUtils.isBooleanType(column.type)) {\n value = dh.FilterValue.ofBoolean(true);\n } else if (TableUtils.isDateType(column.type)) {\n value = dh.FilterValue.ofNumber(dh.DateWrapper.ofJsDate(new Date()));\n } else {\n value = dh.FilterValue.ofNumber(0);\n }\n\n const eqFilter = column.filter().eq(value);\n const notEqFilter = column.filter().notEq(value);\n return eqFilter.and(notEqFilter);\n }\n\n const values = [];\n let isNullSelected = false;\n for (let i = 0; i < selectedValues.length; i += 1) {\n const value = selectedValues[i];\n if (value == null) {\n isNullSelected = true;\n } else if (TableUtils.isTextType(column.type)) {\n values.push(\n dh.FilterValue.ofString(\n typeof value === 'number' ? String.fromCharCode(value) : value\n )\n );\n } else if (TableUtils.isBooleanType(column.type)) {\n values.push(dh.FilterValue.ofBoolean(Boolean(value)));\n } else {\n values.push(dh.FilterValue.ofNumber(value));\n }\n }\n\n if (isNullSelected) {\n if (values.length > 0) {\n if (invertSelection) {\n return column\n .filter()\n .isNull()\n .not()\n .and(column.filter().notIn(values));\n }\n return column.filter().isNull().or(column.filter().in(values));\n }\n if (invertSelection) {\n return column.filter().isNull().not();\n }\n\n return column.filter().isNull();\n }\n\n if (invertSelection) {\n return column.filter().notIn(values);\n }\n\n return column.filter().in(values);\n }\n\n static isTreeTable(table: unknown): table is TreeTable {\n return (\n table != null &&\n (table as TreeTable).expand !== undefined &&\n (table as TreeTable).collapse !== undefined\n );\n }\n\n /**\n * Copies the provided array, sorts by column name case insensitive, and returns the sorted array.\n * @param columns The columns to sort\n * @param isAscending Whether to sort ascending\n */\n static sortColumns(columns: readonly Column[], isAscending = true): Column[] {\n return [...columns].sort((a, b) => {\n const aName = a.name.toUpperCase();\n const bName = b.name.toUpperCase();\n return TextUtils.sort(aName, bName, isAscending);\n });\n }\n}\n\nexport default TableUtils;\n","import TableUtils, { DataType } from './TableUtils';\nimport {\n BooleanColumnFormatter,\n CharColumnFormatter,\n DateTimeColumnFormatter,\n DecimalColumnFormatter,\n DefaultColumnFormatter,\n IntegerColumnFormatter,\n StringColumnFormatter,\n TableColumnFormat,\n TableColumnFormatter,\n} from './formatters';\n\nexport type ColumnName = string;\n\nexport interface FormattingRule {\n columnType: string;\n columnName: ColumnName;\n format: TableColumnFormat;\n}\n\nexport class Formatter {\n /**\n * Converts FormattingRule[] to Map\n * @param columnFormattingRules Array or column formatting rules\n * @returns Map of columnName-to-format Maps indexed by normalized dataType\n */\n static makeColumnFormatMap(\n columnFormattingRules: FormattingRule[]\n ): Map<DataType, Map<ColumnName, TableColumnFormat>> {\n if (columnFormattingRules == null) {\n return new Map();\n }\n return columnFormattingRules.reduce((map, next) => {\n const dataType = TableUtils.getNormalizedType(next.columnType);\n if (dataType === null) {\n return map;\n }\n\n if (!map.has(dataType)) {\n map.set(dataType, new Map());\n }\n const formatMap = map.get(dataType);\n formatMap?.set(next.columnName, next.format);\n return map;\n }, new Map<DataType, Map<ColumnName, TableColumnFormat>>());\n }\n\n /**\n * Creates a column formatting rule\n * @param columnType Normalized data type\n * @param columnName Column name\n * @param format Format object\n */\n static makeColumnFormattingRule(\n columnType: DataType,\n columnName: ColumnName,\n format: TableColumnFormat\n ): FormattingRule {\n return {\n columnType,\n columnName,\n format,\n };\n }\n\n /**\n * @param columnFormattingRules Optional array of column formatting rules\n * @param dateTimeOptions Optional object with DateTime configuration\n * @param decimalFormatOptions Optional object with Decimal configuration\n * @param integerFormatOptions Optional object with Integer configuration\n * @param truncateNumbersWithPound Determine if numbers should be truncated w/ repeating # instead of ellipsis at the end\n */\n constructor(\n columnFormattingRules: FormattingRule[] = [],\n dateTimeOptions?: ConstructorParameters<typeof DateTimeColumnFormatter>[0],\n decimalFormatOptions?: ConstructorParameters<\n typeof DecimalColumnFormatter\n >[0],\n integerFormatOptions?: ConstructorParameters<\n typeof IntegerColumnFormatter\n >[0],\n truncateNumbersWithPound = false\n ) {\n // Formatting order:\n // - columnFormatMap[type][name]\n // - typeFormatterMap[type]\n // - defaultColumnFormatter\n\n this.defaultColumnFormatter = new DefaultColumnFormatter();\n\n // Default formatters by data type\n this.typeFormatterMap = new Map<DataType, TableColumnFormatter>([\n [TableUtils.dataType.BOOLEAN, new BooleanColumnFormatter()],\n [TableUtils.dataType.CHAR, new CharColumnFormatter()],\n [\n TableUtils.dataType.DATETIME,\n new DateTimeColumnFormatter(dateTimeOptions),\n ],\n [\n TableUtils.dataType.DECIMAL,\n new DecimalColumnFormatter(decimalFormatOptions),\n ],\n [\n TableUtils.dataType.INT,\n new IntegerColumnFormatter(integerFormatOptions),\n ],\n [TableUtils.dataType.STRING, new StringColumnFormatter()],\n ]);\n\n // Formats indexed by data type and column name\n this.columnFormatMap = Formatter.makeColumnFormatMap(columnFormattingRules);\n this.truncateNumbersWithPound = truncateNumbersWithPound;\n }\n\n defaultColumnFormatter: TableColumnFormatter;\n\n typeFormatterMap: Map<DataType, TableColumnFormatter>;\n\n columnFormatMap: Map<DataType, Map<string, TableColumnFormat>>;\n\n truncateNumbersWithPound: boolean;\n\n /**\n * Gets columnFormatMap indexed by name for a given column type, creates new Map entry if necessary\n * @param columnType column type\n * @param createIfNecessary create new entry if true\n * @returns Map of format strings indexed by column name or undefined if it doesn't exist\n */\n getColumnFormatMapForType(\n columnType: string,\n createIfNecessary = false\n ): Map<string, TableColumnFormat> | undefined {\n const dataType = TableUtils.getNormalizedType(columnType);\n if (dataType === null) {\n return undefined;\n }\n\n if (createIfNecessary && !this.columnFormatMap.has(dataType)) {\n this.columnFormatMap.set(dataType, new Map());\n }\n return this.columnFormatMap.get(dataType);\n }\n\n /**\n * Gets a column format object for a given column type and name\n * @param columnType column type\n * @param columnName column name\n * @returns format object or null for Default\n */\n getColumnFormat(\n columnType: string,\n columnName: ColumnName\n ): TableColumnFormat | null {\n const columnFormatMap = this.getColumnFormatMapForType(columnType);\n return columnFormatMap?.get(columnName) ?? null;\n }\n\n getColumnTypeFormatter(columnType: string): TableColumnFormatter {\n const dataType = TableUtils.getNormalizedType(columnType);\n let columnTypeFormatter = this.defaultColumnFormatter;\n if (dataType) {\n columnTypeFormatter =\n this.typeFormatterMap.get(dataType) ?? columnTypeFormatter;\n }\n return columnTypeFormatter;\n }\n\n /**\n * Gets formatted string for a given value, column type and name\n * @param value Value to format\n * @param columnType Column type used to determine the formatting settings\n * @param columnName Column name used to determine the formatting settings\n * @param formatOverride Format object passed to the formatter in place of the format defined in columnFormatMap\n */\n getFormattedString(\n value: unknown,\n columnType: string,\n columnName = '',\n formatOverride?: Partial<TableColumnFormat>\n ): string {\n if (value == null) {\n return '';\n }\n\n const formatter = this.getColumnTypeFormatter(columnType);\n const format =\n formatOverride || this.getColumnFormat(columnType, columnName);\n\n return formatter.format(value, format ?? undefined);\n }\n\n /**\n * Gets the timeZone name\n * @returns The time zone name E.g. America/New_York\n */\n get timeZone(): string {\n const formatter = this.typeFormatterMap.get(\n TableUtils.dataType.DATETIME\n ) as DateTimeColumnFormatter;\n return formatter?.dhTimeZone?.id;\n }\n}\n\nexport default Formatter;\n","import type { FormattingRule } from './Formatter';\nimport Formatter from './Formatter';\nimport { DateTimeColumnFormatter, TableColumnFormatter } from './formatters';\nimport { ColumnFormatSettings, DateTimeFormatSettings } from './Settings';\n\nexport function getColumnFormats(\n settings?: ColumnFormatSettings\n): FormattingRule[] | undefined {\n if (settings && settings.formatter) {\n const { formatter } = settings;\n return formatter;\n }\n return undefined;\n}\n\nexport function getDateTimeFormatterOptions(\n settings?: DateTimeFormatSettings | null\n): ConstructorParameters<typeof DateTimeColumnFormatter>[0] {\n return {\n timeZone: settings?.timeZone,\n defaultDateTimeFormatString: settings?.defaultDateTimeFormat,\n showTimeZone: settings?.showTimeZone,\n showTSeparator: settings?.showTSeparator,\n };\n}\n\n/**\n * Check if the formatter has a custom format defined for the column name and type\n * @param formatter Formatter to check\n * @param columnName Column name\n * @param columnType Column type\n * @returns True, if a custom format is defined\n */\nexport function isCustomColumnFormatDefined(\n formatter: Formatter,\n columnName: string,\n columnType: string\n): boolean {\n const columnFormat = formatter.getColumnFormat(columnType, columnName);\n return (\n columnFormat != null &&\n (columnFormat.type === TableColumnFormatter.TYPE_CONTEXT_PRESET ||\n columnFormat.type === TableColumnFormatter.TYPE_CONTEXT_CUSTOM)\n );\n}\n\nexport default {\n getColumnFormats,\n getDateTimeFormatterOptions,\n isCustomColumnFormatDefined,\n};\n","/* eslint-disable global-require */\n// Create a partial plot with only the kinds of charts we need\n// https://github.com/plotly/plotly.js/#modules\n\nimport Plotly from 'plotly.js/lib/core.js';\nimport bar from 'plotly.js/lib/bar.js';\nimport histogram from 'plotly.js/lib/histogram.js';\nimport pie from 'plotly.js/lib/pie.js';\nimport ohlc from 'plotly.js/lib/ohlc.js';\nimport scattergl from 'plotly.js/lib/scattergl.js';\nimport treemap from 'plotly.js/lib/treemap.js';\n\n// Load in the trace types we need/support\nPlotly.register([bar, histogram, pie, ohlc, scattergl, treemap]);\n\nexport default Plotly;\n","// Import the react customizable bundle for building, only pull in the modules we need\n// This reduces the build size. Plotly has a lot of modules we don't need/use.\n// https://github.com/plotly/react-plotly.js#customizing-the-plotlyjs-bundle\nimport createPlotlyComponent from 'react-plotly.js/factory.js';\nimport Plotly from './Plotly';\n\n// Webpack 4 (used in CRA) handles this import such that createPlotlyComponent is a function\n// Webpack 5 (used in docusaurus) gives an object w/ a default key\n// This is probably something on react-plotly.js's side\nexport default typeof createPlotlyComponent === 'function'\n ? createPlotlyComponent(Plotly)\n : createPlotlyComponent.default(Plotly);\n","/* eslint class-methods-use-this: \"off\" */\n/* eslint no-unused-vars: \"off\" */\n\nimport { Formatter } from '@deephaven/jsapi-utils';\nimport { Layout, PlotData } from 'plotly.js';\n\nexport type FilterColumnMap = Map<\n string,\n {\n name: string;\n type: string;\n }\n>;\n\nexport type ChartEvent = CustomEvent;\n/**\n * Model for a Chart\n * All of these methods should return very quickly.\n * If data needs to be loaded asynchronously, return something immediately, then trigger an event for the chart to refresh.\n */\nclass ChartModel {\n static EVENT_UPDATED = 'ChartModel.EVENT_UPDATED';\n\n static EVENT_DISCONNECT = 'ChartModel.EVENT_DISCONNECT';\n\n static EVENT_RECONNECT = 'ChartModel.EVENT_RECONNECT';\n\n static EVENT_DOWNSAMPLESTARTED = 'ChartModel.EVENT_DOWNSAMPLESTARTED';\n\n static EVENT_DOWNSAMPLEFINISHED = 'ChartModel.EVENT_DOWNSAMPLEFINISHED';\n\n static EVENT_DOWNSAMPLEFAILED = 'ChartModel.EVENT_DOWNSAMPLEFAILED';\n\n static EVENT_DOWNSAMPLENEEDED = 'ChartModel.EVENT_DOWNSAMPLENEEDED';\n\n static EVENT_LOADFINISHED = 'ChartModel.EVENT_LOADFINISHED';\n\n constructor() {\n this.listeners = [];\n this.isDownsamplingDisabled = false;\n }\n\n listeners: ((event: ChartEvent) => void)[];\n\n formatter?: Formatter;\n\n rect?: DOMRect;\n\n isDownsamplingDisabled: boolean;\n\n title?: string;\n\n getData(): Partial<PlotData>[] {\n return [];\n }\n\n getDefaultTitle(): string {\n return '';\n }\n\n getLayout(): Partial<Layout> {\n return {};\n }\n\n getFilterColumnMap(): FilterColumnMap {\n return new Map();\n }\n\n isFilterRequired(): boolean {\n return false;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n setFilter(filter: Map<string, string>): void {}\n\n /**\n * Close this model, clean up any underlying subscriptions\n */\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n close(): void {}\n\n /**\n * Set the formatter to use when charting the data.\n * @param formatter The formatter to use to format the charting data\n */\n setFormatter(formatter: Formatter): void {\n this.formatter = formatter;\n }\n\n /**\n * Disable downsampling\n * @param isDownsamplingDisabled True if downsampling should be disabled\n */\n setDownsamplingDisabled(isDownsamplingDisabled: boolean): void {\n this.isDownsamplingDisabled = isDownsamplingDisabled;\n }\n\n /**\n * Set the dimensions of the plot. May be needed to evaluate some of the percents\n * @param rect The bounding rectangle of the plot\n */\n setDimensions(rect: DOMRect): void {\n this.rect = rect;\n }\n\n setTitle(title: string): void {\n this.title = title;\n }\n\n /**\n * Subscribe to this ChartModel and start listening for all events.\n * @param callback Callback when an event occurs\n */\n subscribe(callback: (event: ChartEvent) => void): void {\n this.listeners.push(callback);\n }\n\n unsubscribe(callback: (event: ChartEvent) => void): void {\n this.listeners = this.listeners.filter(listener => listener !== callback);\n }\n\n fireEvent(event: ChartEvent): void {\n for (let i = 0; i < this.listeners.length; i += 1) {\n this.listeners[i](event);\n }\n }\n\n fireUpdate(data: unknown): void {\n this.fireEvent(new CustomEvent(ChartModel.EVENT_UPDATED, { detail: data }));\n }\n\n fireDisconnect(): void {\n this.fireEvent(new CustomEvent(ChartModel.EVENT_DISCONNECT));\n }\n\n fireReconnect(): void {\n this.fireEvent(new CustomEvent(ChartModel.EVENT_RECONNECT));\n }\n\n fireDownsampleStart(detail: unknown): void {\n this.fireEvent(\n new CustomEvent(ChartModel.EVENT_DOWNSAMPLESTARTED, { detail })\n );\n }\n\n fireDownsampleFinish(detail: unknown): void {\n this.fireEvent(\n new CustomEvent(ChartModel.EVENT_DOWNSAMPLEFINISHED, { detail })\n );\n }\n\n fireDownsampleFail(detail: unknown): void {\n this.fireEvent(\n new CustomEvent(ChartModel.EVENT_DOWNSAMPLEFAILED, { detail })\n );\n }\n\n fireDownsampleNeeded(detail: unknown): void {\n this.fireEvent(\n new CustomEvent(ChartModel.EVENT_DOWNSAMPLENEEDED, { detail })\n );\n }\n\n fireLoadFinished(): void {\n this.fireEvent(new CustomEvent(ChartModel.EVENT_LOADFINISHED));\n }\n}\n\nexport default ChartModel;\n","import ChartTheme from './ChartTheme.module.scss';\n\nexport default Object.freeze({\n paper_bgcolor: ChartTheme['paper-bgcolor'],\n plot_bgcolor: ChartTheme['plot-bgcolor'],\n title_color: ChartTheme['title-color'],\n colorway: ChartTheme.colorway,\n gridcolor: ChartTheme.gridcolor,\n linecolor: ChartTheme.linecolor,\n zerolinecolor: ChartTheme.zerolinecolor,\n activecolor: ChartTheme.activecolor,\n rangebgcolor: ChartTheme.rangebgcolor,\n area_color: ChartTheme['area-color'],\n trend_color: ChartTheme['trend-color'],\n line_color: ChartTheme['line-color'],\n error_band_line_color: ChartTheme['error-band-line-color'],\n error_band_fill_color: ChartTheme['error-band-fill-color'],\n ohlc_increasing: ChartTheme['ohlc-increasing'],\n ohlc_decreasing: ChartTheme['ohlc-decreasing'],\n});\n","import Log from '@deephaven/log';\nimport {\n DateTimeColumnFormatter,\n Formatter,\n TableColumnFormatter,\n TableUtils,\n} from '@deephaven/jsapi-utils';\nimport dh, {\n Axis,\n AxisPosition,\n AxisType,\n Chart,\n DateWrapper,\n Figure,\n Holiday,\n LongWrapper,\n Series,\n SeriesDataSource,\n SeriesPlotStyle,\n SourceType,\n TableTemplate,\n TimeZone,\n} from '@deephaven/jsapi-shim';\nimport set from 'lodash.set';\nimport {\n Layout,\n PlotData,\n PlotType,\n Axis as PlotlyAxis,\n ErrorBar,\n LayoutAxis,\n AxisType as PlotlyAxisType,\n OhclData,\n MarkerSymbol,\n} from 'plotly.js';\nimport { assertNotNull, Range } from '@deephaven/utils';\nimport ChartTheme from './ChartTheme';\n\nexport interface ChartModelSettings {\n hiddenSeries?: string[];\n type: keyof SeriesPlotStyle;\n series: string[];\n xAxis: string;\n title?: string;\n}\n\nexport interface SeriesData {\n type: string | null;\n mode: string | null;\n name: string;\n orientation: string;\n xaxis?: number;\n marker?: unknown;\n xLow?: number;\n xHigh?: number;\n}\n\nexport type RangeParser = (range: Range) => unknown[];\n\nexport type AxisRangeParser = (axis: Axis) => RangeParser;\n\nexport type ChartAxisRangeParser = (chart: Chart) => AxisRangeParser;\n\ntype LayoutAxisKey =\n | 'xaxis'\n | 'xaxis2'\n | 'xaxis3'\n | 'xaxis4'\n | 'xaxis5'\n | 'xaxis6'\n | 'xaxis7'\n | 'xaxis8'\n | 'xaxis9'\n | 'yaxis'\n | 'yaxis2'\n | 'yaxis3'\n | 'yaxis4'\n | 'yaxis5'\n | 'yaxis6'\n | 'yaxis7'\n | 'yaxis8'\n | 'yaxis9';\n\nexport interface TreeMapData extends PlotData {\n tiling: {\n packing: 'squarify';\n pad: 0;\n };\n}\n\ninterface Rangebreaks {\n bounds?: number[];\n dvalue?: number;\n enable?: boolean;\n name?: string;\n pattern?: 'day of week' | 'hour' | '';\n values?: string[];\n}\ninterface RangebreakAxisFormat extends PlotlyAxis {\n rangebreaks: Rangebreaks[];\n}\n\nexport type ChartBounds = {\n left: number;\n right: number;\n top: number;\n bottom: number;\n};\n\nexport type AxisTypeMap = Map<AxisType, Axis[]>;\ntype AxisPositionMap = Map<AxisPosition, Axis[]>;\n\nconst log = Log.module('ChartUtils');\n\nconst DAYS = Object.freeze(dh.calendar.DayOfWeek.values());\n\nconst BUSINESS_COLUMN_TYPE = 'io.deephaven.time.DateTime';\n\nconst MILLIS_PER_HOUR = 3600000;\n\nconst NANOS_PER_MILLI = 1000000;\n\nfunction isDateWrapper(value: unknown): value is DateWrapper {\n return (value as DateWrapper).asDate !== undefined;\n}\n\nfunction isLongWrapper(value: unknown): value is LongWrapper {\n return (value as LongWrapper).asNumber !== undefined;\n}\n\nfunction isDateTimeColumnFormatter(\n value: TableColumnFormatter\n): value is DateTimeColumnFormatter {\n return (value as DateTimeColumnFormatter).dhTimeZone !== undefined;\n}\n\nfunction isRangedPlotlyAxis(value: unknown): value is { range: Range[] } {\n return (\n value != null &&\n (value as PlotlyAxis).range != null &&\n ((value as PlotlyAxis).autorange === false ||\n (value as PlotlyAxis).autorange === undefined)\n );\n}\n\nclass ChartUtils {\n static DEFAULT_AXIS_SIZE = 0.15;\n\n static MIN_AXIS_SIZE = 0.025;\n\n static MAX_AXIS_SIZE = 0.2;\n\n static AXIS_SIZE_PX = 75;\n\n static LEGEND_WIDTH_PX = 50;\n\n static MAX_LEGEND_SIZE = 0.25;\n\n static ORIENTATION = Object.freeze({\n HORIZONTAL: 'h',\n VERTICAL: 'v',\n } as const);\n\n static DATE_FORMAT = 'yyyy-MM-dd HH:mm:ss.SSSSSS';\n\n static DEFAULT_MARGIN = Object.freeze({ l: 60, r: 50, t: 30, b: 60, pad: 0 });\n\n static DEFAULT_TITLE_PADDING = Object.freeze({ t: 8 });\n\n static SUBTITLE_LINE_HEIGHT = 25;\n\n static DEFAULT_MARKER_SIZE = 6;\n\n static MODE_MARKERS: PlotData['mode'] = 'markers';\n\n static MODE_LINES: PlotData['mode'] = 'lines';\n\n /**\n * Converts the Iris plot style into a plotly chart type\n * @param plotStyle The plotStyle to use, see dh.plot.SeriesPlotStyle\n * @param isBusinessTime If the plot is using business time for an axis\n */\n static getPlotlyChartType(\n plotStyle: SeriesPlotStyle,\n isBusinessTime: boolean\n ): PlotType | undefined {\n switch (plotStyle) {\n case dh.plot.SeriesPlotStyle.SCATTER:\n // scattergl mode is more performant, but doesn't support the rangebreaks we need for businessTime calendars\n return !isBusinessTime ? 'scattergl' : 'scatter';\n case dh.plot.SeriesPlotStyle.LINE:\n // There is also still some artifacting bugs with scattergl: https://github.com/plotly/plotly.js/issues/3522\n // The artifacting only occurs on line plots, which we can draw with fairly decent performance using SVG paths\n // Once the above plotly issue is fixed, scattergl should be used here (when !isBusinessTime)\n return 'scatter';\n case dh.plot.SeriesPlotStyle.BAR:\n case dh.plot.SeriesPlotStyle.STACKED_BAR:\n return 'bar';\n\n case dh.plot.SeriesPlotStyle.PIE:\n return 'pie';\n\n case dh.plot.SeriesPlotStyle.TREEMAP:\n return 'treemap';\n\n case dh.plot.SeriesPlotStyle.HISTOGRAM:\n return 'histogram';\n\n case dh.plot.SeriesPlotStyle.OHLC:\n return 'ohlc';\n\n default:\n return undefined;\n }\n }\n\n /**\n * Converts the Iris plot style into a plotly chart mode\n * @param plotStyle The plotStyle to use, see dh.plot.SeriesPlotStyle.*\n * @param areLinesVisible Whether lines are visible or not\n * @param areShapesVisible Whether shapes are visible or not\n */\n static getPlotlyChartMode(\n plotStyle: SeriesPlotStyle,\n areLinesVisible?: boolean,\n areShapesVisible?: boolean\n ): PlotData['mode'] | undefined {\n const modes = new Set<PlotData['mode']>();\n\n switch (plotStyle) {\n case dh.plot.SeriesPlotStyle.SCATTER:\n // Default to only showing shapes in scatter plots\n if (areLinesVisible ?? false) {\n modes.add(ChartUtils.MODE_LINES);\n }\n if (areShapesVisible ?? true) {\n modes.add(ChartUtils.MODE_MARKERS);\n }\n break;\n case dh.plot.SeriesPlotStyle.LINE:\n // Default to only showing lines in line series\n if (areLinesVisible ?? true) {\n modes.add(ChartUtils.MODE_LINES);\n }\n if (areShapesVisible ?? false) {\n modes.add(ChartUtils.MODE_MARKERS);\n }\n break;\n default:\n break;\n }\n\n return modes.size > 0\n ? ([...modes].join('+') as PlotData['mode'])\n : undefined;\n }\n\n /**\n * Get the property to set on the series data for plotly\n * @param plotStyle The plot style of the series\n * @param sourceType The source type for the series\n */\n static getPlotlyProperty(\n plotStyle: SeriesPlotStyle,\n sourceType: SourceType\n ): string {\n switch (plotStyle) {\n case dh.plot.SeriesPlotStyle.PIE:\n switch (sourceType) {\n case dh.plot.SourceType.X:\n return 'labels';\n case dh.plot.SourceType.Y:\n return 'values';\n default:\n break;\n }\n break;\n case dh.plot.SeriesPlotStyle.OHLC:\n switch (sourceType) {\n case dh.plot.SourceType.TIME:\n return 'x';\n default:\n break;\n }\n break;\n case dh.plot.SeriesPlotStyle.TREEMAP:\n switch (sourceType) {\n case dh.plot.SourceType.X:\n return 'ids';\n case dh.plot.SourceType.Y:\n return 'values';\n case dh.plot.SourceType.LABEL:\n return 'labels';\n case dh.plot.SourceType.PARENT:\n return 'parents';\n case dh.plot.SourceType.COLOR:\n return 'marker.colors';\n default:\n break;\n }\n break;\n default:\n break;\n }\n\n switch (sourceType) {\n case dh.plot.SourceType.X:\n return 'x';\n case dh.plot.SourceType.Y:\n return 'y';\n case dh.plot.SourceType.Z:\n return 'z';\n case dh.plot.SourceType.X_LOW:\n return 'xLow';\n case dh.plot.SourceType.X_HIGH:\n return 'xHigh';\n case dh.plot.SourceType.Y_LOW:\n return 'yLow';\n case dh.plot.SourceType.Y_HIGH:\n return 'yHigh';\n case dh.plot.SourceType.TIME:\n return 'time';\n case dh.plot.SourceType.OPEN:\n return 'open';\n case dh.plot.SourceType.HIGH:\n return 'high';\n case dh.plot.SourceType.LOW:\n return 'low';\n case dh.plot.SourceType.CLOSE:\n return 'close';\n case dh.plot.SourceType.SHAPE:\n return 'shape';\n case dh.plot.SourceType.SIZE:\n return 'size';\n case dh.plot.SourceType.LABEL:\n return 'label';\n case dh.plot.SourceType.COLOR:\n return 'color';\n case dh.plot.SourceType.PARENT:\n return 'parent';\n case dh.plot.SourceType.HOVER_TEXT:\n return 'hovertext';\n case dh.plot.SourceType.TEXT:\n return 'text';\n default:\n throw new Error(`Unrecognized source type: ${sourceType}`);\n }\n }\n\n static getPlotlySeriesOrientation(series: Series): 'h' | 'v' | undefined {\n const { sources } = series;\n if (sources.length === 2 && sources[0]?.axis?.type === dh.plot.AxisType.Y) {\n return ChartUtils.ORIENTATION.HORIZONTAL;\n }\n\n return ChartUtils.ORIENTATION.VERTICAL;\n }\n\n /**\n * Generate the plotly error bar data from the passed in data.\n * Iris passes in the values as absolute, plotly needs them as relative.\n * @param x The main data array\n * @param xLow The absolute low values\n * @param xHigh\n *\n * @returns The error_x object required by plotly, or null if none is required\n */\n static getPlotlyErrorBars(\n x: number[],\n xLow: number[],\n xHigh: number[]\n ): ErrorBar {\n const array = xHigh.map((value, i) => value - x[i]);\n const arrayminus = xLow.map((value, i) => x[i] - value);\n return {\n type: 'data',\n symmetric: false,\n array,\n arrayminus,\n };\n }\n\n static getPlotlyDateFormat(\n formatter: Formatter | null,\n columnType: string,\n formatPattern: string\n ): Partial<LayoutAxis> {\n const tickformat =\n formatPattern == null\n ? undefined\n : formatPattern\n .replace('%', '%%')\n .replace(/S{9}/g, '%9f')\n .replace(/S{8}/g, '%8f')\n .replace(/S{7}/g, '%7f')\n .replace(/S{6}/g, '%6f')\n .replace(/S{5}/g, '%5f')\n .replace(/S{4}/g, '%4f')\n .replace(/S{3}/g, '%3f')\n .replace(/S{2}/g, '%2f')\n .replace(/S{1}/g, '%1f')\n .replace(/y{4}/g, '%Y')\n .replace(/y{2}/g, '%y')\n .replace(/M{4}/g, '%B')\n .replace(/M{3}/g, '%b')\n .replace(/M{2}/g, '%m')\n .replace(/M{1}/g, '%-m')\n .replace(/E{4,}/g, '%A')\n .replace(/E{1,}/g, '%a')\n .replace(/d{2}/g, '%d')\n .replace(/([^%]|^)d{1}/g, '$1%-d')\n .replace(/H{2}/g, '%H')\n .replace(/h{2}/g, '%I')\n .replace(/h{1}/g, '%-I')\n .replace(/m{2}/g, '%M')\n .replace(/s{2}/g, '%S')\n .replace(\"'T'\", 'T')\n .replace(' z', ''); // timezone added as suffix if necessary\n\n let ticksuffix;\n const dataFormatter = formatter?.getColumnTypeFormatter(columnType);\n if (\n dataFormatter != null &&\n isDateTimeColumnFormatter(dataFormatter) &&\n dataFormatter.dhTimeZone != null &&\n dataFormatter.showTimeZone\n ) {\n ticksuffix = dh.i18n.DateTimeFormat.format(\n ' z',\n new Date(),\n dataFormatter.dhTimeZone\n );\n }\n\n return {\n tickformat,\n ticksuffix,\n automargin: true,\n };\n }\n\n static convertNumberPrefix(prefix: string): string {\n return prefix.replace(/\\u00A4\\u00A4/g, 'USD').replace(/\\u00A4/g, '$');\n }\n\n static getPlotlyNumberFormat(\n formatter: Formatter | null,\n columnType: string,\n formatPattern: string\n ): Partial<LayoutAxis> | null {\n if (!formatPattern) {\n return null;\n }\n\n // We translate java formatting: https://docs.oracle.com/javase/7/docs/api/java/text/DecimalFormat.html\n // Into d3 number formatting: https://github.com/d3/d3-format\n // We can't translate number formatting exactly, but should be able to translate the most common cases\n // First split it into the subpatterns; currently only handling the positive subpattern, ignoring the rest\n const subpatterns = formatPattern.split(';');\n\n const matchArray = subpatterns[0].match(\n /^([^#,0.]*)([#,]*)([0,]*)(\\.?)(0*)(#*)(E?0*)(%?)(.*)/\n );\n assertNotNull(matchArray);\n\n const [\n ,\n prefix,\n placeholderDigits,\n zeroDigits,\n ,\n decimalDigits,\n optionalDecimalDigits,\n numberType,\n percentSign,\n suffix,\n ] = matchArray;\n\n const paddingLength = zeroDigits.replace(',', '').length;\n const isCommaSeparated =\n placeholderDigits.indexOf(',') >= 0 || zeroDigits.indexOf(',') >= 0;\n const comma = isCommaSeparated ? ',' : '';\n const plotlyNumberType =\n numberType != null && numberType !== '' ? 'e' : 'f';\n\n const type = percentSign !== '' ? percentSign : plotlyNumberType;\n\n const decimalLength = decimalDigits.length + optionalDecimalDigits.length;\n // IDS-4565 Plotly uses an older version of d3 which doesn't support the trim option or negative brackets\n // If plotly updates it's d3 version, this should be re-enabled\n // const trimOption = optionalDecimalDigits.length > 0 ? '~' : '';\n const trimOption = '';\n\n const tickformat = `0${paddingLength}${comma}.${decimalLength}${trimOption}${type}`;\n const tickprefix = ChartUtils.convertNumberPrefix(prefix);\n // prefix and suffix are processed the same\n const ticksuffix = ChartUtils.convertNumberPrefix(suffix);\n\n return { tickformat, tickprefix, ticksuffix, automargin: true };\n }\n\n /**\n * Gets the plotly axis formatting information from the source passed in\n * @param source The Source to get the formatter information from\n * @param formatter The current formatter for formatting data\n */\n static getPlotlyAxisFormat(\n source: SeriesDataSource,\n formatter: Formatter | null = null\n ): Partial<PlotlyAxis> | null {\n const { axis, columnType } = source;\n const { formatPattern } = axis;\n\n let axisFormat = null;\n if (TableUtils.isDateType(columnType)) {\n axisFormat = ChartUtils.getPlotlyDateFormat(\n formatter,\n columnType,\n formatPattern\n );\n axisFormat = ChartUtils.addTickSpacing(axisFormat, axis, true);\n } else if (TableUtils.isNumberType(columnType)) {\n axisFormat = ChartUtils.getPlotlyNumberFormat(\n formatter,\n columnType,\n formatPattern\n );\n axisFormat = ChartUtils.addTickSpacing(axisFormat, axis, false);\n }\n\n if (axis.formatType === dh.plot.AxisFormatType.CATEGORY) {\n if (axisFormat) {\n axisFormat.type = 'category';\n } else {\n axisFormat = {\n type: 'category' as PlotlyAxisType,\n tickformat: undefined,\n ticksuffix: undefined,\n };\n }\n }\n\n return axisFormat;\n }\n\n /**\n * Adds tick spacing for an axis that has gapBetweenMajorTicks defined.\n *\n * @param axisFormat the current axis format, may be null\n * @param axis the current axis\n * @param isDateType indicates if the columns is a date type\n */\n static addTickSpacing(\n axisFormat: Partial<LayoutAxis> | null,\n axis: Axis,\n isDateType: boolean\n ): Partial<PlotlyAxis> | null {\n const { gapBetweenMajorTicks } = axis;\n if (gapBetweenMajorTicks > 0) {\n const updatedFormat: Partial<PlotlyAxis> = axisFormat || {};\n let tickSpacing = gapBetweenMajorTicks;\n if (isDateType) {\n // Need to convert from nanoseconds to milliseconds\n tickSpacing = gapBetweenMajorTicks / NANOS_PER_MILLI;\n }\n if (axis.log) {\n tickSpacing = Math.log(tickSpacing);\n }\n // Note that tickmode defaults to 'auto'\n updatedFormat.tickmode = 'linear';\n updatedFormat.dtick = tickSpacing;\n return updatedFormat;\n }\n\n return axisFormat;\n }\n\n /**\n * Retrieve the data source for a given axis in a chart\n * @param chart The chart to get the source for\n * @param axis The axis to find the source for\n * @returns The first source matching this axis\n */\n static getSourceForAxis(chart: Chart, axis: Axis): SeriesDataSource | null {\n for (let i = 0; i < chart.series.length; i += 1) {\n const series = chart.series[i];\n for (let j = 0; j < series.sources.length; j += 1) {\n const source = series.sources[j];\n if (source.axis === axis) {\n return source;\n }\n }\n }\n\n return null;\n }\n\n /**\n * Get visibility setting for the series object\n * @param name The series name to get the visibility for\n * @param settings Chart settings\n * @returns True for visible series and 'legendonly' for hidden\n */\n static getSeriesVisibility(\n name: string,\n settings?: Partial<ChartModelSettings>\n ): boolean | 'legendonly' {\n if (\n settings != null &&\n settings.hiddenSeries != null &&\n settings.hiddenSeries.includes(name)\n ) {\n return 'legendonly';\n }\n return true;\n }\n\n /**\n * Get hidden labels array from chart settings\n * @param settings Chart settings\n * @returns Array of hidden series names\n */\n static getHiddenLabels(settings: Partial<ChartModelSettings>): string[] {\n if (settings?.hiddenSeries) {\n return [...settings.hiddenSeries];\n }\n return [];\n }\n\n /**\n * Create a default series data object. Apply styling to the object afterward.\n * @returns A simple series data object with no styling\n */\n static makeSeriesData(\n type: PlotType | undefined,\n mode: PlotData['mode'] | undefined,\n name: string,\n showLegend: boolean | null,\n orientation: 'h' | 'v' = ChartUtils.ORIENTATION.VERTICAL\n ): Partial<PlotData> {\n return {\n type,\n mode,\n name,\n orientation,\n showlegend: showLegend ?? undefined,\n };\n }\n\n /**\n * Create a data series (trace) for use with plotly\n * @param series The series to create the series data with\n * @param axisTypeMap The map of axes grouped by type\n * @param seriesVisibility Visibility setting for the series\n * @param theme The theme properties for the plot. See ChartTheme.js for an example\n * @returns The series data (trace) object for use with plotly.\n */\n static makeSeriesDataFromSeries(\n series: Series,\n axisTypeMap: AxisTypeMap,\n seriesVisibility: boolean | 'legendonly',\n showLegend: boolean | null = null,\n theme = ChartTheme\n ): Partial<PlotData> {\n const {\n name,\n isLinesVisible,\n isShapesVisible,\n plotStyle,\n lineColor,\n shapeColor,\n sources,\n shape,\n shapeSize,\n } = series;\n\n const isBusinessTime = sources.some(\n source => source.axis?.businessCalendar\n );\n const type = ChartUtils.getChartType(plotStyle, isBusinessTime);\n const mode = ChartUtils.getPlotlyChartMode(\n plotStyle,\n isLinesVisible ?? undefined,\n isShapesVisible ?? undefined\n );\n const orientation = ChartUtils.getPlotlySeriesOrientation(series);\n const seriesData = ChartUtils.makeSeriesData(\n type,\n mode,\n name,\n showLegend,\n orientation\n );\n\n ChartUtils.addSourcesToSeriesData(\n seriesData,\n plotStyle,\n sources,\n axisTypeMap\n );\n\n ChartUtils.addStylingToSeriesData(\n seriesData,\n plotStyle,\n theme,\n lineColor,\n shapeColor,\n shape,\n shapeSize,\n seriesVisibility\n );\n\n return seriesData;\n }\n\n static addSourcesToSeriesData(\n seriesDataParam: Partial<PlotData>,\n plotStyle: SeriesPlotStyle,\n sources: SeriesDataSource[],\n axisTypeMap: AxisTypeMap\n ): void {\n const seriesData = seriesDataParam;\n for (let k = 0; k < sources.length; k += 1) {\n const source = sources[k];\n const { axis, type: sourceType } = source;\n\n const dataAttributeName = ChartUtils.getPlotlyProperty(\n plotStyle,\n sourceType\n );\n set(seriesData, dataAttributeName, []);\n\n const axisProperty =\n axis != null ? ChartUtils.getAxisPropertyName(axis.type) : null;\n if (axisProperty != null) {\n const axes = axisTypeMap.get(axis.type);\n if (axes) {\n const axisIndex = axes.indexOf(axis);\n const axisIndexString = axisIndex > 0 ? `${axisIndex + 1}` : '';\n seriesData[\n `${axisProperty}axis`\n ] = `${axisProperty}${axisIndexString}`;\n }\n }\n }\n }\n\n static addStylingToSeriesData(\n seriesDataParam: Partial<PlotData>,\n plotStyle: SeriesPlotStyle,\n theme: typeof ChartTheme = ChartTheme,\n lineColor: string | null = null,\n shapeColor: string | null = null,\n shape: string | null = null,\n shapeSize: number | null = null,\n seriesVisibility: 'legendonly' | boolean | null = null\n ): void {\n const seriesData = seriesDataParam;\n // Add some empty objects so we can fill them in later with details without checking for existence\n seriesData.marker = { line: {} }; // border line width on markers\n seriesData.line = {\n width: 1, // default line width for lines, should eventually be able to override\n };\n\n if (plotStyle === dh.plot.SeriesPlotStyle.AREA) {\n seriesData.fill = 'tozeroy';\n } else if (plotStyle === dh.plot.SeriesPlotStyle.STACKED_AREA) {\n seriesData.stackgroup = 'stack';\n } else if (plotStyle === dh.plot.SeriesPlotStyle.STEP) {\n seriesData.line.shape = 'hv'; // plot.ly horizontal then vertical step styling\n } else if (plotStyle === dh.plot.SeriesPlotStyle.HISTOGRAM) {\n // The default histfunc in plotly is 'count', but the data passed up from the API provides explicit x/y values and bins\n // Since it's converted to bar, just set the widths of each bar\n seriesData.width = [];\n\n if (seriesData.marker.line !== undefined) {\n Object.assign(seriesData.marker.line, {\n color: theme.paper_bgcolor,\n width: 1,\n });\n }\n } else if (plotStyle === dh.plot.SeriesPlotStyle.OHLC) {\n (seriesData as Partial<OhclData>).increasing = {\n line: { color: theme.ohlc_increasing },\n };\n (seriesData as Partial<OhclData>).decreasing = {\n line: { color: theme.ohlc_decreasing },\n };\n } else if (plotStyle === dh.plot.SeriesPlotStyle.PIE) {\n seriesData.textinfo = 'label+percent';\n\n // TODO Open DefinitelyTyped/Plotly PR to mark family and size as optional\n // https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/plotly.js/lib/traces/pie.d.ts#L6\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (seriesData as any).outsidetextfont = {\n color: theme.title_color,\n };\n } else if (plotStyle === dh.plot.SeriesPlotStyle.TREEMAP) {\n seriesData.hoverinfo = 'text';\n seriesData.textinfo = 'label+text';\n (seriesData as TreeMapData).tiling = {\n packing: 'squarify',\n pad: 0,\n };\n seriesData.textposition = 'middle center';\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (seriesData as any).outsidetextfont = { color: theme.title_color };\n }\n\n if (lineColor != null) {\n if (plotStyle === dh.plot.SeriesPlotStyle.BAR) {\n seriesData.marker.color = lineColor;\n } else {\n seriesData.line.color = lineColor;\n }\n }\n\n if (shapeColor != null) {\n seriesData.marker.color = shapeColor;\n }\n\n if (shape != null && shape.length > 0) {\n try {\n seriesData.marker.symbol = ChartUtils.getMarkerSymbol(shape);\n } catch (e) {\n log.warn('Unable to handle shape', shape, ':', e);\n }\n }\n\n if (shapeSize != null) {\n seriesData.marker.size = shapeSize * ChartUtils.DEFAULT_MARKER_SIZE;\n }\n\n // Skipping pie charts\n // Pie slice visibility is configured in chart layout instead of series data\n if (seriesVisibility != null && plotStyle !== dh.plot.SeriesPlotStyle.PIE) {\n seriesData.visible = seriesVisibility;\n }\n }\n\n /**\n * Get the Plotly marker symbol for the provided Deephaven shape\n * Deephaven shapes: https://deephaven.io/enterprise/docs/plotting/visual-formatting/#point-formatting\n * Plotly shapes: https://plotly.com/javascript/reference/scattergl/#scattergl-marker-symbol\n * Table of plotly shapes: https://plotly.com/python/marker-style/#custom-marker-symbols\n * @param deephavenShape Deephaven shape to get the marker symbol for\n */\n static getMarkerSymbol(deephavenShape: string): MarkerSymbol {\n switch (deephavenShape) {\n case 'SQUARE':\n return 'square';\n case 'CIRCLE':\n return 'circle';\n case 'DIAMOND':\n return 'diamond';\n case 'UP_TRIANGLE':\n return 'triangle-up';\n case 'DOWN_TRIANGLE':\n return 'triangle-down';\n case 'RIGHT_TRIANGLE':\n return 'triangle-right';\n case 'LEFT_TRIANGLE':\n return 'triangle-left';\n // There don't seem to be any plotly equivalents for ellipse or rectangles\n // Rectangles could be `line-ew`, `line-ns`, or `hourglass` and `bowtie` instead?\n // Ellipse could be `asterisk` or `diamond-wide` instead?\n // Just throw an error, we've already got a bunch of types.\n case 'ELLIPSE':\n case 'HORIZONTAL_RECTANGLE':\n case 'VERTICAL_RECTANGLE':\n default:\n throw new Error(`Unrecognized shape ${deephavenShape}`);\n }\n }\n\n /**\n * Retrieve the axis formats from the provided figure.\n * Currently defaults to just the x/y axes.\n * @param figure The figure to get the axis formats for\n * @param formatter The formatter to use when getting the axis format\n * @returns A map of axis layout property names to axis formats\n */\n static getAxisFormats(\n figure: Figure,\n formatter: Formatter\n ): Map<LayoutAxisKey, Partial<PlotlyAxis>> {\n const axisFormats = new Map();\n const nullFormat = { tickformat: null, ticksuffix: null };\n\n const allAxes = ChartUtils.getAllAxes(figure);\n const axisTypeMap = ChartUtils.groupArray(allAxes, 'type');\n const { charts } = figure;\n\n for (let i = 0; i < charts.length; i += 1) {\n const chart = charts[i];\n\n for (let j = 0; j < chart.series.length; j += 1) {\n const series = chart.series[j];\n const { sources } = series;\n const axisSources = sources.filter(source => source.axis);\n for (let k = 0; k < axisSources.length; k += 1) {\n const source = axisSources[k];\n const { axis } = source;\n const { type: axisType } = axis;\n const typeAxes = axisTypeMap.get(axisType);\n assertNotNull(typeAxes);\n const axisIndex = typeAxes.indexOf(axis);\n const axisProperty = ChartUtils.getAxisPropertyName(axisType);\n if (axisProperty != null) {\n const axisLayoutProperty = ChartUtils.getAxisLayoutProperty(\n axisProperty,\n axisIndex\n );\n\n if (axisFormats.has(axisLayoutProperty)) {\n log.debug(`${axisLayoutProperty} already added.`);\n } else {\n log.debug(`Adding ${axisLayoutProperty} to axisFormats.`);\n const axisFormat = ChartUtils.getPlotlyAxisFormat(\n source,\n formatter\n );\n if (axisFormat === null) {\n axisFormats.set(axisLayoutProperty, nullFormat);\n } else {\n axisFormats.set(axisLayoutProperty, axisFormat);\n\n const { businessCalendar } = axis;\n if (businessCalendar != null) {\n const rangebreaks: Rangebreaks[] = [];\n const {\n businessPeriods,\n businessDays,\n holidays,\n timeZone: calendarTimeZone,\n } = businessCalendar;\n const typeFormatter = formatter?.getColumnTypeFormatter(\n BUSINESS_COLUMN_TYPE\n );\n let formatterTimeZone;\n if (isDateTimeColumnFormatter(typeFormatter)) {\n formatterTimeZone = typeFormatter.dhTimeZone;\n }\n const timeZoneDiff = formatterTimeZone\n ? (calendarTimeZone.standardOffset -\n formatterTimeZone.standardOffset) /\n 60\n : 0;\n if (holidays.length > 0) {\n rangebreaks.push(\n ...ChartUtils.createRangeBreakValuesFromHolidays(\n holidays,\n calendarTimeZone,\n formatterTimeZone\n )\n );\n }\n businessPeriods.forEach(period =>\n rangebreaks.push({\n pattern: 'hour',\n bounds: [\n ChartUtils.periodToDecimal(period.close) + timeZoneDiff,\n ChartUtils.periodToDecimal(period.open) + timeZoneDiff,\n ],\n })\n );\n // If there are seven business days, then there is no weekend\n if (businessDays.length < DAYS.length) {\n ChartUtils.createBoundsFromDays(businessDays).forEach(\n weekendBounds =>\n rangebreaks.push({\n pattern: 'day of week',\n bounds: weekendBounds,\n })\n );\n }\n\n (axisFormat as RangebreakAxisFormat).rangebreaks = rangebreaks;\n }\n\n if (axisFormats.size === chart.axes.length) {\n return axisFormats;\n }\n }\n }\n }\n }\n }\n }\n\n return axisFormats;\n }\n\n static getChartType(\n plotStyle: SeriesPlotStyle,\n isBusinessTime: boolean\n ): PlotType | undefined {\n switch (plotStyle) {\n case dh.plot.SeriesPlotStyle.HISTOGRAM:\n // When reading data from the `Figure`, it already provides bins and values, so rather than using\n // plot.ly to calculate the bins and sum values, just convert it to a bar chart\n return 'bar';\n default:\n return ChartUtils.getPlotlyChartType(plotStyle, isBusinessTime);\n }\n }\n\n /**\n * Return the plotly axis property name\n * @param axisType The axis type to get the property name for\n */\n static getAxisPropertyName(axisType: AxisType): 'x' | 'y' | null {\n switch (axisType) {\n case dh.plot.AxisType.X:\n return 'x';\n case dh.plot.AxisType.Y:\n return 'y';\n default:\n return null;\n }\n }\n\n /**\n * Returns the plotly \"side\" value for the provided axis position\n * @param axisPosition The Iris AxisPosition of the axis\n */\n static getAxisSide(\n axisPosition: AxisPosition\n ): LayoutAxis['side'] | undefined {\n switch (axisPosition) {\n case dh.plot.AxisPosition.BOTTOM:\n return 'bottom';\n case dh.plot.AxisPosition.TOP:\n return 'top';\n case dh.plot.AxisPosition.LEFT:\n return 'left';\n case dh.plot.AxisPosition.RIGHT:\n return 'right';\n default:\n return undefined;\n }\n }\n\n /**\n * Get all axes for a given `Figure`. Iterates through all charts axes and concatenates them.\n * @param figure Figure to get all axes for\n */\n static getAllAxes(figure: Figure): Axis[] {\n return figure.charts.reduce(\n (axes, chart) => [...axes, ...chart.axes],\n [] as Axis[]\n );\n }\n\n /**\n * Retrieve the chart that contains the passed in series from the figure\n * @param figure The figure to retrieve the chart from\n * @param series The series to get the chart for\n */\n static getChartForSeries(figure: Figure, series: Series): Chart | null {\n const { charts } = figure;\n\n for (let i = 0; i < charts.length; i += 1) {\n const chart = charts[i];\n for (let j = 0; j < chart.series.length; j += 1) {\n if (series === chart.series[j]) {\n return chart;\n }\n }\n }\n\n return null;\n }\n\n /**\n * Get an object mapping axis to their ranges\n * @param layout The plotly layout object to get the ranges from\n * @returns An object mapping the axis name to it's range\n */\n static getLayoutRanges(layout: Layout): Record<string, Range[]> {\n const ranges: Record<string, Range[]> = {};\n const keys: (keyof Layout)[] = Object.keys(layout).filter(\n key => key.indexOf('axis') >= 0\n ) as LayoutAxisKey[];\n for (let i = 0; i < keys.length; i += 1) {\n const key = keys[i];\n const value = layout[key];\n if (isRangedPlotlyAxis(value)) {\n // Only want to add the range if it's not autoranged\n ranges[key] = [...(value as PlotlyAxis).range];\n }\n }\n\n return ranges;\n }\n\n /**\n * Update the layout with all the axes information for the provided figure\n * @param figure Figure to update the axes for\n * @param layoutParam Layout object to update in place\n * @param chartAxisRangeParser Function to retrieve the axis range parser\n * @param plotWidth Width of the plot in pixels\n * @param plotHeight Height of the plot in pixels\n * @param theme Theme used for displaying the plot\n */\n static updateFigureAxes(\n layoutParam: Partial<Layout>,\n figure: Figure,\n chartAxisRangeParser?: ChartAxisRangeParser,\n plotWidth = 0,\n plotHeight = 0,\n theme = ChartTheme\n ): void {\n const layout = layoutParam;\n const figureAxes = ChartUtils.getAllAxes(figure);\n for (let i = 0; i < figure.charts.length; i += 1) {\n const chart = figure.charts[i];\n const axisRangeParser = chartAxisRangeParser?.(chart);\n const bounds = ChartUtils.getChartBounds(\n figure,\n chart,\n plotWidth,\n plotHeight\n );\n ChartUtils.updateLayoutAxes(\n layout,\n chart.axes,\n figureAxes,\n plotWidth,\n plotHeight,\n bounds,\n axisRangeParser,\n theme\n );\n }\n\n ChartUtils.removeStaleAxes(layout, figureAxes);\n }\n\n static getChartBounds(\n figure: Figure,\n chart: Chart,\n plotWidth = 0,\n plotHeight = 0\n ): ChartBounds {\n const { cols, rows } = figure;\n const { column, colspan, row, rowspan } = chart;\n\n const endColumn = column + colspan;\n const endRow = row + rowspan;\n const columnSize = 1 / cols;\n const rowSize = 1 / rows;\n const xMarginSize = ChartUtils.AXIS_SIZE_PX / plotWidth;\n const yMarginSize = ChartUtils.AXIS_SIZE_PX / plotHeight;\n\n const bounds: ChartBounds = {\n left: column * columnSize + (column > 0 ? xMarginSize / 2 : 0),\n bottom: row * rowSize + (row > 0 ? yMarginSize / 2 : 0),\n top: endRow * rowSize - (endRow < rows ? yMarginSize / 2 : 0),\n right: endColumn * columnSize - (endColumn < cols ? xMarginSize / 2 : 0),\n };\n\n // Adjust the bounds based on where the legend is\n // For now, always assume the legend is shown on the right\n const axisPositionMap = ChartUtils.groupArray(chart.axes, 'position');\n const rightAxes = axisPositionMap.get(dh.plot.AxisPosition.RIGHT) ?? [];\n if (rightAxes.length > 0) {\n if (plotWidth > 0) {\n bounds.right -=\n (bounds.right - bounds.left) *\n Math.max(\n 0,\n Math.min(\n ChartUtils.LEGEND_WIDTH_PX / plotWidth,\n ChartUtils.MAX_LEGEND_SIZE\n )\n );\n } else {\n bounds.right -=\n (bounds.right - bounds.left) * ChartUtils.DEFAULT_AXIS_SIZE;\n }\n }\n\n return bounds;\n }\n\n /**\n * Updates the axes positions and sizes in the layout object provided.\n * If the axis did not exist in the layout previously, it is created and added.\n * Any axis that no longer exists in axes is removed.\n * With Downsampling enabled, will also update the range on the axis itself as appropriate\n * @param layoutParam The layout object to update\n * @param chartAxes The chart axes to update the layout with\n * @param figureAxes All figure axes to update the layout with\n * @param plotWidth The width of the plot to calculate the axis sizes for\n * @param plotHeight The height of the plot to calculate the axis sizes for\n * @param bounds The bounds for this set of axes\n * @param axisRangeParser A function to retrieve the range parser for a given axis\n */\n static updateLayoutAxes(\n layoutParam: Partial<Layout>,\n chartAxes: Axis[],\n figureAxes: Axis[],\n plotWidth = 0,\n plotHeight = 0,\n bounds: ChartBounds = { left: 0, top: 0, right: 1, bottom: 1 },\n axisRangeParser?: AxisRangeParser,\n theme = ChartTheme\n ): void {\n const xAxisSize =\n plotWidth > 0\n ? Math.max(\n ChartUtils.MIN_AXIS_SIZE,\n Math.min(\n ChartUtils.AXIS_SIZE_PX / plotHeight,\n ChartUtils.MAX_AXIS_SIZE\n )\n )\n : ChartUtils.DEFAULT_AXIS_SIZE;\n const yAxisSize =\n plotHeight > 0\n ? Math.max(\n ChartUtils.MIN_AXIS_SIZE,\n Math.min(\n ChartUtils.AXIS_SIZE_PX / plotWidth,\n ChartUtils.MAX_AXIS_SIZE\n )\n )\n : ChartUtils.DEFAULT_AXIS_SIZE;\n\n const layout = layoutParam;\n const axisPositionMap = ChartUtils.groupArray(chartAxes, 'position');\n const axisTypeMap = ChartUtils.groupArray(chartAxes, 'type');\n const axisTypes = [...axisTypeMap.keys()];\n const figureAxisTypeMap = ChartUtils.groupArray(figureAxes, 'type');\n for (let j = 0; j < axisTypes.length; j += 1) {\n const axisType = axisTypes[j];\n const axisProperty = ChartUtils.getAxisPropertyName(axisType);\n if (axisProperty != null) {\n const typeAxes = axisTypeMap.get(axisType);\n const figureTypeAxes = figureAxisTypeMap.get(axisType);\n const isYAxis = axisType === dh.plot.AxisType.Y;\n const plotSize = isYAxis ? plotHeight : plotWidth;\n\n assertNotNull(typeAxes);\n assertNotNull(figureTypeAxes);\n for (\n let chartAxisIndex = 0;\n chartAxisIndex < typeAxes.length;\n chartAxisIndex += 1\n ) {\n const axis = typeAxes[chartAxisIndex];\n const figureAxisIndex = figureTypeAxes.indexOf(axis);\n const axisLayoutProperty = ChartUtils.getAxisLayoutProperty(\n axisProperty,\n figureAxisIndex\n );\n if (layout[axisLayoutProperty] == null) {\n layout[axisLayoutProperty] = ChartUtils.makeLayoutAxis(\n axisType,\n theme\n );\n }\n\n const layoutAxis = layout[axisLayoutProperty];\n if (layoutAxis != null) {\n ChartUtils.updateLayoutAxis(\n layoutAxis,\n axis,\n chartAxisIndex,\n axisPositionMap,\n xAxisSize,\n yAxisSize,\n bounds\n );\n\n const { range, autorange } = layoutAxis;\n if (\n axisRangeParser != null &&\n range !== undefined &&\n (autorange === undefined || autorange === false)\n ) {\n const rangeParser = axisRangeParser(axis);\n const [rangeStart, rangeEnd] = rangeParser(range as Range);\n\n log.debug(\n 'Setting downsample range',\n plotSize,\n rangeStart,\n rangeEnd\n );\n\n axis.range(plotSize, rangeStart, rangeEnd);\n } else {\n axis.range(plotSize);\n }\n }\n }\n }\n }\n }\n\n /**\n * Remove any axes from the layout param that no longer belong to any series\n * @param layoutParam Layout object to remove stale axes from\n * @param axes All axes in the figure\n */\n static removeStaleAxes(layoutParam: Partial<Layout>, axes: Axis[]): void {\n const layout = layoutParam;\n const figureAxisTypeMap = ChartUtils.groupArray(axes, 'type');\n const figureAxisTypes = [...figureAxisTypeMap.keys()];\n for (let i = 0; i < figureAxisTypes.length; i += 1) {\n const axisType = figureAxisTypes[i];\n const typeAxes = figureAxisTypeMap.get(axisType);\n assertNotNull(typeAxes);\n let axisIndex = typeAxes.length;\n // Delete any axes that may no longer exist\n const axisProperty = ChartUtils.getAxisPropertyName(axisType);\n if (axisProperty != null) {\n let axisLayoutProperty = ChartUtils.getAxisLayoutProperty(\n axisProperty,\n axisIndex\n );\n while (layout[axisLayoutProperty] != null) {\n delete layout[axisLayoutProperty];\n\n axisIndex += 1;\n axisLayoutProperty = ChartUtils.getAxisLayoutProperty(\n axisProperty,\n axisIndex\n );\n }\n }\n }\n }\n\n static getAxisLayoutProperty(\n axisProperty: 'x' | 'y',\n axisIndex: number\n ): LayoutAxisKey {\n const axisIndexString = axisIndex > 0 ? `${axisIndex + 1}` : '';\n return `${axisProperty ?? ''}axis${axisIndexString}` as LayoutAxisKey;\n }\n\n /**\n * Updates the layout axis object in place\n * @param layoutAxisParam The plotly layout axis param\n * @param axis The Iris Axis to update the plotly layout with\n * @param axisIndex The type index for this axis\n * @param axisPositionMap All the axes mapped by position\n * @param axisSize The size of each axis in percent\n * @param bounds The bounds of the axes domains\n */\n static updateLayoutAxis(\n layoutAxisParam: Partial<LayoutAxis>,\n axis: Axis,\n axisIndex: number,\n axisPositionMap: AxisPositionMap,\n xAxisSize: number,\n yAxisSize: number,\n bounds: {\n left: number;\n bottom: number;\n top: number;\n right: number;\n }\n ): void {\n const isYAxis = axis.type === dh.plot.AxisType.Y;\n const axisSize = isYAxis ? yAxisSize : xAxisSize;\n const layoutAxis = layoutAxisParam;\n // Enterprise API returns null for empty axis labels\n // Passing null title text to Plotly results in incorrect axis position, DH-9164\n const label = axis.label ?? '';\n if (\n layoutAxis.title !== undefined &&\n typeof layoutAxis.title !== 'string'\n ) {\n layoutAxis.title.text = label;\n } else {\n layoutAxis.title = { text: label };\n }\n\n if (axis.log) {\n layoutAxis.type = 'log';\n }\n\n layoutAxis.side = ChartUtils.getAxisSide(axis.position);\n\n if (axisIndex > 0) {\n layoutAxis.overlaying =\n ChartUtils.getAxisPropertyName(axis.type) ?? undefined;\n\n const positionAxes = axisPositionMap.get(axis.position) ?? [];\n const sideIndex = positionAxes.indexOf(axis);\n if (sideIndex > 0) {\n layoutAxis.anchor = 'free';\n\n if (axis.position === dh.plot.AxisPosition.RIGHT) {\n layoutAxis.position =\n bounds.right + (sideIndex - positionAxes.length + 1) * axisSize;\n } else if (axis.position === dh.plot.AxisPosition.TOP) {\n layoutAxis.position =\n bounds.top + (sideIndex - positionAxes.length + 1) * axisSize;\n } else if (axis.position === dh.plot.AxisPosition.BOTTOM) {\n layoutAxis.position =\n bounds.bottom + (positionAxes.length - sideIndex + 1) * axisSize;\n } else if (axis.position === dh.plot.AxisPosition.LEFT) {\n layoutAxis.position =\n bounds.left + (positionAxes.length - sideIndex + 1) * axisSize;\n }\n }\n } else if (axis.type === dh.plot.AxisType.X) {\n const leftAxes = axisPositionMap.get(dh.plot.AxisPosition.LEFT) || [];\n const rightAxes = axisPositionMap.get(dh.plot.AxisPosition.RIGHT) || [];\n const left = Math.max(\n bounds.left,\n bounds.left + (leftAxes.length - 1) * yAxisSize\n );\n const right = Math.min(\n bounds.right - (rightAxes.length - 1) * yAxisSize,\n bounds.right\n );\n layoutAxis.domain = [left, right];\n } else if (axis.type === dh.plot.AxisType.Y) {\n const bottomAxes = axisPositionMap.get(dh.plot.AxisPosition.BOTTOM) || [];\n const topAxes = axisPositionMap.get(dh.plot.AxisPosition.TOP) || [];\n const bottom = Math.max(\n bounds.bottom,\n bounds.bottom + (bottomAxes.length - 1) * xAxisSize\n );\n const top = Math.min(\n bounds.top - (topAxes.length - 1) * xAxisSize,\n bounds.top\n );\n layoutAxis.domain = [bottom, top];\n }\n }\n\n /**\n * Converts an open or close period to a declimal. e.g '09:30\" to 9.5\n *\n * @param period the open or close value of the period\n */\n static periodToDecimal(period: string): number {\n const values = period.split(':');\n return Number(values[0]) + Number(values[1]) / 60;\n }\n\n /**\n * Creates range break bounds for plotly from business days.\n * For example a standard business week of ['MONDAY','TUESDAY','WEDNESDAY','THURSDAY','FRIDAY']\n * will result in [[6,1]] meaning close on Saturday and open on Monday.\n * If you remove Wednesday from the array, then you get two closures [[6, 1], [3, 4]]\n *\n * @param businessDays the days to display on the x-axis\n */\n static createBoundsFromDays(businessDays: string[]): Range[] {\n const businessDaysInt = businessDays.map(day => DAYS.indexOf(day));\n const nonBusinessDaysInt = DAYS.filter(\n day => !businessDays.includes(day)\n ).map(day => DAYS.indexOf(day));\n // These are the days when business reopens (e.g. Monday after a weekend)\n const reopenDays = new Set<number>();\n nonBusinessDaysInt.forEach(closed => {\n for (let i = closed + 1; i < closed + DAYS.length; i += 1) {\n const adjustedDay = i % DAYS.length;\n if (businessDaysInt.includes(adjustedDay)) {\n reopenDays.add(adjustedDay);\n break;\n }\n }\n });\n const boundsArray: Range[] = [];\n // For each reopen day, find the furthest previous closed day\n reopenDays.forEach(open => {\n for (let i = open - 1; i > open - DAYS.length; i -= 1) {\n const adjustedDay = i < 0 ? i + DAYS.length : i;\n if (businessDaysInt.includes(adjustedDay)) {\n const closedDay = (adjustedDay + 1) % 7;\n boundsArray.push([closedDay, open]);\n break;\n }\n }\n });\n return boundsArray;\n }\n\n /**\n * Creates an array of range breaks for all holidays.\n *\n * @param holidays an array of holidays\n * @param calendarTimeZone the time zone for the business calendar\n * @param formatterTimeZone the time zone for the formatter\n */\n static createRangeBreakValuesFromHolidays(\n holidays: Holiday[],\n calendarTimeZone: TimeZone,\n formatterTimeZone?: TimeZone\n ): Rangebreaks[] {\n const fullHolidays: string[] = [];\n const partialHolidays: {\n values: string[];\n dvalue: number;\n }[] = [];\n holidays.forEach(holiday => {\n if (holiday.businessPeriods.length > 0) {\n partialHolidays.push(\n ...ChartUtils.createPartialHoliday(\n holiday,\n calendarTimeZone,\n formatterTimeZone\n )\n );\n } else {\n fullHolidays.push(\n ChartUtils.createFullHoliday(\n holiday,\n calendarTimeZone,\n formatterTimeZone\n )\n );\n }\n });\n return [{ values: fullHolidays }, ...partialHolidays];\n }\n\n /**\n * Creates the range break value for a full holiday. A full holiday is day that has no business periods.\n *\n * @param holiday the full holiday\n * @param calendarTimeZone the time zone for the business calendar\n * @param formatterTimeZone the time zone for the formatter\n */\n static createFullHoliday(\n holiday: Holiday,\n calendarTimeZone: TimeZone,\n formatterTimeZone?: TimeZone\n ): string {\n return ChartUtils.adjustDateForTimeZone(\n `${holiday.date.toString()} 00:00:00.000000`,\n calendarTimeZone,\n formatterTimeZone\n );\n }\n\n /**\n * Creates the range break for a partial holiday. A partial holiday is holiday with business periods\n * that are different than the default business periods.\n *\n * @param holiday the partial holiday\n * @param calendarTimeZone the time zone for the business calendar\n * @param formatterTimeZone the time zone for the formatter\n */\n static createPartialHoliday(\n holiday: Holiday,\n calendarTimeZone: TimeZone,\n formatterTimeZone?: TimeZone\n ): {\n values: string[];\n dvalue: number;\n }[] {\n // If a holiday has business periods {open1, close1} and {open2, close2}\n // This will generate range breaks for:\n // closed from 00:00 to open1\n // closed from close1 to open2\n // closed from close2 to 23:59:59.999999\n const dateString = holiday.date.toString();\n const closedPeriods = ['00:00'];\n holiday.businessPeriods.forEach(period => {\n closedPeriods.push(period.open);\n closedPeriods.push(period.close);\n });\n // To go up to 23:59:59.999999, we calculate the dvalue using 24 - close\n closedPeriods.push('24:00');\n\n const rangeBreaks = [];\n for (let i = 0; i < closedPeriods.length; i += 2) {\n const startClose = closedPeriods[i];\n const endClose = closedPeriods[i + 1];\n // Skip over any periods where start and close are the same (zero hours)\n if (startClose !== endClose) {\n const values = [\n ChartUtils.adjustDateForTimeZone(\n `${dateString} ${startClose}:00.000000`,\n calendarTimeZone,\n formatterTimeZone\n ),\n ];\n const dvalue =\n MILLIS_PER_HOUR *\n (ChartUtils.periodToDecimal(endClose) -\n ChartUtils.periodToDecimal(startClose));\n rangeBreaks.push({ values, dvalue });\n }\n }\n return rangeBreaks;\n }\n\n /**\n * Adjusts a date string from the calendar time zone to the formatter time zone.\n *\n * @param dateString the date string\n * @param calendarTimeZone the time zone for the business calendar\n * @param formatterTimeZone the time zone for the formatter\n */\n static adjustDateForTimeZone(\n dateString: string,\n calendarTimeZone: TimeZone,\n formatterTimeZone?: TimeZone\n ): string {\n if (\n formatterTimeZone &&\n formatterTimeZone.standardOffset !== calendarTimeZone.standardOffset\n ) {\n return ChartUtils.unwrapValue(\n ChartUtils.wrapValue(\n dateString,\n BUSINESS_COLUMN_TYPE,\n calendarTimeZone\n ),\n formatterTimeZone\n ) as string;\n }\n return dateString;\n }\n\n /**\n * Groups an array and returns a map\n * @param array The object to group\n * @param property The property name to group by\n * @returns A map containing the items grouped by their values for the property\n */\n static groupArray<T, P extends keyof T>(\n array: T[],\n property: P\n ): Map<T[P], T[]> {\n return array.reduce((result, item) => {\n const key = item[property];\n const group: T[] = result.get(key) ?? [];\n group.push(item);\n result.set(key, group);\n return result;\n }, new Map());\n }\n\n /**\n * Unwraps a value provided from API to a value plotly can understand\n * Eg. Unwraps DateWrapper, LongWrapper objects.\n */\n static unwrapValue(value: unknown, timeZone?: TimeZone): unknown {\n if (value != null) {\n if (isDateWrapper(value)) {\n return dh.i18n.DateTimeFormat.format(\n ChartUtils.DATE_FORMAT,\n value,\n timeZone\n );\n }\n\n if (isLongWrapper(value)) {\n return value.asNumber();\n }\n }\n\n return value;\n }\n\n /**\n *\n * @param value The value to wrap up\n * @param columnType The type of column this value is from\n * @param timeZone The time zone if applicable\n */\n static wrapValue(\n value: unknown,\n columnType: string,\n timeZone: TimeZone | null = null\n ): unknown {\n if (TableUtils.isDateType(columnType) && typeof value === 'string') {\n // Need to limit the format to the actual length of the string range set in plotly\n // Otherwise parse will fail\n const text = value;\n const format = ChartUtils.DATE_FORMAT.substr(0, value.length);\n const date = dh.i18n.DateTimeFormat.parse(format, text);\n if (!timeZone) {\n return date;\n }\n\n // IDS-5994 Due to date parsing, time zone, and daylight savings shenanigans, we need\n // to pass the actual offset with the time to have it parse correctly.\n // However, the offset can change based on the date because of Daylight Savings\n // So we end up parsing the date multiple times. And curse daylight savings.\n const tzFormat = `${format} Z`;\n const estimatedOffset = dh.i18n.DateTimeFormat.format(\n 'Z',\n date,\n timeZone\n );\n const estimatedDate = dh.i18n.DateTimeFormat.parse(\n tzFormat,\n `${text} ${estimatedOffset}`\n );\n const offset = dh.i18n.DateTimeFormat.format(\n 'Z',\n estimatedDate,\n timeZone\n );\n return dh.i18n.DateTimeFormat.parse(tzFormat, `${text} ${offset}`);\n }\n\n return value;\n }\n\n static makeLayoutAxis(\n type: AxisType,\n theme = ChartTheme\n ): Partial<LayoutAxis> {\n const axis = {\n automargin: true,\n gridcolor: theme.gridcolor,\n linecolor: theme.linecolor,\n rangeslider: { visible: false },\n showline: true,\n ticklen: 5, // act as padding, can't find a tick padding\n tickcolor: theme.paper_bgcolor, // hide ticks as padding\n tickfont: {\n color: theme.zerolinecolor,\n },\n title: {\n font: {\n color: theme.title_color,\n },\n },\n };\n\n if (type === dh.plot.AxisType.X) {\n Object.assign(axis, {\n showgrid: true,\n });\n } else if (type === dh.plot.AxisType.Y) {\n Object.assign(axis, {\n zerolinecolor: theme.zerolinecolor,\n zerolinewidth: 2,\n });\n }\n\n return axis;\n }\n\n /**\n * Parses the colorway property of a theme and returns an array of colors\n * Theme could have a single string with space separated colors or an array of strings representing the colorway\n * @param theme The theme to get colorway from\n * @returns Colorway array for the theme\n */\n static getColorwayFromTheme(theme = ChartTheme): string[] {\n let colorway: string[] = [];\n if (theme.colorway) {\n if (Array.isArray(theme.colorway)) {\n colorway = theme.colorway;\n } else if (typeof theme.colorway === 'string') {\n colorway = theme.colorway.split(' ');\n } else {\n log.warn(`Unable to handle colorway property: ${theme.colorway}`);\n }\n }\n\n return colorway;\n }\n\n static makeDefaultLayout(theme = ChartTheme): Partial<Layout> {\n const layout: Partial<Layout> = {\n ...theme,\n autosize: true,\n colorway: ChartUtils.getColorwayFromTheme(theme),\n font: {\n family: \"'Fira Sans', sans-serif\",\n },\n title: {\n font: {\n color: theme.title_color,\n },\n yanchor: 'top',\n pad: { ...ChartUtils.DEFAULT_TITLE_PADDING },\n y: 1,\n },\n legend: {\n font: {\n color: theme.title_color,\n },\n },\n margin: { ...ChartUtils.DEFAULT_MARGIN },\n xaxis: ChartUtils.makeLayoutAxis(dh.plot.AxisType.X, theme),\n yaxis: ChartUtils.makeLayoutAxis(dh.plot.AxisType.Y, theme),\n };\n layout.datarevision = 0;\n return layout;\n }\n\n /**\n * Hydrate settings from a JSONable object\n * @param settings Dehydrated settings\n */\n static hydrateSettings(\n settings: ChartModelSettings\n ): Omit<ChartModelSettings, 'type'> & { type: SeriesPlotStyle } {\n return {\n ...settings,\n type: dh.plot.SeriesPlotStyle[settings.type],\n };\n }\n\n static titleFromSettings(settings: ChartModelSettings): string {\n const {\n series,\n xAxis,\n title = `${series.join(', ')} by ${xAxis}`,\n } = settings;\n\n return title;\n }\n\n /**\n * Creates the Figure settings from the Chart Builder settings\n * This should be deprecated at some point, and have Chart Builder create the figure settings directly.\n * This logic will still need to exist to translate existing charts, but could be part of a migration script\n * to translate the data.\n * Change when we decide to add more functionality to the Chart Builder.\n * @param settings The chart builder settings\n * @param settings.title The title for this figure\n * @param settings.xAxis The name of the column to use for the x-axis\n * @param settings.series The name of the columns to use for the series of this figure\n * @param settings.type The plot style for this figure\n */\n static makeFigureSettings(\n settings: ChartModelSettings,\n table: TableTemplate\n ): {\n charts: {\n chartType: string;\n axes: { formatType: string; type: string; position: string }[];\n series: {\n plotStyle: string;\n name: string;\n dataSources: {\n type: string;\n columnName: string;\n axis: { formatType: string; type: string; position: string };\n table: TableTemplate;\n }[];\n }[];\n }[];\n title: string;\n } {\n const { series, xAxis: settingsAxis, type } = settings;\n const title = ChartUtils.titleFromSettings(settings);\n const xAxis = {\n formatType: `${dh.plot.AxisFormatType.NUMBER}`,\n type: `${dh.plot.AxisType.X}`,\n position: `${dh.plot.AxisPosition.BOTTOM}`,\n };\n const yAxis = {\n formatType: `${dh.plot.AxisFormatType.NUMBER}`,\n type: `${dh.plot.AxisType.Y}`,\n position: `${dh.plot.AxisPosition.LEFT}`,\n };\n\n return {\n charts: [\n {\n chartType: `${dh.plot.ChartType.XY}`,\n axes: [xAxis, yAxis],\n series: series.map(name => ({\n plotStyle: `${type}`,\n name,\n dataSources: [\n {\n type: `${dh.plot.SourceType.X}`,\n columnName: settingsAxis,\n axis: xAxis,\n table,\n },\n {\n type: `${dh.plot.SourceType.Y}`,\n columnName: name,\n axis: yAxis,\n table,\n },\n ],\n })),\n },\n ],\n title,\n };\n }\n}\n\nexport default ChartUtils;\n","import React, { Component, ReactElement, RefObject } from 'react';\nimport deepEqual from 'deep-equal';\nimport memoize from 'memoize-one';\nimport {\n vsLoading,\n dhGraphLineDown,\n dhWarningFilled,\n IconDefinition,\n} from '@deephaven/icons';\nimport {\n Formatter,\n FormatterUtils,\n DateUtils,\n DateTimeColumnFormatterOptions,\n DecimalColumnFormatterOptions,\n IntegerColumnFormatterOptions,\n FormattingRule,\n ColumnFormatSettings,\n DateTimeFormatSettings,\n} from '@deephaven/jsapi-utils';\nimport Log from '@deephaven/log';\nimport { Layout, Icon, PlotData } from 'plotly.js';\nimport Plotly from './plotly/Plotly';\nimport Plot from './plotly/Plot';\nimport ChartModel from './ChartModel';\nimport ChartUtils, { ChartModelSettings } from './ChartUtils';\nimport './Chart.scss';\n\nconst log = Log.module('Chart');\n\ntype FormatterSettings = ColumnFormatSettings &\n DateTimeFormatSettings & {\n decimalFormatOptions?: DecimalColumnFormatterOptions;\n integerFormatOptions?: IntegerColumnFormatterOptions;\n };\n\ninterface ChartProps {\n model: ChartModel;\n settings: FormatterSettings;\n isActive: boolean;\n onDisconnect: () => void;\n onReconnect: () => void;\n onUpdate: (obj: { isLoading: boolean }) => void;\n onError: (error: Error) => void;\n onSettingsChanged: (settings: Partial<ChartModelSettings>) => void;\n}\n\ninterface ChartState {\n data: Partial<PlotData>[] | null;\n downsamplingError: unknown;\n isDownsampleFinished: boolean;\n isDownsampleInProgress: boolean;\n isDownsamplingDisabled: boolean;\n layout: Partial<Layout>;\n revision: number;\n}\n\nexport class Chart extends Component<ChartProps, ChartState> {\n static defaultProps = {\n isActive: true,\n settings: {\n timeZone: 'America/New_York',\n defaultDateTimeFormat: DateUtils.FULL_DATE_FORMAT,\n showTimeZone: false,\n showTSeparator: true,\n formatter: [],\n },\n onDisconnect: (): void => undefined,\n onReconnect: (): void => undefined,\n onUpdate: (): void => undefined,\n onError: (): void => undefined,\n onSettingsChanged: (): void => undefined,\n };\n\n /**\n * Convert a font awesome icon definition to a plotly icon definition\n * @param faIcon The icon to convert\n */\n static convertIcon(faIcon: IconDefinition): Icon {\n const [width, , , , path] = faIcon.icon;\n // By default the icons are flipped upside down, so we need to add our own transform\n // https://github.com/plotly/plotly.js/issues/1335\n const stringPath = `${path}`;\n return {\n width,\n path: stringPath,\n ascent: width,\n descent: 0,\n transform: `matrix(1, 0, 0, 1, 0, 0)`,\n };\n }\n\n static downsampleButtonTitle(\n isDownsampleInProgress: boolean,\n isDownsamplingDisabled: boolean\n ): string {\n if (isDownsampleInProgress) {\n return 'Downsampling in progress...';\n }\n\n return isDownsamplingDisabled\n ? 'Downsampling disabled, click to enable'\n : 'Downsampling enabled, click to disable';\n }\n\n static downsampleButtonAttr(\n isDownsampleInProgress: boolean,\n isDownsamplingDisabled: boolean\n ): string | undefined {\n if (isDownsampleInProgress) {\n return 'animation-spin';\n }\n\n return isDownsamplingDisabled ? undefined : 'fill-active';\n }\n\n constructor(props: ChartProps) {\n super(props);\n\n this.handleAfterPlot = this.handleAfterPlot.bind(this);\n this.handleDownsampleClick = this.handleDownsampleClick.bind(this);\n this.handleModelEvent = this.handleModelEvent.bind(this);\n this.handlePlotUpdate = this.handlePlotUpdate.bind(this);\n this.handleRelayout = this.handleRelayout.bind(this);\n this.handleRestyle = this.handleRestyle.bind(this);\n\n this.plot = React.createRef();\n this.plotWrapper = React.createRef();\n this.columnFormats = [];\n this.dateTimeFormatterOptions = {};\n this.decimalFormatOptions = {};\n this.integerFormatOptions = {};\n this.isSubscribed = false;\n this.isLoadedFired = false;\n this.currentSeries = 0;\n\n this.state = {\n data: null,\n downsamplingError: null,\n isDownsampleFinished: false,\n isDownsampleInProgress: false,\n isDownsamplingDisabled: false,\n layout: {\n datarevision: 0,\n },\n revision: 0,\n };\n }\n\n componentDidMount(): void {\n // Need to make sure the model dimensions are up to date before initializing the data\n this.updateDimensions();\n this.updateModelDimensions();\n\n this.initData();\n this.initFormatter();\n\n const { isActive } = this.props;\n if (isActive) {\n this.subscribe();\n }\n }\n\n componentDidUpdate(prevProps: ChartProps): void {\n const { isActive, settings } = this.props;\n this.updateFormatterSettings(settings as FormatterSettings);\n\n if (isActive !== prevProps.isActive) {\n if (isActive) {\n this.subscribe();\n } else {\n this.unsubscribe();\n }\n }\n }\n\n componentWillUnmount(): void {\n this.unsubscribe();\n }\n\n currentSeries: number;\n\n plot: RefObject<typeof Plot>;\n\n plotWrapper: RefObject<HTMLDivElement>;\n\n columnFormats?: FormattingRule[];\n\n dateTimeFormatterOptions?: DateTimeColumnFormatterOptions;\n\n decimalFormatOptions: DecimalColumnFormatterOptions;\n\n integerFormatOptions: IntegerColumnFormatterOptions;\n\n rect?: DOMRect;\n\n ranges?: unknown;\n\n isSubscribed: boolean;\n\n isLoadedFired: boolean;\n\n getCachedConfig = memoize(\n (\n downsamplingError: unknown,\n isDownsampleFinished: boolean,\n isDownsampleInProgress: boolean,\n isDownsamplingDisabled: boolean\n ) => {\n const customButtons = [];\n const hasDownsampleError = Boolean(downsamplingError);\n if (hasDownsampleError) {\n customButtons.push({\n name: `Downsampling failed: ${downsamplingError}`,\n click: () => undefined,\n icon: Chart.convertIcon(dhWarningFilled),\n attr: 'fill-warning',\n });\n }\n\n if (\n isDownsampleFinished ||\n isDownsampleInProgress ||\n isDownsamplingDisabled ||\n hasDownsampleError\n ) {\n const name = Chart.downsampleButtonTitle(\n isDownsampleInProgress,\n isDownsamplingDisabled\n );\n const attr = Chart.downsampleButtonAttr(\n isDownsampleInProgress,\n isDownsamplingDisabled\n );\n\n const icon = isDownsampleInProgress ? vsLoading : dhGraphLineDown;\n customButtons.push({\n name,\n icon: Chart.convertIcon(icon),\n click: this.handleDownsampleClick,\n attr,\n });\n }\n\n return {\n displaylogo: false,\n\n // Display the mode bar if there's an error or downsampling so user can see progress\n // Yes, the value is a boolean or the string 'hover': https://github.com/plotly/plotly.js/blob/master/src/plot_api/plot_config.js#L249\n displayModeBar:\n // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n isDownsampleInProgress || hasDownsampleError ? true : 'hover',\n\n // Each array gets grouped together in the mode bar\n modeBarButtons: [\n customButtons,\n ['toImage'],\n ['zoom2d', 'pan2d'],\n ['zoomIn2d', 'zoomOut2d', 'autoScale2d', 'resetScale2d'],\n ],\n };\n }\n );\n\n getPlotRect(): DOMRect | null {\n return this.plotWrapper.current?.getBoundingClientRect() ?? null;\n }\n\n initData(): void {\n const { model } = this.props;\n const { layout } = this.state;\n this.setState({\n data: model.getData(),\n layout: {\n ...layout,\n ...model.getLayout(),\n },\n });\n }\n\n subscribe(): void {\n if (this.isSubscribed) {\n return;\n }\n\n const { model } = this.props;\n if (!this.rect || this.rect.width === 0 || this.rect.height === 0) {\n log.debug2('Delaying subscription until model dimensions are set');\n return;\n }\n model.subscribe(this.handleModelEvent);\n this.isSubscribed = true;\n }\n\n unsubscribe(): void {\n if (!this.isSubscribed) {\n return;\n }\n\n const { model } = this.props;\n model.unsubscribe(this.handleModelEvent);\n this.isSubscribed = false;\n }\n\n handleAfterPlot(): void {\n if (this.plot.current != null) {\n // TODO: Translate whatever Don was doing in plotting.js in the afterplot here so that area graphs show up properly\n }\n }\n\n handleDownsampleClick(): void {\n this.setState(\n ({ isDownsamplingDisabled }) => ({\n downsamplingError: null,\n isDownsampleInProgress: false,\n isDownsampleFinished: false,\n isDownsamplingDisabled: !isDownsamplingDisabled,\n }),\n () => {\n const { model } = this.props;\n const { isDownsamplingDisabled } = this.state;\n model.setDownsamplingDisabled(isDownsamplingDisabled);\n }\n );\n }\n\n handleModelEvent(event: CustomEvent): void {\n const { type, detail } = event;\n log.debug2('Received data update', type, detail);\n\n switch (type) {\n case ChartModel.EVENT_UPDATED: {\n this.currentSeries += 1;\n this.setState(state => {\n const { layout, revision } = state;\n if (typeof layout.datarevision === 'number') {\n layout.datarevision += 1;\n }\n return {\n data: detail,\n layout,\n revision: revision + 1,\n };\n });\n\n const { onUpdate } = this.props;\n onUpdate({ isLoading: !this.isLoadedFired });\n break;\n }\n case ChartModel.EVENT_LOADFINISHED: {\n const { onUpdate } = this.props;\n this.isLoadedFired = true;\n onUpdate({ isLoading: false });\n break;\n }\n case ChartModel.EVENT_DISCONNECT: {\n const { onDisconnect } = this.props;\n onDisconnect();\n break;\n }\n case ChartModel.EVENT_RECONNECT: {\n const { onReconnect } = this.props;\n onReconnect();\n break;\n }\n case ChartModel.EVENT_DOWNSAMPLESTARTED: {\n this.setState({\n isDownsampleFinished: false,\n isDownsampleInProgress: true,\n downsamplingError: null,\n });\n break;\n }\n case ChartModel.EVENT_DOWNSAMPLEFINISHED: {\n this.setState({\n isDownsampleFinished: true,\n isDownsampleInProgress: false,\n downsamplingError: null,\n });\n break;\n }\n case ChartModel.EVENT_DOWNSAMPLENEEDED:\n case ChartModel.EVENT_DOWNSAMPLEFAILED: {\n const downsamplingError = detail.message ?? detail;\n this.setState({\n isDownsampleFinished: false,\n isDownsampleInProgress: false,\n isDownsamplingDisabled: false,\n downsamplingError,\n });\n\n const { onError } = this.props;\n onError(new Error(downsamplingError));\n break;\n }\n default:\n log.debug('Unknown event type', type, event);\n }\n }\n\n handlePlotUpdate(figure: { layout: Layout }): void {\n // User could have modified zoom/pan here, update the model dimensions\n // We don't need to update the datarevision, as we don't have any data changes\n // until an update comes back from the server anyway\n const { layout } = figure;\n const ranges = ChartUtils.getLayoutRanges(layout);\n\n const isRangesChanged = !deepEqual(ranges, this.ranges);\n\n if (isRangesChanged) {\n this.ranges = ranges;\n\n this.updateModelDimensions(true);\n }\n }\n\n handleRelayout(changes: { hiddenlabels?: string[] }): void {\n log.debug('handleRelayout', changes);\n if (changes.hiddenlabels != null) {\n const { onSettingsChanged } = this.props;\n // Pie charts store series visibility in layout.hiddenlabels and trigger relayout on changes\n // Series visibility for other types of charts is handled in handleRestyle\n const hiddenSeries = [...changes.hiddenlabels];\n onSettingsChanged({ hiddenSeries });\n }\n\n this.updateModelDimensions();\n }\n\n handleRestyle([changes, seriesIndexes]: [\n Record<string, unknown>,\n number[]\n ]): void {\n log.debug('handleRestyle', changes, seriesIndexes);\n if (Object.keys(changes).includes('visible')) {\n const { data } = this.state;\n const { onSettingsChanged } = this.props;\n if (data != null) {\n const hiddenSeries = data.reduce(\n (acc: string[], { name, visible }) =>\n name != null && visible === 'legendonly' ? [...acc, name] : acc,\n []\n );\n onSettingsChanged({ hiddenSeries });\n }\n }\n }\n\n /**\n * Update the models dimensions and ranges.\n * Note that this will update it all whether the plot size changes OR the range\n * the user is looking at has changed (eg. panning/zooming).\n * Could update each independently, but doing them at the same time keeps the\n * ChartModel API a bit cleaner.\n * @param force Force a change even if the chart dimensions haven't changed (eg. after pan/zoom)\n */\n updateModelDimensions(force = false): void {\n const rect = this.getPlotRect();\n if (!rect) {\n log.warn('Unable to get plotting rect');\n return;\n }\n\n const isRectChanged =\n !this.rect ||\n this.rect.width !== rect.width ||\n this.rect.height !== rect.height;\n\n if (isRectChanged || force) {\n this.rect = rect;\n\n const { isActive, model } = this.props;\n model.setDimensions(rect);\n // We may need to resubscribe if dimensions were too small before\n if (isActive) {\n this.subscribe();\n }\n }\n }\n\n initFormatter(): void {\n const { settings } = this.props;\n this.updateFormatterSettings(settings as FormatterSettings);\n }\n\n updateFormatterSettings(settings: FormatterSettings): void {\n const columnFormats = FormatterUtils.getColumnFormats(settings);\n const dateTimeFormatterOptions = FormatterUtils.getDateTimeFormatterOptions(\n settings\n );\n const { decimalFormatOptions = {}, integerFormatOptions = {} } = settings;\n\n if (\n !deepEqual(this.columnFormats, columnFormats) ||\n !deepEqual(this.dateTimeFormatterOptions, dateTimeFormatterOptions) ||\n !deepEqual(this.decimalFormatOptions, decimalFormatOptions) ||\n !deepEqual(this.integerFormatOptions, integerFormatOptions)\n ) {\n this.columnFormats = FormatterUtils.getColumnFormats(settings);\n this.dateTimeFormatterOptions = dateTimeFormatterOptions;\n this.decimalFormatOptions = decimalFormatOptions;\n this.integerFormatOptions = integerFormatOptions;\n this.updateFormatter();\n }\n }\n\n updateFormatter(): void {\n const formatter = new Formatter(\n this.columnFormats,\n this.dateTimeFormatterOptions,\n this.decimalFormatOptions,\n this.integerFormatOptions\n );\n\n const { model } = this.props;\n model.setFormatter(formatter);\n }\n\n updateDimensions(): void {\n const rect = this.getPlotRect();\n if (\n this.plot.current != null &&\n rect != null &&\n rect.width > 0 &&\n rect.height > 0\n ) {\n // Call relayout to resize avoiding the debouncing plotly does\n // https://github.com/plotly/plotly.js/issues/2769#issuecomment-402099552\n Plotly.relayout(this.plot.current.el, { autosize: true }).catch(\n (e: unknown) => {\n log.debug('Unable to resize, promise rejected', e);\n }\n );\n }\n }\n\n render(): ReactElement {\n const {\n data,\n downsamplingError,\n isDownsampleFinished,\n isDownsampleInProgress,\n isDownsamplingDisabled,\n layout,\n revision,\n } = this.state;\n const config = this.getCachedConfig(\n downsamplingError,\n isDownsampleFinished,\n isDownsampleInProgress,\n isDownsamplingDisabled\n );\n const isPlotShown = data != null;\n return (\n <div className=\"h-100 w-100 chart-wrapper\" ref={this.plotWrapper}>\n {isPlotShown && (\n <Plot\n ref={this.plot}\n data={data}\n layout={layout}\n revision={revision}\n config={config}\n onAfterPlot={this.handleAfterPlot}\n onError={log.error}\n onRelayout={this.handleRelayout}\n onUpdate={this.handlePlotUpdate}\n onRestyle={this.handleRestyle}\n useResizeHandler\n style={{ height: '100%', width: '100%' }}\n />\n )}\n </div>\n );\n }\n}\n\nexport default Chart;\n","/* eslint class-methods-use-this: \"off\" */\nimport memoize from 'memoizee';\nimport debounce from 'lodash.debounce';\nimport set from 'lodash.set';\nimport dh, {\n Axis,\n Chart,\n Figure,\n OneClick,\n Series,\n SourceType,\n} from '@deephaven/jsapi-shim';\nimport Log from '@deephaven/log';\nimport { Range } from '@deephaven/utils';\nimport { Layout, PlotData } from 'plotly.js';\nimport type {\n DateTimeColumnFormatter,\n Formatter,\n} from '@deephaven/jsapi-utils';\nimport ChartModel, { ChartEvent, FilterColumnMap } from './ChartModel';\nimport ChartUtils, { AxisTypeMap, ChartModelSettings } from './ChartUtils';\nimport ChartTheme from './ChartTheme';\n\nconst log = Log.module('FigureChartModel');\n\n/**\n * Takes a Figure object from a widget to make a model for a chart\n */\nclass FigureChartModel extends ChartModel {\n static ADD_SERIES_DEBOUNCE = 50;\n\n /**\n * @param figure The figure object created by the API\n * @param settings Chart settings\n */\n constructor(\n figure: Figure,\n settings: Partial<ChartModelSettings> = {},\n theme: typeof ChartTheme = ChartTheme\n ) {\n super();\n\n this.handleFigureUpdated = this.handleFigureUpdated.bind(this);\n this.handleFigureDisconnected = this.handleFigureDisconnected.bind(this);\n this.handleFigureReconnected = this.handleFigureReconnected.bind(this);\n this.handleFigureSeriesAdded = this.handleFigureSeriesAdded.bind(this);\n this.handleDownsampleStart = this.handleDownsampleStart.bind(this);\n this.handleDownsampleFinish = this.handleDownsampleFinish.bind(this);\n this.handleDownsampleFail = this.handleDownsampleFail.bind(this);\n this.handleDownsampleNeeded = this.handleDownsampleNeeded.bind(this);\n this.handleRequestFailed = this.handleRequestFailed.bind(this);\n\n this.figure = figure;\n this.settings = settings;\n this.theme = theme;\n this.data = [];\n const template = { data: {}, layout: ChartUtils.makeDefaultLayout(theme) };\n this.layout = {\n grid: {\n rows: figure.rows,\n columns: figure.cols,\n pattern: 'independent',\n },\n template,\n };\n this.seriesDataMap = new Map();\n this.pendingSeries = [];\n this.oneClicks = [];\n this.filterColumnMap = new Map();\n this.lastFilter = new Map();\n this.isConnected = true; // Assume figure is connected to start\n this.seriesToProcess = new Set();\n\n this.setTitle(this.getDefaultTitle());\n this.initAllSeries();\n this.updateAxisPositions();\n this.startListeningFigure();\n }\n\n figure: Figure;\n\n settings: Partial<ChartModelSettings>;\n\n theme: typeof ChartTheme;\n\n data: Partial<PlotData>[];\n\n layout: Partial<Layout>;\n\n seriesDataMap: Map<\n string,\n Partial<PlotData> & {\n xLow?: number[];\n xHigh?: number[];\n yLow?: number[];\n yHigh?: number[];\n }\n >;\n\n pendingSeries: Series[];\n\n oneClicks: OneClick[];\n\n filterColumnMap: FilterColumnMap;\n\n lastFilter: Map<string, string>;\n\n isConnected: boolean; // Assume figure is connected to start\n\n seriesToProcess;\n\n close(): void {\n this.figure.close();\n this.addPendingSeries.cancel();\n this.stopListeningFigure();\n }\n\n getDefaultTitle(): string {\n if (this.figure.charts.length > 0) {\n const chart = this.figure.charts[0];\n return chart.title;\n }\n\n return '';\n }\n\n initAllSeries(): void {\n this.oneClicks = [];\n this.filterColumnMap.clear();\n\n const { charts } = this.figure;\n const axes = ChartUtils.getAllAxes(this.figure);\n const activeSeriesNames: string[] = [];\n for (let i = 0; i < charts.length; i += 1) {\n const chart = charts[i];\n\n for (let j = 0; j < chart.series.length; j += 1) {\n const series = chart.series[j];\n activeSeriesNames.push(series.name);\n this.addSeries(series, axes, chart.showLegend);\n }\n }\n\n // Remove any series that no longer exist\n const allSeriesNames = [...this.seriesDataMap.keys()];\n const inactiveSeriesNames = allSeriesNames.filter(\n seriesName => activeSeriesNames.indexOf(seriesName) < 0\n );\n for (let i = 0; i < inactiveSeriesNames.length; i += 1) {\n const seriesName = inactiveSeriesNames[i];\n this.seriesDataMap.delete(seriesName);\n }\n this.seriesToProcess = new Set([...this.seriesDataMap.keys()]);\n }\n\n /**\n * Add a series to the model\n * @param series Series object to add\n * @param axes All the axis in this figure\n * @param showLegend Whether this series should show the legend or not\n */\n addSeries(series: Series, axes: Axis[], showLegend: boolean | null): void {\n const axisTypeMap: AxisTypeMap = ChartUtils.groupArray(axes, 'type');\n\n const seriesData = ChartUtils.makeSeriesDataFromSeries(\n series,\n axisTypeMap,\n ChartUtils.getSeriesVisibility(series.name, this.settings),\n showLegend,\n this.theme\n );\n\n this.seriesDataMap.set(series.name, seriesData);\n\n this.data = [...this.seriesDataMap.values()];\n\n if (series.plotStyle === dh.plot.SeriesPlotStyle.STACKED_BAR) {\n this.layout.barmode = 'stack';\n } else if (series.plotStyle === dh.plot.SeriesPlotStyle.PIE) {\n this.layout.hiddenlabels = ChartUtils.getHiddenLabels(this.settings);\n }\n\n // We only want to force hide the legend if there is only one series that is not a PIE\n // Right now this means that if the user only has one series, they cannot explicitly show the legend until deephaven-core#3254 is implemented\n // TODO: deephaven-core#3254, once done, this can be removed.\n this.layout.showlegend =\n this.data.length > 1 || series.plotStyle === dh.plot.SeriesPlotStyle.PIE\n ? showLegend ?? undefined\n : false;\n\n if (series.oneClick != null) {\n const { oneClick } = series;\n const { columns } = oneClick;\n for (let i = 0; i < columns.length; i += 1) {\n this.filterColumnMap.set(columns[i].name, columns[i]);\n }\n\n this.oneClicks.push(oneClick);\n }\n\n this.updateLayoutFormats();\n }\n\n // We need to debounce adding series so we subscribe to them all in the same tick\n // This should no longer be necessary after IDS-5049 lands\n addPendingSeries = debounce(() => {\n const axes = ChartUtils.getAllAxes(this.figure);\n const { pendingSeries } = this;\n for (let i = 0; i < pendingSeries.length; i += 1) {\n const series = pendingSeries[i];\n const chart = this.figure.charts.find(c => c.series.includes(series));\n this.addSeries(series, axes, chart?.showLegend ?? null);\n\n series.subscribe();\n // We'll get an update with the data after subscribing\n }\n\n this.pendingSeries = [];\n }, FigureChartModel.ADD_SERIES_DEBOUNCE);\n\n subscribe(callback: (event: ChartEvent) => void): void {\n super.subscribe(callback);\n\n if (this.listeners.length === 1) {\n // Need to initialize the series here as we may have missed some series when not subscribed\n this.initAllSeries();\n this.subscribeFigure();\n }\n }\n\n unsubscribe(callback: (event: ChartEvent) => void): void {\n super.unsubscribe(callback);\n\n if (this.listeners.length === 0) {\n this.unsubscribeFigure();\n }\n }\n\n subscribeFigure(): void {\n if (!this.isConnected) {\n log.debug('Ignoring subscribe when figure in disconnected state');\n return;\n }\n\n this.figure.subscribe(\n this.isDownsamplingDisabled\n ? dh.plot.DownsampleOptions.DISABLE\n : dh.plot.DownsampleOptions.DEFAULT\n );\n }\n\n unsubscribeFigure(): void {\n this.figure.unsubscribe();\n }\n\n startListeningFigure(): void {\n this.figure.addEventListener(\n dh.plot.Figure.EVENT_UPDATED,\n this.handleFigureUpdated\n );\n this.figure.addEventListener(\n dh.plot.Figure.EVENT_SERIES_ADDED,\n this.handleFigureSeriesAdded\n );\n this.figure.addEventListener(\n dh.plot.Figure.EVENT_DISCONNECT,\n this.handleFigureDisconnected\n );\n this.figure.addEventListener(\n dh.plot.Figure.EVENT_RECONNECT,\n this.handleFigureReconnected\n );\n this.figure.addEventListener(\n dh.plot.Figure.EVENT_DOWNSAMPLESTARTED,\n this.handleDownsampleStart\n );\n this.figure.addEventListener(\n dh.plot.Figure.EVENT_DOWNSAMPLEFINISHED,\n this.handleDownsampleFinish\n );\n this.figure.addEventListener(\n dh.plot.Figure.EVENT_DOWNSAMPLEFAILED,\n this.handleDownsampleFail\n );\n this.figure.addEventListener(\n dh.plot.Figure.EVENT_DOWNSAMPLENEEDED,\n this.handleDownsampleNeeded\n );\n this.figure.addEventListener(\n dh.Client.EVENT_REQUEST_FAILED,\n this.handleRequestFailed\n );\n }\n\n stopListeningFigure(): void {\n this.figure.removeEventListener(\n dh.plot.Figure.EVENT_UPDATED,\n this.handleFigureUpdated\n );\n this.figure.removeEventListener(\n dh.plot.Figure.EVENT_SERIES_ADDED,\n this.handleFigureSeriesAdded\n );\n this.figure.removeEventListener(\n dh.plot.Figure.EVENT_DISCONNECT,\n this.handleFigureDisconnected\n );\n this.figure.removeEventListener(\n dh.plot.Figure.EVENT_RECONNECT,\n this.handleFigureReconnected\n );\n this.figure.removeEventListener(\n dh.plot.Figure.EVENT_DOWNSAMPLESTARTED,\n this.handleDownsampleStart\n );\n this.figure.removeEventListener(\n dh.plot.Figure.EVENT_DOWNSAMPLEFINISHED,\n this.handleDownsampleFinish\n );\n this.figure.removeEventListener(\n dh.plot.Figure.EVENT_DOWNSAMPLEFAILED,\n this.handleDownsampleFail\n );\n this.figure.removeEventListener(\n dh.plot.Figure.EVENT_DOWNSAMPLENEEDED,\n this.handleDownsampleNeeded\n );\n this.figure.removeEventListener(\n dh.Client.EVENT_REQUEST_FAILED,\n this.handleRequestFailed\n );\n }\n\n getTimeZone = memoize(\n (columnType: string, formatter: Formatter | undefined) => {\n if (formatter != null) {\n const dataFormatter = formatter.getColumnTypeFormatter(columnType);\n if (dataFormatter != null) {\n return (dataFormatter as DateTimeColumnFormatter).dhTimeZone;\n }\n }\n return undefined;\n }\n );\n\n getValueTranslator = memoize(\n (columnType: string, formatter: Formatter | undefined) => {\n const timeZone = this.getTimeZone(columnType, formatter);\n return (value: unknown) => ChartUtils.unwrapValue(value, timeZone);\n }\n );\n\n /** Gets the parser for a value with the provided column type */\n getValueParser = memoize(\n (columnType: string, formatter: Formatter | undefined) => {\n const timeZone = this.getTimeZone(columnType, formatter);\n return (value: unknown) =>\n ChartUtils.wrapValue(value, columnType, timeZone);\n }\n );\n\n /**\n * Gets the range parser for a particular column type\n */\n getRangeParser = memoize(\n (columnType: string, formatter?: Formatter) => (range: Range) => {\n let [rangeStart, rangeEnd]: [unknown, unknown] = range;\n const valueParser = this.getValueParser(columnType, formatter);\n rangeStart = valueParser(rangeStart);\n rangeEnd = valueParser(rangeEnd);\n return [rangeStart, rangeEnd];\n }\n );\n\n /**\n * Gets the parser for parsing the range from an axis within the given chart\n */\n getAxisRangeParser = memoize(\n (chart: Chart, formatter?: Formatter) => (axis: Axis) => {\n const source = ChartUtils.getSourceForAxis(chart, axis);\n if (source) {\n return this.getRangeParser(source.columnType, formatter);\n }\n\n return (range: [unknown, unknown]) => range;\n }\n );\n\n handleDownsampleStart(event: ChartEvent): void {\n log.debug('Downsample started', event);\n\n this.fireDownsampleStart(event.detail);\n }\n\n handleDownsampleFinish(event: ChartEvent): void {\n log.debug('Downsample finished', event);\n\n this.fireDownsampleFinish(event.detail);\n }\n\n handleDownsampleFail(event: ChartEvent): void {\n log.error('Downsample failed', event);\n\n this.fireDownsampleFail(event.detail);\n }\n\n handleDownsampleNeeded(event: ChartEvent): void {\n log.info('Downsample needed', event);\n\n this.fireDownsampleNeeded(event.detail);\n }\n\n handleFigureUpdated(event: ChartEvent): void {\n const { detail: figureUpdateEvent } = event;\n const { series: seriesArray } = figureUpdateEvent;\n\n log.debug2('handleFigureUpdated', seriesArray);\n\n for (let i = 0; i < seriesArray.length; i += 1) {\n const series = seriesArray[i];\n\n log.debug2('handleFigureUpdated updating series', series.name);\n\n const { sources } = series;\n for (let j = 0; j < sources.length; j += 1) {\n const source = sources[j];\n const { columnType, type } = source;\n const valueTranslator = this.getValueTranslator(\n columnType,\n this.formatter\n );\n const dataArray = figureUpdateEvent.getArray(\n series,\n type,\n valueTranslator\n );\n this.setDataArrayForSeries(series, type, dataArray);\n }\n\n this.seriesToProcess.delete(series.name);\n if (this.seriesToProcess.size === 0) {\n this.fireLoadFinished();\n }\n\n this.cleanSeries(series);\n }\n\n const { data } = this;\n this.fireUpdate(data);\n }\n\n handleRequestFailed(event: ChartEvent): void {\n log.error('Request failed', event);\n }\n\n /**\n * Resubscribe to the figure, should be done if settings change\n */\n resubscribe(): void {\n if (this.listeners.length > 0) {\n this.unsubscribeFigure();\n this.subscribeFigure();\n }\n }\n\n setFormatter(formatter: Formatter): void {\n super.setFormatter(formatter);\n\n this.updateLayoutFormats();\n\n // Unsubscribe and resubscribe to trigger a data update\n // Data may need to be translated again because of the new formatter\n this.resubscribe();\n }\n\n setDownsamplingDisabled(isDownsamplingDisabled: boolean): void {\n super.setDownsamplingDisabled(isDownsamplingDisabled);\n\n this.resubscribe();\n }\n\n handleFigureDisconnected(event: CustomEvent): void {\n log.debug('Figure disconnected', event);\n\n this.isConnected = false;\n\n if (this.listeners.length > 0) {\n this.unsubscribeFigure();\n }\n\n this.fireDisconnect();\n }\n\n handleFigureReconnected(event: CustomEvent): void {\n log.debug('Figure reconnected', event);\n\n this.isConnected = true;\n\n // It's possible the series have changed completely, as the query could have been changed\n this.initAllSeries();\n\n this.fireReconnect();\n\n if (this.listeners.length > 0) {\n this.subscribeFigure();\n }\n }\n\n handleFigureSeriesAdded(event: { detail: Series }): void {\n const { detail: series } = event;\n log.debug('handleFigureSeriesAdded', series);\n\n this.pendingSeries.push(series);\n this.addPendingSeries();\n }\n\n setDimensions(rect: DOMRect): void {\n super.setDimensions(rect);\n\n this.updateAxisPositions();\n }\n\n setTitle(title: string): void {\n super.setTitle(title);\n\n // Need to recalculate the padding based on how many lines of text the title is\n // Plotly doesn't handle positioning it correctly, and it's an undocumented feature\n const subtitleCount = (title ?? '').match(/<br>/g)?.length ?? 0;\n const margin =\n ChartUtils.DEFAULT_MARGIN.t +\n subtitleCount * ChartUtils.SUBTITLE_LINE_HEIGHT;\n\n if (this.layout.margin) {\n this.layout.margin.t = margin;\n } else {\n this.layout.margin = { t: margin };\n }\n\n if (typeof this.layout.title === 'string') {\n this.layout.title = title;\n } else {\n this.layout.title = { ...this.layout.title };\n this.layout.title.text = title;\n this.layout.title.pad = { ...this.layout.title.pad };\n this.layout.title.pad.t =\n ChartUtils.DEFAULT_TITLE_PADDING.t +\n subtitleCount * ChartUtils.SUBTITLE_LINE_HEIGHT * 0.5;\n }\n }\n\n getPlotWidth(): number {\n if (!this.rect || !this.rect.width) {\n return 0;\n }\n\n return Math.max(\n this.rect.width -\n (this.layout.margin?.l ?? 0) -\n (this.layout.margin?.r ?? 0),\n 0\n );\n }\n\n getPlotHeight(): number {\n if (!this.rect || !this.rect.height) {\n return 0;\n }\n\n return Math.max(\n this.rect.height -\n (this.layout.margin?.t ?? 0) -\n (this.layout.margin?.b ?? 0),\n 0\n );\n }\n\n updateAxisPositions(): void {\n const plotWidth = this.getPlotWidth();\n const plotHeight = this.getPlotHeight();\n ChartUtils.updateFigureAxes(\n this.layout,\n this.figure,\n chart => this.getAxisRangeParser(chart, this.formatter),\n plotWidth,\n plotHeight,\n this.theme\n );\n }\n\n /**\n * Updates the format patterns used\n */\n updateLayoutFormats(): void {\n if (!this.formatter) {\n return;\n }\n\n const axisFormats = ChartUtils.getAxisFormats(this.figure, this.formatter);\n axisFormats.forEach((axisFormat, axisLayoutProperty) => {\n log.debug(\n `Assigning ${axisLayoutProperty}`,\n this.layout[axisLayoutProperty],\n axisFormat\n );\n\n const props = this.layout[axisLayoutProperty];\n if (props != null) {\n Object.assign(props, axisFormat);\n } else {\n log.debug(`Ignoring null layout.${axisLayoutProperty}`);\n }\n });\n }\n\n /**\n * Set a specific array for the array of series properties specified.\n * @param series The series to set the data array for.\n * @param sourceType The source type within that series to set the data for.\n * @param dataArray The array to use for the data for this series source.\n */\n setDataArrayForSeries(\n series: Series,\n sourceType: SourceType,\n dataArray: unknown[]\n ): void {\n const { name, plotStyle } = series;\n\n const seriesData = this.seriesDataMap.get(name);\n const property = ChartUtils.getPlotlyProperty(plotStyle, sourceType);\n\n if (seriesData) {\n set(seriesData, property, dataArray);\n }\n }\n\n /**\n * After setting all the data in the series data, we may need to adjust some other properties\n * Eg. Calculating the width from the xLow/xHigh values; Plot.ly uses `width` instead of a low/high\n * value for x.\n * @param series The series to clean the data for\n */\n cleanSeries(series: Series): void {\n const { name, plotStyle } = series;\n const seriesData = this.seriesDataMap.get(name);\n if (seriesData == null) {\n return;\n }\n if (plotStyle === dh.plot.SeriesPlotStyle.HISTOGRAM) {\n const { xLow, xHigh } = seriesData;\n if (xLow && xHigh && xLow.length === xHigh.length) {\n const width = [];\n for (let i = 0; i < xLow.length; i += 1) {\n width.push(xHigh[i] - xLow[i]);\n }\n seriesData.width = width;\n }\n } else if (plotStyle === dh.plot.SeriesPlotStyle.LINE) {\n const { x, xLow, xHigh, y, yLow, yHigh } = seriesData;\n if (xLow && xHigh && xLow !== x) {\n seriesData.error_x = ChartUtils.getPlotlyErrorBars(\n x as number[],\n xLow,\n xHigh\n );\n }\n if (yLow && yHigh && yLow !== y) {\n seriesData.error_y = ChartUtils.getPlotlyErrorBars(\n y as number[],\n yLow,\n yHigh\n );\n }\n } else if (plotStyle === dh.plot.SeriesPlotStyle.TREEMAP) {\n const { ids, labels } = seriesData;\n if (ids !== undefined && labels === undefined) {\n // If the user only provided IDs, we assign the IDs to the labels property as well automatically\n // Plotly uses the labels primarily, which from our API perspective seems kind of backwards\n seriesData.labels = ids;\n }\n }\n }\n\n getData(): Partial<PlotData>[] {\n return this.data;\n }\n\n getLayout(): Partial<Layout> {\n return this.layout;\n }\n\n getFilterColumnMap(): FilterColumnMap {\n return new Map(this.filterColumnMap);\n }\n\n isFilterRequired(): boolean {\n return (\n this.oneClicks.find(oneClick => oneClick.requireAllFiltersToDisplay) !=\n null\n );\n }\n\n /**\n * Sets the filter on the model. Will only set the values that have changed.\n * @param filterMap Map of filter column names to values\n */\n setFilter(filterMap: Map<string, string>): void {\n if (this.oneClicks.length === 0) {\n log.warn('Trying to set a filter, but no one click!');\n return;\n }\n\n log.debug('setFilter', filterMap);\n\n for (let i = 0; i < this.oneClicks.length; i += 1) {\n const oneClick = this.oneClicks[i];\n const { columns } = oneClick;\n // Need to get all the keys in case a filter was removed\n const keys = new Set([...filterMap.keys(), ...this.lastFilter.keys()]);\n keys.forEach(key => {\n const value = filterMap.get(key);\n if (\n this.lastFilter.get(key) !== value &&\n columns.find(column => column.name === key) != null\n ) {\n oneClick.setValueForColumn(key, value);\n }\n });\n }\n\n this.lastFilter = new Map(filterMap);\n }\n\n setFigure(figure: Figure): void {\n this.close();\n\n this.figure = figure;\n\n this.setTitle(this.getDefaultTitle());\n this.initAllSeries();\n this.updateAxisPositions();\n this.startListeningFigure();\n if (this.listeners.length > 0) {\n this.subscribeFigure();\n }\n }\n\n updateSettings(settings: Partial<ChartModelSettings>): void {\n this.settings = settings;\n }\n}\n\nexport default FigureChartModel;\n","import dh, { Figure, Table } from '@deephaven/jsapi-shim';\nimport ChartUtils, { ChartModelSettings } from './ChartUtils';\nimport FigureChartModel from './FigureChartModel';\nimport ChartTheme from './ChartTheme';\nimport ChartModel from './ChartModel';\n\nclass ChartModelFactory {\n /**\n * Creates a model from the settings provided.\n * Tries to create a Figure in the API with it.\n * @param settings The chart builder settings\n * @param settings.isLinked Whether the newly created chart should stay linked with the original table, update when filters are updated\n * @param settings.series The column names to use for creating the series of this chart\n * @param settings.type Chart builder type, from ChartBuilder.types\n * @param settings.xAxis The column name to use for the x-axis\n * @param [settings.hiddenSeries] Array of hidden series names\n * @param table The table to build the model for\n * @param theme The theme for the figure. Defaults to ChartTheme\n * @returns The ChartModel Promise representing the figure\n * CRA sets tsconfig to type check JS based on jsdoc comments. It isn't able to figure out FigureChartModel extends ChartModel\n * This causes TS issues in 1 or 2 spots. Once this is TS it can be returned to just FigureChartModel\n */\n static async makeModelFromSettings(\n settings: ChartModelSettings,\n table: Table,\n theme = ChartTheme\n ): Promise<ChartModel> {\n const figure = await ChartModelFactory.makeFigureFromSettings(\n settings,\n table\n );\n return new FigureChartModel(figure, settings, theme);\n }\n\n /**\n * Creates a model from the settings provided.\n * Tries to create a Figure in the API with it.\n * @param settings The chart builder settings\n * @param settings.isLinked Whether the newly created chart should stay linked with the original table, update when filters are updated\n * @param settings.series The column names to use for creating the series of this chart\n * @param settings.type Chart builder type, from ChartBuilder.types\n * @param settings.xAxis The column name to use for the x-axis\n * @param [settings.hiddenSeries] Array of hidden series names\n * @param table The table to build the model for\n * @returns The Figure created with the settings provided\n */\n static async makeFigureFromSettings(\n settings: ChartModelSettings,\n table: Table\n ): Promise<Figure> {\n // Copy the table first and then re-apply the filters from the original table\n // When we add toable linking we'll want to listen to the original table and update\n // the copied table with any changes that occur.\n // The table gets owned by the Figure that gets created, which closes the table\n const tableCopy = await table.copy();\n tableCopy.applyCustomColumns(table.customColumns);\n tableCopy.applyFilter(table.filter);\n tableCopy.applySort(table.sort);\n\n return dh.plot.Figure.create(\n ChartUtils.makeFigureSettings(settings, tableCopy)\n );\n }\n\n /**\n * Creates a model from the settings provided.\n * Tries to create a Figure in the API with it.\n * @param settings The chart builder settings\n * @param settings.isLinked Whether the newly created chart should stay linked with the original table, update when filters are updated\n * @param settings.series The column names to use for creating the series of this chart\n * @param settings.type Chart builder type, from ChartBuilder.types\n * @param settings.xAxis The column name to use for the x-axis\n * @param [settings.hiddenSeries] Array of hidden series names\n * @param figure The figure to build the model for\n * @param theme The theme for the figure. Defaults to ChartTheme\n * @returns The FigureChartModel representing the figure\n * CRA sets tsconfig to type check JS based on jsdoc comments. It isn't able to figure out FigureChartModel extends ChartModel\n * This causes TS issues in 1 or 2 spots. Once this is TS it can be returned to just FigureChartModel\n */\n static async makeModel(\n settings: Record<string, unknown> | undefined,\n figure: Figure,\n theme = ChartTheme\n ): Promise<ChartModel> {\n return new FigureChartModel(figure, settings, theme);\n }\n}\n\nexport default ChartModelFactory;\n","import React, { useEffect, useMemo, useState } from 'react';\nimport { Chart, ChartModel, ChartModelFactory } from '@deephaven/chart'; // chart is used to display Deephaven charts\nimport { ContextMenuRoot, LoadingOverlay } from '@deephaven/components'; // Use the loading spinner from the Deephaven components package\nimport dh, { IdeConnection } from '@deephaven/jsapi-shim'; // Import the shim to use the JS API\nimport Log from '@deephaven/log';\nimport './App.scss'; // Styles for in this app\n\nconst log = Log.module('EmbedChart.App');\n\n/**\n * Load an existing Deephaven figure with the connection provided\n * @param connection The Deephaven session object\n * @param name Name of the figure to load\n * @returns Deephaven figure\n */\nasync function loadFigure(connection: IdeConnection, name: string) {\n log.info(`Fetching figure ${name}...`);\n\n const definition = { name, type: dh.VariableType.FIGURE };\n return connection.getObject(definition);\n}\n\n/**\n * A functional React component that displays a Deephaven figure using the @deephaven/chart package.\n * It will attempt to open and display the figure specified with the `name` parameter, expecting it to be present on the server.\n * E.g. http://localhost:3000/?name=myFigure will attempt to open a figure `myFigure`\n * If no query param is provided, it will display an error.\n * By default, tries to connect to the server defined in the VITE_CORE_API_URL variable, which is set to http://localhost:10000/jsapi\n * See create-react-app docs for how to update these env vars: https://create-react-app.dev/docs/adding-custom-environment-variables/\n */\nfunction App(): JSX.Element {\n const [model, setModel] = useState<ChartModel>();\n const [error, setError] = useState<string>();\n const [isLoading, setIsLoading] = useState(true);\n const searchParams = useMemo(\n () => new URLSearchParams(window.location.search),\n []\n );\n\n useEffect(\n function initializeApp() {\n async function initApp() {\n try {\n // Get the table name from the query param `name`.\n const name = searchParams.get('name');\n\n if (name == null) {\n throw new Error('No name param provided');\n }\n\n // Connect to the Web API server\n const baseUrl = new URL(\n import.meta.env.VITE_CORE_API_URL ?? '',\n `${window.location}`\n );\n\n const websocketUrl = `${baseUrl.protocol}//${baseUrl.host}`;\n\n log.debug(`Starting connection...`);\n const connection = new dh.IdeConnection(websocketUrl);\n\n log.debug('Loading figure', name, '...');\n\n // Load the figure up.\n const figure = await loadFigure(connection, name);\n\n // Create the `ChartModel` for use with the `Chart` component\n log.debug(`Creating model...`);\n\n const newModel = await ChartModelFactory.makeModel(undefined, figure);\n\n setModel(newModel);\n\n log.debug('Figure successfully loaded!');\n } catch (e: unknown) {\n log.error('Unable to load figure', e);\n setError(`${e}`);\n }\n setIsLoading(false);\n }\n initApp();\n },\n [searchParams]\n );\n\n const isLoaded = model != null;\n\n return (\n <div className=\"App\">\n {isLoaded && <Chart model={model} />}\n {!isLoaded && (\n <LoadingOverlay\n isLoaded={isLoaded}\n isLoading={isLoading}\n errorMessage={error ?? null}\n />\n )}\n <ContextMenuRoot />\n </div>\n );\n}\n\nexport default App;\n"],"names":["assertNotNull","value","TextUtils","items","conjunction","itemText","lastItem","text","isNullAllowed","a","b","isAscending","ContextMenuRoot","Component","constructor","props","handleMenuClose","bind","handleContextMenu","container","React","createRef","openMenu","state","actions","left","top","componentDidMount","_a","current","parentElement","addEventListener","componentWillUnmount","removeEventListener","e","ContextActionUtils","isContextActionEvent","metaKey","ctrlKey","contextActions","getMenuItems","parentRect","getBoundingClientRect","clientY","clientX","length","target","preventDefault","setState","element","document","elementFromPoint","mouseEvent","MouseEvent","bubbles","cancelable","dispatchEvent","menu","render","dataTestId","ContextMenu","verifiedTop","verifiedLeft","classNames","active","TableColumnFormatter","format","formatA","formatB","label","formatString","type","BooleanColumnFormatter","CharColumnFormatter","dh","Column","PropTypes","FilterCondition","Sort","Table","TreeTable","VariableDefinition","VariableChanges","RollupConfig","IdeSession","log","Log","_DateTimeColumnFormatter","timeZoneParam","showTimeZone","showTSeparator","defaultDateTimeFormatString","timeZone","separator","tz","baseFormatString","DateTimeColumnFormatter","_DecimalColumnFormatter","defaultFormatString","multiplier","valueParam","DecimalColumnFormatter","DefaultColumnFormatter","_IntegerColumnFormatter","IntegerColumnFormatter","StringColumnFormatter","_DateUtils","year","month","day","hour","minute","second","ns","yearString","monthString","dayString","hourString","minuteString","secondString","nanoString","dateString","sigNanos","zeros","nextNanoString","components","values","date","hours","minutes","seconds","nanos","jsDate","cleanMonthString","i","dateTimeString","result","overflow","cleanText","now","startDate","endDate","dateWrapper","DateUtils","Operator","Type","_TableUtils","sort","columnIndex","tableSort","sortIndex","filter","columnType","FilterType","columns","sorts","direction","isAbs","addToExisting","newSort","modelColumn","type1","type2","column","orComponents","orFilter","andComponents","andFilter","j","andComponent","columnFilter","operation","negativeSign","abnormalValue","error","prefix","suffix","notEqual","cleanValue","boolValue","dateText","filterOperation","startValue","endValue","startFilter","endFilter","filterValue","table","PromiseUtils","resolved","eventName","timeout","matcher","eventCleanup","timeoutId","isPending","wrappedPromise","resolve","reject","TimeoutError","event","options","filterItems","filterOperators","invertSelection","selectedValues","filterItem","selectedType","newFilter","filterOperator","FilterOperator","err","selectValueFilter","rawValue","allowEmpty","numberText","eqFilter","notEqFilter","isNullSelected","aName","bName","TableUtils","Formatter","columnFormattingRules","map","next","dataType","formatMap","columnName","dateTimeOptions","decimalFormatOptions","integerFormatOptions","truncateNumbersWithPound","createIfNecessary","columnFormatMap","columnTypeFormatter","formatOverride","formatter","getColumnFormats","settings","getDateTimeFormatterOptions","isCustomColumnFormatDefined","columnFormat","FormatterUtils","Plotly","bar","histogram","pie","ohlc","scattergl","treemap","Plot","createPlotlyComponent","_ChartModel","isDownsamplingDisabled","rect","title","callback","listener","data","detail","ChartModel","ChartTheme","DAYS","BUSINESS_COLUMN_TYPE","MILLIS_PER_HOUR","NANOS_PER_MILLI","isDateWrapper","isLongWrapper","isDateTimeColumnFormatter","isRangedPlotlyAxis","_ChartUtils","plotStyle","isBusinessTime","areLinesVisible","areShapesVisible","modes","sourceType","series","sources","_b","x","xLow","xHigh","array","arrayminus","formatPattern","tickformat","ticksuffix","dataFormatter","matchArray","placeholderDigits","zeroDigits","decimalDigits","optionalDecimalDigits","numberType","percentSign","paddingLength","comma","plotlyNumberType","decimalLength","tickprefix","source","axis","axisFormat","isDateType","gapBetweenMajorTicks","updatedFormat","tickSpacing","chart","name","mode","showLegend","orientation","axisTypeMap","seriesVisibility","theme","isLinesVisible","isShapesVisible","lineColor","shapeColor","shape","shapeSize","seriesData","seriesDataParam","k","dataAttributeName","set","axisProperty","axes","axisIndex","axisIndexString","deephavenShape","figure","axisFormats","nullFormat","allAxes","charts","axisSources","axisType","typeAxes","axisLayoutProperty","businessCalendar","rangebreaks","businessPeriods","businessDays","holidays","calendarTimeZone","typeFormatter","formatterTimeZone","timeZoneDiff","period","weekendBounds","axisPosition","layout","ranges","keys","key","layoutParam","chartAxisRangeParser","plotWidth","plotHeight","figureAxes","axisRangeParser","bounds","cols","rows","colspan","row","rowspan","endColumn","endRow","columnSize","rowSize","xMarginSize","yMarginSize","chartAxes","xAxisSize","yAxisSize","axisPositionMap","axisTypes","figureAxisTypeMap","figureTypeAxes","plotSize","chartAxisIndex","figureAxisIndex","layoutAxis","range","autorange","rangeParser","rangeStart","rangeEnd","figureAxisTypes","layoutAxisParam","axisSize","positionAxes","_c","sideIndex","leftAxes","rightAxes","right","bottomAxes","topAxes","bottom","businessDaysInt","nonBusinessDaysInt","reopenDays","closed","adjustedDay","boundsArray","open","closedDay","fullHolidays","partialHolidays","holiday","closedPeriods","rangeBreaks","startClose","endClose","dvalue","property","item","group","tzFormat","estimatedOffset","estimatedDate","offset","colorway","xAxis","settingsAxis","yAxis","ChartUtils","module","Chart","getCachedConfig","memoize","downsamplingError","isDownsampleFinished","isDownsampleInProgress","customButtons","hasDownsampleError","Boolean","push","click","undefined","icon","convertIcon","dhWarningFilled","attr","downsampleButtonTitle","downsampleButtonAttr","vsLoading","dhGraphLineDown","handleDownsampleClick","displaylogo","displayModeBar","modeBarButtons","handleAfterPlot","handleModelEvent","handlePlotUpdate","handleRelayout","handleRestyle","plot","plotWrapper","columnFormats","dateTimeFormatterOptions","isSubscribed","isLoadedFired","currentSeries","datarevision","revision","faIcon","width","path","stringPath","ascent","descent","transform","updateDimensions","updateModelDimensions","initData","initFormatter","isActive","subscribe","componentDidUpdate","prevProps","updateFormatterSettings","unsubscribe","getPlotRect","model","getData","getLayout","height","debug2","setDownsamplingDisabled","EVENT_UPDATED","onUpdate","isLoading","EVENT_LOADFINISHED","EVENT_DISCONNECT","onDisconnect","EVENT_RECONNECT","onReconnect","EVENT_DOWNSAMPLESTARTED","EVENT_DOWNSAMPLEFINISHED","EVENT_DOWNSAMPLENEEDED","EVENT_DOWNSAMPLEFAILED","message","onError","Error","debug","getLayoutRanges","deepEqual","changes","hiddenlabels","onSettingsChanged","hiddenSeries","seriesIndexes","Object","includes","reduce","acc","visible","force","warn","setDimensions","updateFormatter","setFormatter","relayout","el","autosize","catch","config","isPlotShown","_jsx","_Chart","defaultProps","defaultDateTimeFormat","FULL_DATE_FORMAT","_FigureChartModel","debounce","pendingSeries","c","valueParser","template","activeSeriesNames","inactiveSeriesNames","seriesName","oneClick","figureUpdateEvent","seriesArray","valueTranslator","dataArray","subtitleCount","margin","_d","y","yLow","yHigh","ids","labels","filterMap","FigureChartModel","ChartModelFactory","tableCopy","loadFigure","connection","info","definition","VariableType","FIGURE","getObject","App","setModel","useState","setError","setIsLoading","searchParams","useMemo","URLSearchParams","window","location","search","useEffect","initApp","get","baseUrl","URL","import","websocketUrl","protocol","host","IdeConnection","newModel","makeModel","isLoaded","LoadingOverlay"],"mappings":"+VACO,SAASA,GACdC,EACoB,CACpB,GAAIA,GAAS,KAAY,MAAA,IAAI,MAAM,4BAA4B,CACjE,CCLA,MAAMC,EAAU,CAUd,OAAO,KAAKC,EAAwBC,EAAc,MAAe,CAC/D,GAAID,GAAS,MAAQA,EAAM,SAAW,EAC7B,MAAA,GAGL,GAAAA,EAAM,SAAW,EACnB,OAAOA,EAAM,GAGX,GAAAA,EAAM,SAAW,EACnB,MAAO,GAAGA,EAAM,MAAMC,KAAeD,EAAM,KAGvC,MAAAE,EAAWF,EAAM,MAAM,EAAGA,EAAM,OAAS,CAAC,EAAE,KAAK,IAAI,EACrDG,EAAWH,EAAMA,EAAM,OAAS,GAC/B,MAAA,GAAGE,MAAaD,KAAeE,GACxC,CAOA,OAAO,QAAQC,EAAqBC,EAAgB,GAAc,CAChE,GAAID,GAAQ,KAAM,CAChB,GAAIC,EACK,MAAA,GAGH,MAAA,IAAI,MAAM,4CAA4C,CAC9D,CAEA,OAAOD,EAAK,aACd,CAQA,OAAO,KAAKE,EAAWC,EAAWC,EAAc,GAAc,CAC5D,OAAIF,EAAIC,EACCC,EAAc,GAAK,EAExBF,EAAIC,EACCC,EAAc,EAAI,GAEpB,CACT,CACF,CC1CA,MAAMC,WAAwBC,EAAAA,QAAAA,SAG5B,CACAC,YAAYC,EAA6B,CACvC,MAAMA,CAAK,EAEX,KAAKC,gBAAkB,KAAKA,gBAAgBC,KAAK,IAAI,EACrD,KAAKC,kBAAoB,KAAKA,kBAAkBD,KAAK,IAAI,EACpDE,KAAAA,UAAYC,GAAMC,YAClBC,KAAAA,SAAWF,GAAMC,YAEtB,KAAKE,MAAQ,CACXC,QAAS,KACTC,KAAM,EACNC,IAAK,CAAA,CAET,CAEAC,mBAA0B,QACpBC,EAAA,KAAKT,UAAUU,UAAf,MAAAD,E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