### JavaScript: Get Widget Data as String Source: https://docs.deephaven.io/core/client-api/javascript/classes/dh Retrieves the data associated with a widget as a UTF-8 encoded string. This is suitable for text-based data or when the data needs to be displayed or processed as a string. ```javascript const stringData = myWidget.getDataAsString(); ``` -------------------------------- ### JavaScript: Get Widget Data as Base64 Source: https://docs.deephaven.io/core/client-api/javascript/classes/dh Retrieves the data associated with a widget as a Base64 encoded string. This is useful for transferring data efficiently or when binary data needs to be represented as text. ```javascript const base64Data = myWidget.getDataAsBase64(); ``` -------------------------------- ### JavaScript: Get Widget Data as Uint8Array Source: https://docs.deephaven.io/core/client-api/javascript/classes/dh Retrieves the data associated with a widget as a Uint8Array. This is ideal for working with raw binary data directly in JavaScript. ```javascript const u8ArrayData = myWidget.getDataAsU8(); ``` -------------------------------- ### Instantiate SignatureInformation (JavaScript) Source: https://docs.deephaven.io/core/client-api/javascript/classes/dh.lsp Demonstrates how to create a new instance of the SignatureInformation class. This is a basic constructor call. ```javascript new SignatureInformation() ``` -------------------------------- ### Create Directory with StorageService Source: https://docs.deephaven.io/core/client-api/javascript/classes/dh.storage Creates a new directory at the specified path using the StorageService. This method returns a Promise that resolves with no value on success or rejects with an error. ```javascript import { StorageService } from "@deephaven/jsapi-types"; // Assuming 'storageService' is an instance of StorageService const storageService: StorageService = ...; const directoryPath = "my/new/directory"; storageService.createDirectory(directoryPath) .then(() => { console.log(`Directory created successfully at: ${directoryPath}`); }) .catch((error) => { console.error(`Error creating directory: ${error}`); }); ``` -------------------------------- ### Widget Constructors Source: https://docs.deephaven.io/core/client-api/javascript/classes/dh Details on how to construct a Widget instance. ```APIDOC ## Constructors ### `Protected` constructor * `new Widget()`: Widget * #### Returns Widget ``` -------------------------------- ### StorageService API Source: https://docs.deephaven.io/core/client-api/javascript/classes/dh.storage The StorageService provides methods for managing files and directories on the Deephaven server. ```APIDOC ## StorageService Remote service to read and write files on the server. Paths use "/" as a separator, and should not start with "/". ### Methods #### `createDirectory(path: string): Promise` Creates a new directory at the specified path. * **path** (string) - Required - The path of the directory to create. #### `deleteItem(path: string): Promise` Deletes the item at the given path. Directories must be empty to be deleted. * **path** (string) - Required - The path of the item to delete. #### `listItems(path: string, glob?: string): Promise` Lists items in a given directory, with an optional filter glob to only list files that match. The empty or "root" path should be specified as the empty string. * **path** (string) - Required - The path of the directory to list. * **glob** (string) - Optional - An optional glob to filter the contents of the directory. #### `loadFile(path: string, etag?: string): Promise` Downloads a file at the given path, unless an etag is provided that matches the file's current contents. * **path** (string) - Required - The path of the file to fetch. * **etag** (string) - Optional - An optional etag from the last time the client saw this file. #### `moveItem(oldPath: string, newPath: string, allowOverwrite?: boolean): Promise` Moves (and/or renames) an item from its old path to its new path. The optional `allowOverwrite` parameter can be set to `true` to allow an existing item to be overwritten. Directories must be empty to be overwritten. * **oldPath** (string) - Required - The path of the existing item. * **newPath** (string) - Required - The new path to move the item to. * **allowOverwrite** (boolean) - Optional - `true` to allow an existing file to be overwritten, `false` or omit to require a new file. #### `saveFile(path: string, contents: FileContents, allowOverwrite?: boolean): Promise` Saves the provided contents to the given path, creating a file or replacing an existing one. The optional `allowOverwrite` parameter can be set to `true` to allow an existing file to be overwritten, only creating a new file if it does not exist. Directories must be empty to be overwritten. * **path** (string) - Required - The path of the file to write. * **contents** (FileContents) - Required - The contents to write to that path. * **allowOverwrite** (boolean) - Optional - `true` to allow an existing file to be overwritten, `false` or omit to require a new file. ``` -------------------------------- ### GrpcTransportOptions Interface Source: https://docs.deephaven.io/core/client-api/javascript/interfaces/dh.grpc Options for creating a gRPC stream transport instance. ```APIDOC ## Interface GrpcTransportOptions Options for creating a gRPC stream transport instance. ### Properties #### `debug` - **Type**: `boolean` - **Description**: True to enable debug logging for this stream. #### `onChunk` - **Type**: `(chunk: Uint8Array) => void` - **Description**: Callback for when a chunk of data is received. #### `onEnd` - **Type**: `(error?: Error) => void` - **Description**: Callback for when the stream ends, with an error instance if it can be provided. Note that the present implementation does not consume errors, even if provided. #### `onHeaders` - **Type**: `(headers: { [key: string]: string | string[] }, status: number) => void` - **Description**: Callback for when headers and status are received. The headers are a map of header names to values, and the status is the HTTP status code. If the connection could not be made, the status should be 0. #### `url` - **Type**: `URL` - **Description**: The gRPC method URL. ``` -------------------------------- ### Widget Class Overview Source: https://docs.deephaven.io/core/client-api/javascript/classes/dh Provides a general overview of the Widget class, its purpose, and how it handles communication with the Deephaven server. ```APIDOC ## Class Widget A Widget represents a server side object that sends one or more responses to the client. The client can then interpret these responses to see what to render, or how to respond. Most custom object types result in a single response being sent to the client, often with other exported objects, but some will have streamed responses, and allow the client to send follow-up requests of its own. This class's API is backwards compatible, but as such does not offer a way to tell the difference between a streaming or non-streaming object type, the client code that handles the payloads is expected to know what to expect. See WidgetMessageDetails for more information. When the promise that returns this object resolves, it will have the first response assigned to its fields. Later responses from the server will be emitted as "message" events. When the connection with the server ends, the "close" event will be emitted. In this way, the connection will behave roughly in the same way as a WebSocket - either side can close, and after close no more messages will be processed. There can be some latency in closing locally while remote messages are still pending - it is up to implementations of plugins to handle this case. Also like WebSockets, the plugin API doesn't define how to serialize messages, and just handles any binary payloads. What it does handle however, is allowing those messages to include references to server-side objects with those payloads. Those server side objects might be tables or other built-in types in the Deephaven JS API, or could be objects usable through their own plugins. They also might have no plugin at all, allowing the client to hold a reference to them and pass them back to the server, either to the current plugin instance, or through another API. The `Widget` type does not specify how those objects should be used or their lifecycle, but leaves that entirely to the plugin. Messages will arrive in the order they were sent. This can suggest several patterns for how plugins operate: * The plugin merely exists to transport some other object to the client. This can be useful for objects which can easily be translated to some other type (like a Table) when the user clicks on it. An example of this is `pandas.DataFrame` will result in a widget that only contains a static Table. Presently, the widget is immediately closed, and only the Table is provided to the JS API consumer. * The plugin provides references to Tables and other objects, and those objects can live longer than the object which provided them. One concrete example of this could have been PartitionedTable when fetching constituent tables, but it was implemented before bidirectional plugins were implemented. Another example of this is plugins that serve as a "factory", giving the user access to table manipulation/creation methods not supported by gRPC or the JS API. * The plugin provides reference to Tables and other objects that only make sense within the context of the widget instance, so when the widget goes away, those objects should be released as well. This is also an example of PartitionedTable, as the partitioned table tracks creation of new keys through an internal table instance. Handling server objects in messages also has more than one potential pattern that can be used: * One object per message - the message clearly is about that object, no other details required. * Objects indexed within their message - as each message comes with a list of objects, those objects can be referenced within the payload by index. This is roughly how Figure behaves, where the figure descriptor schema includes an index for each created series, describing which table should be used, which columns should be mapped to each axis. * Objects indexed since widget creation - each message would append its objects to a list created when the widget was first made, and any new exports that arrive in a new message would be appended to that list. Then, subsequent messages can reference objects already sent. This imposes a limitation where the client cannot release any exports without the server somehow signaling that it will never reference that export again. #### Hierarchy * Widget #### Implements * WidgetMessageDetails * HasEventHandling ``` -------------------------------- ### Load File with StorageService Source: https://docs.deephaven.io/core/client-api/javascript/classes/dh.storage Downloads a file from the specified path. An optional etag can be provided to avoid re-downloading if the file hasn't changed. This method returns a Promise resolving to FileContents or rejecting with an error. ```javascript import { StorageService, FileContents } from "@deephaven/jsapi-types"; // Assuming 'storageService' is an instance of StorageService const storageService: StorageService = ...; const filePath = "path/to/your/file.txt"; const lastKnownEtag = "some-etag-value"; // Optional storageService.loadFile(filePath, lastKnownEtag) .then((fileContent: FileContents) => { console.log("File loaded:", fileContent); }) .catch((error) => { console.error(`Error loading file: ${error}`); }); ``` -------------------------------- ### List Items with StorageService Source: https://docs.deephaven.io/core/client-api/javascript/classes/dh.storage Lists items within a directory, optionally filtering by a glob pattern. The root path is represented by an empty string. This method returns a Promise that resolves with an array of ItemDetails or rejects with an error. ```javascript import { StorageService, ItemDetails } from "@deephaven/jsapi-types"; // Assuming 'storageService' is an instance of StorageService const storageService: StorageService = ...; const directoryPath = ""; // Root directory const fileGlob = "*.csv"; storageService.listItems(directoryPath, fileGlob) .then((items: ItemDetails[]) => { console.log("Files matching glob:", items); }) .catch((error) => { console.error(`Error listing items: ${error}`); }); ``` -------------------------------- ### Widget Methods Source: https://docs.deephaven.io/core/client-api/javascript/classes/dh Methods available on Widget instances for interaction. ```APIDOC ## Methods ### `addEventListener` * `addEventListener(type: string, listener: () => void)`: void * Adds an event listener to the widget. ### `close` * `close()`: void * Closes the connection with the server. ### `getDataAsBase64` * `getDataAsBase64()`: string * Retrieves widget data as a Base64 encoded string. ### `getDataAsString` * `getDataAsString()`: string * Retrieves widget data as a string. ### `getDataAsU8` * `getDataAsU8()`: Uint8Array * Retrieves widget data as a Uint8Array. ### `hasListeners` * `hasListeners(type: string)`: boolean * Checks if the widget has listeners for a given event type. ### `nextEvent` * `nextEvent()`: Promise * Returns a promise that resolves with the next event from the widget. ### `removeEventListener` * `removeEventListener(type: string, listener: () => void)`: void * Removes an event listener from the widget. ### `sendMessage` * `sendMessage(message: any)`: void * Sends a message to the server associated with the widget. ``` -------------------------------- ### SourceType Constructor and Properties (JavaScript) Source: https://docs.deephaven.io/core/client-api/javascript/classes/dh.plot Demonstrates the constructor for the SourceType class and lists its static readonly properties. These properties are numerical constants representing various data types or visual elements used within the Deephaven charting API. ```javascript class SourceType { constructor(); static readonly CLOSE: number; static readonly COLOR: number; static readonly HIGH: number; static readonly HOVER_TEXT: number; static readonly LABEL: number; static readonly LOW: number; static readonly OPEN: number; static readonly PARENT: number; static readonly SHAPE: number; static readonly SIZE: number; static readonly TEXT: number; static readonly TIME: number; static readonly X: number; static readonly X_HIGH: number; static readonly X_LOW: number; static readonly Y: number; static readonly Y_HIGH: number; static readonly Y_LOW: number; static readonly Z: number; } // Example instantiation (though typically used via imported constants) // const sourceTypeInstance = new SourceType(); // Accessing properties // console.log(SourceType.CLOSE); ``` -------------------------------- ### Data and Connection Management Source: https://docs.deephaven.io/core/client-api/javascript/classes/dh Methods for managing the client connection and retrieving data in various formats. ```APIDOC ## Data and Connection Management ### close - **Description**: Ends the client connection to the server. - **Method**: DELETE (or similar, depending on underlying implementation) - **Endpoint**: N/A (Method call) - **Returns**: void ``` ```APIDOC ### getDataAsBase64 - **Description**: Returns the data from this message as a base64-encoded string. - **Method**: GET - **Endpoint**: N/A (Method call) - **Returns**: string ``` ```APIDOC ### getDataAsString - **Description**: Returns the data from this message as a utf-8 string. - **Method**: GET - **Endpoint**: N/A (Method call) - **Returns**: string ``` ```APIDOC ### getDataAsU8 - **Description**: Returns the data from this message as a Uint8Array. - **Method**: GET - **Endpoint**: N/A (Method call) - **Returns**: Uint8Array ``` ```APIDOC ### sendMessage - **Description**: Sends a string/bytes payload to the server, along with references to objects that exist on the server. - **Method**: POST - **Endpoint**: N/A (Method call) - **Parameters**: - **msg** (string | ArrayBuffer | ArrayBufferView) - Required - The message payload. - **references** ((TotalsTable | Table | WidgetExportedObject | Widget | PartitionedTable | TreeTable)[]) - Optional - An array of objects that can be safely sent to the server. - **Returns**: void ``` -------------------------------- ### Save File with StorageService Source: https://docs.deephaven.io/core/client-api/javascript/classes/dh.storage Saves content to a file at the specified path, creating or overwriting it. The allowOverwrite flag controls behavior for existing files. Returns a Promise resolving to FileContents with the new etag, or rejecting with an error. ```javascript import { StorageService, FileContents } from "@deephaven/jsapi-types"; // Assuming 'storageService' is an instance of StorageService const storageService: StorageService = ...; const filePath = "path/to/save/file.txt"; const fileContent = { data: "This is the file content." }; // Example FileContents const overwriteExisting = true; storageService.saveFile(filePath, fileContent, overwriteExisting) .then((result: FileContents) => { console.log("File saved successfully:", result); }) .catch((error) => { console.error(`Error saving file: ${error}`); }); ``` -------------------------------- ### Move Item with StorageService Source: https://docs.deephaven.io/core/client-api/javascript/classes/dh.storage Moves or renames an item from an old path to a new path. Overwriting can be controlled with the allowOverwrite flag. Directories must be empty to be overwritten. Returns a Promise that resolves with no value on success or rejects with an error. ```javascript import { StorageService } from "@deephaven/jsapi-types"; // Assuming 'storageService' is an instance of StorageService const storageService: StorageService = ...; const oldPath = "source/item"; const newPath = "destination/renamed-item"; const overwriteExisting = false; storageService.moveItem(oldPath, newPath, overwriteExisting) .then(() => { console.log(`Item moved successfully from ${oldPath} to ${newPath}`); }) .catch((error) => { console.error(`Error moving item: ${error}`); }); ``` -------------------------------- ### Delete Item with StorageService Source: https://docs.deephaven.io/core/client-api/javascript/classes/dh.storage Deletes an item (file or empty directory) at the specified path using the StorageService. Directories must be empty to be deleted. This method returns a Promise that resolves with no value on success or rejects with an error. ```javascript import { StorageService } from "@deephaven/jsapi-types"; // Assuming 'storageService' is an instance of StorageService const storageService: StorageService = ...; const itemPathToDelete = "path/to/item"; storageService.deleteItem(itemPathToDelete) .then(() => { console.log(`Item deleted successfully at: ${itemPathToDelete}`); }) .catch((error) => { console.error(`Error deleting item: ${error}`); }); ``` -------------------------------- ### Widget Constructor Source: https://docs.deephaven.io/core/client-api/javascript/classes/dh This snippet shows the protected constructor for the Widget class. It is used internally to create new Widget instances. ```javascript new Widget(): Widget ``` -------------------------------- ### Widget Properties Source: https://docs.deephaven.io/core/client-api/javascript/classes/dh Static properties available on the Widget class. ```APIDOC ## Properties ### `Static` `Readonly` EVENT_CLOSE * `EVENT_CLOSE`: string ### `Static` `Readonly` EVENT_MESSAGE * `EVENT_MESSAGE`: string ``` -------------------------------- ### TimeZone Class Documentation Source: https://docs.deephaven.io/core/client-api/javascript/classes/dh.i18n Provides details on the TimeZone class, including its constructor, accessors (id, standardOffset), and static methods like getTimeZone. ```APIDOC ## Class TimeZone Represents the timezones supported by Deephaven. Can be used to format dates, taking into account the offset changing throughout the year (potentially changing each year). These instances mostly are useful at this time to pass to the **DateTimeFormat.format()** methods, though also support a few properties at this time to see details about each instance. The following timezone codes are supported when getting a timezone object - instances appearing in the same line will return the same details: * GMT/UTC * Asia/Tokyo * Asia/Seoul * Asia/Hong_Kong * Asia/Singapore * Asia/Calcutta/Asia/Kolkata * Europe/Berlin * Europe/London * America/Sao_Paulo * America/St_Johns * America/Halifax * America/New_York * America/Chicago * America/Denver * America/Los_Angeles * America/Anchorage * Pacific/Honolulu A Timezone object can also be created from an abbreviation. The following abbreviations are supported: * UTC * GMT * Z * NY * ET * EST * EDT * MN * CT * CST * CDT * MT * MST * MDT * PT * PST * PDT * HI * HST * HDT * BT * BRST * BRT * KR * KST * HK * HKT * JP * JST * AT * AST * ADT * NF * NST * NDT * AL * AKST * AKDT * IN * IST * CE * CET * CEST * SG * SGT * LON * BST * MOS * SHG * CH * NL * TW * SYD * AEST * AEDT ### Hierarchy * TimeZone ##### Index ### Constructors constructor ### Accessors id standardOffset ### Methods getTimeZone ## Constructors ### `Protected` constructor * new TimeZone(): TimeZone * #### Returns TimeZone ## Accessors ### id * get id(): string * the timezone code that represents this `TimeZone`, usually the same key as was use to create this instance #### Returns string String ### standardOffset * get standardOffset(): number * the standard offset of this timezone, in minutes #### Returns number int ## Methods ### `Static` getTimeZone * getTimeZone(tzCode): TimeZone * Factory method which creates timezone instances from one of the supported keys. #### Parameters * ##### tzCode: string #### Returns TimeZone `dh.i18n.TimeZone` ### Settings #### Member Visibility * Protected * Private * Inherited * External #### Theme OSLightDark ### On This Page * constructor * id * standardOffset * getTimeZone ``` -------------------------------- ### Widget Class Methods Source: https://docs.deephaven.io/core/client-api/javascript/classes/dh This snippet outlines the public methods available on the Widget class. These methods allow clients to interact with the server-side widget, such as adding event listeners, closing the connection, retrieving data, and sending messages. ```javascript addEventListener(type: "close" | "message", listener: () => void): void close(): void getDataAsBase64(): Promise getDataAsString(): Promise getDataAsU8(): Promise hasListeners(type: "close" | "message"): boolean nextEvent(): Promise removeEventListener(type: "close" | "message", listener: () => void): void sendMessage(payload: any): Promise ``` -------------------------------- ### DayOfWeek Class Source: https://docs.deephaven.io/core/client-api/javascript/classes/dh.calendar Details about the DayOfWeek class, its properties, and methods. ```APIDOC ## DayOfWeek Class ### Description The DayOfWeek class represents the days of the week, providing static properties for each day and a method to retrieve all day names. ### Properties * **FRIDAY** (string) - Represents Friday. * **MONDAY** (string) - Represents Monday. * **SATURDAY** (string) - Represents Saturday. * **SUNDAY** (string) - Represents Sunday. * **THURSDAY** (string) - Represents Thursday. * **TUESDAY** (string) - Represents Tuesday. * **WEDNESDAY** (string) - Represents Wednesday. ### Methods * **values()**: string[] - Returns an array of all day names. ### Constructor * **new DayOfWeek()**: DayOfWeek - Initializes a new instance of the DayOfWeek class. ``` -------------------------------- ### Event Handling Methods Source: https://docs.deephaven.io/core/client-api/javascript/classes/dh Methods for adding, removing, and checking event listeners, as well as retrieving the next event. ```APIDOC ## Event Handling Methods ### addEventListener - **Description**: Listens for events on this object. - **Method**: POST (or similar, depending on underlying implementation) - **Endpoint**: N/A (Method call) - **Type Parameters**: T - the type of the data that the event will provide - **Parameters**: - **name** (string) - Required - The name of the event to listen for. - **callback** ((e) => void) - Required - A function to call when the event occurs. The event parameter `e` is of type `Event`. - **Returns**: (() => void) - Returns a cleanup function. ``` ```APIDOC ### removeEventListener - **Description**: Removes an event listener added to this table. - **Method**: DELETE (or similar, depending on underlying implementation) - **Endpoint**: N/A (Method call) - **Type Parameters**: T - the type of the data that the event will provide - **Parameters**: - **name** (string) - Required - The name of the event to remove. - **callback** ((e) => void) - Required - The callback function to remove. The event parameter `e` is of type `Event`. - **Returns**: boolean - True if the listener was removed, false otherwise. ``` ```APIDOC ### hasListeners - **Description**: Checks if there are any listeners for a specific event name. - **Method**: GET (or similar, depending on underlying implementation) - **Endpoint**: N/A (Method call) - **Parameters**: - **name** (string) - Required - The name of the event to check for listeners. - **Returns**: boolean - True if there are listeners, false otherwise. ``` ```APIDOC ### nextEvent - **Description**: Asynchronously waits for the next event of a specified name. - **Method**: POST (or similar, depending on underlying implementation) - **Endpoint**: N/A (Method call) - **Type Parameters**: T - the type of the data that the event will provide - **Parameters**: - **eventName** (string) - Required - The name of the event to wait for. - **timeoutInMillis** (number) - Optional - The timeout in milliseconds. If not provided, it waits indefinitely. - **Returns**: Promise> - A promise that resolves with the `Event` object when the event occurs or the timeout is reached. ``` -------------------------------- ### SignatureInformation Properties (JavaScript) Source: https://docs.deephaven.io/core/client-api/javascript/classes/dh.lsp Illustrates the properties available on a SignatureInformation object, including activeParameter, documentation, label, and parameters. These properties hold details about a function signature. ```javascript activeParameter: number documentation: MarkupContent label: string parameters: ParameterInformation[] ``` -------------------------------- ### Class SourceType Source: https://docs.deephaven.io/core/client-api/javascript/classes/dh.plot Documentation for the SourceType class, which represents different types of data sources and their associated properties. ```APIDOC ## Class SourceType ### Description The `SourceType` class provides constants representing various data source properties, commonly used in charting or data visualization contexts. ### Hierarchy `SourceType` ### Constructors #### constructor ```typescript new SourceType(): SourceType ``` **Returns**: `SourceType` - An instance of the SourceType class. ### Properties All properties are static and readonly. - **CLOSE** (number) - Represents the closing price data. - **COLOR** (number) - Represents the color property. - **HIGH** (number) - Represents the high price data. - **HOVER_TEXT** (number) - Represents the hover text property. - **LABEL** (number) - Represents the label property. - **LOW** (number) - Represents the low price data. - **OPEN** (number) - Represents the opening price data. - **PARENT** (number) - Represents the parent element or container. - **SHAPE** (number) - Represents the shape property. - **SIZE** (number) - Represents the size property. - **TEXT** (number) - Represents the text content. - **TIME** (number) - Represents the time data. - **X** (number) - Represents the X-coordinate. - **X_HIGH** (number) - Represents the upper bound of the X-coordinate. - **X_LOW** (number) - Represents the lower bound of the X-coordinate. - **Y** (number) - Represents the Y-coordinate. - **Y_HIGH** (number) - Represents the upper bound of the Y-coordinate. - **Y_LOW** (number) - Represents the lower bound of the Y-coordinate. - **Z** (number) - Represents the Z-coordinate (depth). ### Settings #### Member Visibility - Protected - Private - Inherited - External #### Theme - OSLightDark ### On This Page - constructor - CLOSE - COLOR - HIGH - HOVER_TEXT - LABEL - LOW - OPEN - PARENT - SHAPE - SIZE - TEXT - TIME - X - X_HIGH - X_LOW - Y - Y_HIGH - Y_LOW - Z ``` -------------------------------- ### CommandResult Interface Source: https://docs.deephaven.io/core/client-api/javascript/interfaces/dh.ide Provides information about the result of code execution on the Deephaven server, including any changes made or errors encountered. ```APIDOC ## Interface CommandResult Indicates the result of code run on the server. ### Hierarchy * CommandResult ### Accessors #### changes * **get changes()**: VariableChanges * Describes changes made in the course of this command. * **Returns**: VariableChanges #### error * **get error()**: string * If the command failed, the error message will be provided here. * **Returns**: string ### Settings #### Member Visibility * Protected * Private * Inherited * External #### Theme OSLightDark ``` -------------------------------- ### Series Interface Methods (TypeScript) Source: https://docs.deephaven.io/core/client-api/javascript/interfaces/dh.plot This snippet details the methods available on the Series interface in TypeScript, part of the @deephaven/jsapi-types library. It includes the `subscribe` method for enabling data updates, optionally disabling downsampling, and the `unsubscribe` method to disable these updates. These methods are crucial for real-time data handling in charts. ```typescript interface Series { subscribe(forceDisableDownsample?: DownsampleOptions): void; unsubscribe(): void; } ``` -------------------------------- ### JavaScript: Send Message to Server Source: https://docs.deephaven.io/core/client-api/javascript/classes/dh Sends a message, which can be a string or binary data, to the Deephaven server. Optionally, references to existing server-side objects can be included. The `msg` parameter can be a string, ArrayBuffer, or ArrayBufferView. ```javascript const messageToSend = "Hello Server!"; myWidget.sendMessage(messageToSend); const bufferToSend = new Uint8Array([1, 2, 3]); myWidget.sendMessage(bufferToSend); ``` -------------------------------- ### Create TimeZone Instance using Factory Method Source: https://docs.deephaven.io/core/client-api/javascript/classes/dh.i18n Demonstrates how to create a TimeZone object using the static `getTimeZone` factory method. This method accepts a timezone code or abbreviation and returns a `TimeZone` instance. Ensure the `dh.i18n.TimeZone` module is accessible. ```javascript import * as dh from "@deephaven/jsapi-types"; // Example using a timezone code const nyTimeZone = dh.i18n.TimeZone.getTimeZone("America/New_York"); console.log(nyTimeZone.id); // Output: America/New_York // Example using a timezone abbreviation const utcTimeZone = dh.i18n.TimeZone.getTimeZone("UTC"); console.log(utcTimeZone.id); // Output: UTC // Example of accessing properties console.log(nyTimeZone.standardOffset); // Output: -300 (example value, depends on DST) ``` -------------------------------- ### JavaScript Iterator Interface Documentation Source: https://docs.deephaven.io/core/client-api/javascript/interfaces/Iterator Documentation for the standard JavaScript Iterator interface, which is part of EcmaScript 2015. It defines a single `next()` method that returns an object with `done` and `value` properties. ```javascript interface Iterator { next(): IIterableResult; } interface IIterableResult { done: boolean; value?: T; } ``` -------------------------------- ### DayOfWeek Constructor - JavaScript Source: https://docs.deephaven.io/core/client-api/javascript/classes/dh.calendar This snippet illustrates the constructor for the DayOfWeek class. It is used to instantiate a DayOfWeek object, returning a DayOfWeek type. ```javascript class DayOfWeek { constructor(): DayOfWeek; } ``` -------------------------------- ### Widget Accessors Source: https://docs.deephaven.io/core/client-api/javascript/classes/dh Accessor properties for the Widget class. ```APIDOC ## Accessors ### `exportedObjects` * Get: Returns the exported objects associated with the widget. ### `type` * Get: Returns the type of the widget. ``` -------------------------------- ### JavaScript Iterator hasNext Method Source: https://docs.deephaven.io/core/client-api/javascript/interfaces/Iterator The `hasNext()` method of the Iterator interface returns a boolean indicating whether there are more items to iterate over. This is a common pattern for pre-checking iteration readiness. ```javascript /** * Checks if there are more elements in the iteration. * @returns {boolean} True if there are more elements, false otherwise. */ hasNext(): boolean; ``` -------------------------------- ### Series Interface Properties and Accessors (TypeScript) Source: https://docs.deephaven.io/core/client-api/javascript/interfaces/dh.plot This snippet shows the TypeScript definition for the Series interface, detailing its properties such as visibility flags, formatting options, and styling attributes. It also includes accessors for retrieving information like line color, series name, and plot style. This interface is part of the @deephaven/jsapi-types library. ```typescript interface Series { // Properties isLinesVisible?: boolean; isShapesVisible?: boolean; pointLabelFormat?: string; shapeSize?: number; xToolTipPattern?: string; yToolTipPattern?: string; // Accessors readonly gradientVisible: boolean; readonly lineColor: string; readonly multiSeries: MultiSeries | null; readonly name: string; readonly oneClick: OneClick; readonly plotStyle: number; readonly shape: string; readonly shapeColor: string; readonly shapeLabel: string; readonly sources: SeriesDataSource[]; } ``` -------------------------------- ### WidgetExportedObject Properties Source: https://docs.deephaven.io/core/client-api/javascript/classes/dh Provides information about exported objects and the type of the widget. ```APIDOC ## WidgetExportedObject Properties ### exportedObjects - **Description**: Retrieves the exported objects sent in the initial message from the server. The client is responsible for closing them when finished using them. - **Method**: GET - **Endpoint**: N/A (Property access) - **Returns**: WidgetExportedObject[] ### type - **Description**: Retrieves the type of this widget. - **Method**: GET - **Endpoint**: N/A (Property access) - **Returns**: string ``` -------------------------------- ### Widget Class Properties and Events Source: https://docs.deephaven.io/core/client-api/javascript/classes/dh This snippet shows the static read-only properties EVENT_CLOSE and EVENT_MESSAGE available on the Widget class. These events are used for handling connection closure and incoming messages, respectively. ```javascript EVENT_CLOSE: string EVENT_MESSAGE: string ``` -------------------------------- ### Series Interface Source: https://docs.deephaven.io/core/client-api/javascript/interfaces/dh.plot Provides access to the data for displaying in a figure. Includes properties, accessors, and methods for managing plot series. ```APIDOC ## Interface Series Provides access to the data for displaying in a figure. ### Hierarchy * Series ### Properties - **isLinesVisible** (boolean) - Optional, Readonly - Indicates if lines are visible for the series. - **isShapesVisible** (boolean) - Optional, Readonly - Indicates if shapes are visible for the series. - **pointLabelFormat** (string) - Optional, Readonly - The format for point labels. - **shapeSize** (number) - Optional, Readonly - The size of the shapes used in the series. - **xToolTipPattern** (string) - Optional, Readonly - The tooltip pattern for the x-axis. - **yToolTipPattern** (string) - Optional, Readonly - The tooltip pattern for the y-axis. ### Accessors - **gradientVisible** - Returns `boolean` - Indicates if the gradient is visible. - **lineColor** - Returns `string` - The color of the line used in the series. - **multiSeries** - Returns `dh.plot.MultiSeries` - Indicates if this series belongs to a MultiSeries, null otherwise. - **name** - Returns `string` - The name for this series. - **oneClick** - Returns `OneClick` -. - **plotStyle** - Returns `number` - The plotting style to use for this series. See **SeriesPlotStyle** enum for more details. - **shape** - Returns `string` -. - **shapeColor** - Returns `string` -. - **shapeLabel** - Returns `string` -. - **sources** - Returns `SeriesDataSource[]` - Contains details on how to access data within the chart for this series. Keyed with the way that this series uses the axis. ### Methods - **subscribe** - `subscribe(forceDisableDownsample?: DownsampleOptions): void` - Enables updates for this Series. Optionally disable downsampling. - **unsubscribe** - `unsubscribe(): void` - Disables updates for this Series. ### Settings - **Member Visibility**: Protected, Private, Inherited, External - **Theme**: OSLightDark ``` -------------------------------- ### JavaScript: Wait for Next Event Source: https://docs.deephaven.io/core/client-api/javascript/classes/dh Asynchronously waits for the next occurrence of a specified event on the widget. Supports an optional timeout in milliseconds. Returns a Promise that resolves with the event data. ```javascript async function waitForData() { try { const eventData = await myWidget.nextEvent("dataUpdate", 5000); console.log("Received data update:", eventData); } catch (error) { console.error("Waiting for event timed out or failed:", error); } } ``` -------------------------------- ### DayOfWeek Class Properties - JavaScript Source: https://docs.deephaven.io/core/client-api/javascript/classes/dh.calendar This snippet demonstrates the static, read-only properties representing each day of the week within the DayOfWeek class. These properties are defined as strings. ```javascript class DayOfWeek { static FRIDAY: string; static MONDAY: string; static SATURDAY: string; static SUNDAY: string; static THURSDAY: string; static TUESDAY: string; static WEDNESDAY: string; } ``` -------------------------------- ### JavaScript Iterator next Method Source: https://docs.deephaven.io/core/client-api/javascript/interfaces/Iterator The `next()` method of the Iterator interface returns the next element in the iteration. It returns an object with a `done` property indicating completion and an optional `value` property containing the next item. ```javascript /** * Returns the next element in the iteration. * @returns {IIterableResult} An object with 'done' and optional 'value' properties. */ next(): IIterableResult; ``` -------------------------------- ### JavaScript: Add Event Listener to Widget Source: https://docs.deephaven.io/core/client-api/javascript/classes/dh Adds an event listener to a widget to react to specific events. It supports generic event types and returns a cleanup function to remove the listener. Ensure the callback function is correctly typed to handle the event data. ```javascript widget.addEventListener("customEvent", (e: MyEventType) => { console.log("Custom event received:", e); }); ``` -------------------------------- ### DayOfWeek Class Methods - JavaScript Source: https://docs.deephaven.io/core/client-api/javascript/classes/dh.calendar This snippet shows the static 'values' method of the DayOfWeek class. This method returns an array of strings, where each string is the name of a day of the week. ```javascript class DayOfWeek { static values(): string[]; } ``` -------------------------------- ### Access Worker Heap Memory Information (TypeScript) Source: https://docs.deephaven.io/core/client-api/javascript/interfaces/dh Demonstrates how to access heap memory information from a WorkerHeapInfo object. This interface provides read-only access to the free memory, maximum heap size, and total heap size available to a worker. ```typescript interface WorkerHeapInfo { /** * Gets the amount of free memory in the worker's heap. * @returns The free memory in bytes. */ get freeMemory(): number; /** * Gets the maximum heap size allowed for the worker. * @returns The maximum heap size in bytes. */ get maximumHeapSize(): number; /** * Gets the total heap size currently used by the worker. * @returns The total heap size in bytes. */ get totalHeapSize(): number; } ``` -------------------------------- ### Access TimeZone Properties Source: https://docs.deephaven.io/core/client-api/javascript/classes/dh.i18n Shows how to access the `id` and `standardOffset` properties of a `TimeZone` object. The `id` property returns the timezone's identifier, and `standardOffset` returns the standard offset in minutes from UTC. These properties are useful for understanding the timezone's configuration. ```javascript import * as dh from "@deephaven/jsapi-types"; const londonTimeZone = dh.i18n.TimeZone.getTimeZone("Europe/London"); // Get the timezone identifier const timeZoneId = londonTimeZone.id; console.log(`Timezone ID: ${timeZoneId}`); // Example Output: Timezone ID: Europe/London // Get the standard offset in minutes const standardOffsetMinutes = londonTimeZone.standardOffset; console.log(`Standard Offset (minutes): ${standardOffsetMinutes}`); // Example Output: Standard Offset (minutes): 0 (for GMT) ``` -------------------------------- ### JavaScript: Close Widget Connection Source: https://docs.deephaven.io/core/client-api/javascript/classes/dh Closes the client connection to the Deephaven server for a specific widget. This method should be called when the widget is no longer needed to free up server resources. ```javascript myWidget.close(); ``` -------------------------------- ### JavaScript: Check for Event Listeners Source: https://docs.deephaven.io/core/client-api/javascript/classes/dh Checks if a specific event listener is currently attached to the widget. This can be used to determine if an event will be handled before attempting to trigger it. ```javascript const hasCustomListener = myWidget.hasListeners("customEvent"); ``` -------------------------------- ### JavaScript: Remove Event Listener from Widget Source: https://docs.deephaven.io/core/client-api/javascript/classes/dh Removes a previously added event listener from the widget. Returns a boolean indicating whether the listener was successfully removed. Ensure the callback function matches the one provided during `addEventListener`. ```javascript const myCallback = (e) => { console.log(e); }; myWidget.addEventListener("someEvent", myCallback); // Later... const removed = myWidget.removeEventListener("someEvent", myCallback); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.