@jigonzalez930209/scichart-engine 0.1.0 → 0.2.0

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.
@@ -0,0 +1,18 @@
1
+ import { Series } from '../Series';
2
+ import { Bounds } from '../../types';
3
+ import { ExportOptions } from './types';
4
+
5
+ /**
6
+ * Export series data to CSV format
7
+ */
8
+ export declare function exportToCSV(series: Series[], options?: ExportOptions): string;
9
+ /**
10
+ * Export series data to JSON format
11
+ */
12
+ export declare function exportToJSON(series: Series[], viewBounds: Bounds, options?: ExportOptions): string;
13
+ /**
14
+ * Export chart to image
15
+ */
16
+ export declare function exportToImage(webglCanvas: HTMLCanvasElement, overlayCanvas: HTMLCanvasElement, backgroundColor: [number, number, number, number], legend: {
17
+ draw: (ctx: CanvasRenderingContext2D, dpr: number) => void;
18
+ } | null, showLegend: boolean, dpr: number, type?: "png" | "jpeg"): string;
@@ -0,0 +1,55 @@
1
+ import { Bounds, ZoomOptions, AxisOptions, ChartEventMap } from '../../types';
2
+ import { Scale } from '../../scales';
3
+ import { EventEmitter } from '../EventEmitter';
4
+
5
+ export interface NavigationContext {
6
+ viewBounds: Bounds;
7
+ yScales: Map<string, Scale>;
8
+ yAxisOptionsMap: Map<string, AxisOptions>;
9
+ xAxisOptions: AxisOptions;
10
+ primaryYAxisId: string;
11
+ getPlotArea: () => {
12
+ x: number;
13
+ y: number;
14
+ width: number;
15
+ height: number;
16
+ };
17
+ events: EventEmitter<ChartEventMap>;
18
+ requestRender: () => void;
19
+ series: Map<string, {
20
+ isVisible(): boolean;
21
+ getBounds(): Bounds | null;
22
+ getYAxisId(): string | undefined;
23
+ }>;
24
+ }
25
+ /**
26
+ * Apply zoom to the chart
27
+ */
28
+ export declare function applyZoom(ctx: NavigationContext, options: ZoomOptions): void;
29
+ /**
30
+ * Apply pan to the chart
31
+ */
32
+ export declare function applyPan(ctx: NavigationContext, deltaX: number, deltaY: number, axisId?: string): void;
33
+ /**
34
+ * Auto-scale all axes to fit data
35
+ */
36
+ export declare function autoScaleAll(ctx: NavigationContext): void;
37
+ /**
38
+ * Handle box zoom selection
39
+ */
40
+ export declare function handleBoxZoom(ctx: NavigationContext, selectionRect: {
41
+ x: number;
42
+ y: number;
43
+ width: number;
44
+ height: number;
45
+ } | null, currentRect: {
46
+ x: number;
47
+ y: number;
48
+ width: number;
49
+ height: number;
50
+ } | null, zoom: (options: ZoomOptions) => void): {
51
+ x: number;
52
+ y: number;
53
+ width: number;
54
+ height: number;
55
+ } | null;
@@ -0,0 +1,67 @@
1
+ import { Bounds, CursorOptions, AxisOptions, ChartEventMap } from '../../types';
2
+ import { Series } from '../Series';
3
+ import { Scale } from '../../scales';
4
+ import { NativeWebGLRenderer, NativeSeriesRenderData as SeriesRenderData } from '../../renderer/NativeWebGLRenderer';
5
+ import { OverlayRenderer } from '../OverlayRenderer';
6
+ import { AnnotationManager } from '../annotations';
7
+ import { ChartStatistics } from '../ChartStatistics';
8
+ import { EventEmitter } from '../EventEmitter';
9
+
10
+ export interface RenderContext {
11
+ webglCanvas: HTMLCanvasElement;
12
+ overlayCanvas: HTMLCanvasElement;
13
+ overlayCtx: CanvasRenderingContext2D;
14
+ container: HTMLDivElement;
15
+ series: Map<string, Series>;
16
+ viewBounds: Bounds;
17
+ xScale: Scale;
18
+ yScales: Map<string, Scale>;
19
+ yAxisOptionsMap: Map<string, AxisOptions>;
20
+ xAxisOptions: AxisOptions;
21
+ primaryYAxisId: string;
22
+ renderer: NativeWebGLRenderer;
23
+ overlay: OverlayRenderer;
24
+ annotationManager: AnnotationManager;
25
+ backgroundColor: [number, number, number, number];
26
+ cursorOptions: CursorOptions | null;
27
+ cursorPosition: {
28
+ x: number;
29
+ y: number;
30
+ } | null;
31
+ selectionRect: {
32
+ x: number;
33
+ y: number;
34
+ width: number;
35
+ height: number;
36
+ } | null;
37
+ stats: ChartStatistics | null;
38
+ showStatistics: boolean;
39
+ events: EventEmitter<ChartEventMap>;
40
+ updateSeriesBuffer: (s: Series) => void;
41
+ getPlotArea: () => {
42
+ x: number;
43
+ y: number;
44
+ width: number;
45
+ height: number;
46
+ };
47
+ pixelToDataX: (px: number) => number;
48
+ pixelToDataY: (py: number) => number;
49
+ }
50
+ /**
51
+ * Prepare series data for WebGL rendering
52
+ */
53
+ export declare function prepareSeriesData(ctx: RenderContext, plotArea: {
54
+ x: number;
55
+ y: number;
56
+ width: number;
57
+ height: number;
58
+ }): SeriesRenderData[];
59
+ /**
60
+ * Render overlay elements (axes, grid, annotations, etc.)
61
+ */
62
+ export declare function renderOverlay(ctx: RenderContext, plotArea: {
63
+ x: number;
64
+ y: number;
65
+ width: number;
66
+ height: number;
67
+ }, primaryYScale: Scale): void;
@@ -0,0 +1,52 @@
1
+ import { SeriesOptions, SeriesUpdateData, Bounds } from '../../types';
2
+ import { Series } from '../Series';
3
+ import { FitType, FitOptions } from '../../analysis';
4
+ import { NativeWebGLRenderer } from '../../renderer/NativeWebGLRenderer';
5
+ import { Annotation } from '../annotations';
6
+
7
+ export interface SeriesManagerContext {
8
+ series: Map<string, Series>;
9
+ renderer: NativeWebGLRenderer;
10
+ viewBounds: Bounds;
11
+ autoScale: () => void;
12
+ requestRender: () => void;
13
+ addAnnotation: (annotation: Annotation) => string;
14
+ xAxisOptions: {
15
+ auto?: boolean;
16
+ };
17
+ yAxisOptionsMap: Map<string, {
18
+ auto?: boolean;
19
+ }>;
20
+ autoScrollEnabled: boolean;
21
+ updateLegend?: () => void;
22
+ }
23
+ /**
24
+ * Add a new series to the chart
25
+ */
26
+ export declare function addSeries(ctx: SeriesManagerContext, options: SeriesOptions): void;
27
+ /**
28
+ * Remove a series from the chart
29
+ */
30
+ export declare function removeSeries(ctx: SeriesManagerContext, id: string): void;
31
+ /**
32
+ * Update series data
33
+ */
34
+ export declare function updateSeries(ctx: SeriesManagerContext, id: string, data: SeriesUpdateData): void;
35
+ /**
36
+ * Update series buffer for rendering
37
+ */
38
+ export declare function updateSeriesBuffer(ctx: SeriesManagerContext, s: Series): void;
39
+ /**
40
+ * Append data to existing series
41
+ */
42
+ export declare function appendData(ctx: SeriesManagerContext, id: string, x: number[] | Float32Array, y: number[] | Float32Array): void;
43
+ /**
44
+ * Set max points for rolling window
45
+ */
46
+ export declare function setMaxPoints(ctx: SeriesManagerContext, id: string, maxPoints: number): void;
47
+ /**
48
+ * Add a fit line (regression) to an existing series
49
+ */
50
+ export declare function addFitLine(ctx: SeriesManagerContext & {
51
+ addSeries: (o: SeriesOptions) => void;
52
+ }, seriesId: string, type: FitType, options?: FitOptions): string;
@@ -0,0 +1,50 @@
1
+ import { ChartOptions, AxisOptions } from '../../types';
2
+ import { Scale } from '../../scales';
3
+ import { ChartTheme } from '../../theme';
4
+
5
+ export interface SetupResult {
6
+ theme: ChartTheme;
7
+ backgroundColor: [number, number, number, number];
8
+ showLegend: boolean;
9
+ showControls: boolean;
10
+ autoScroll: boolean;
11
+ showStatistics: boolean;
12
+ dpr: number;
13
+ xAxisOptions: AxisOptions;
14
+ xScale: Scale;
15
+ yAxisOptionsMap: Map<string, AxisOptions>;
16
+ yScales: Map<string, Scale>;
17
+ primaryYAxisId: string;
18
+ webglCanvas: HTMLCanvasElement;
19
+ overlayCanvas: HTMLCanvasElement;
20
+ overlayCtx: CanvasRenderingContext2D;
21
+ }
22
+ /**
23
+ * Initialize chart configuration from options
24
+ */
25
+ export declare function initializeChart(container: HTMLDivElement, options: ChartOptions): SetupResult;
26
+ /**
27
+ * Create a canvas element
28
+ */
29
+ export declare function createCanvas(type: "webgl" | "overlay"): HTMLCanvasElement;
30
+ /**
31
+ * Calculate the plot area based on container size and margins
32
+ */
33
+ export declare function getPlotArea(container: HTMLDivElement, yAxisOptionsMap: Map<string, AxisOptions>): {
34
+ x: number;
35
+ y: number;
36
+ width: number;
37
+ height: number;
38
+ };
39
+ /**
40
+ * Get axes layout for interaction manager
41
+ */
42
+ export declare function getAxesLayout(yAxisOptionsMap: Map<string, AxisOptions>): Array<{
43
+ id: string;
44
+ position: 'left' | 'right';
45
+ offset: number;
46
+ }>;
47
+ /**
48
+ * Resize canvases to match container
49
+ */
50
+ export declare function resizeCanvases(container: HTMLDivElement, webglCanvas: HTMLCanvasElement, overlayCanvas: HTMLCanvasElement, overlayCtx: CanvasRenderingContext2D, dpr: number): boolean;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Chart barrel export
3
+ *
4
+ * Re-exports all chart submodules for clean imports.
5
+ */
6
+ export type { Chart, ExportOptions } from './types';
7
+ export { MARGINS } from './types';
8
+ export { exportToCSV, exportToJSON, exportToImage } from './ChartExporter';
9
+ export { applyZoom, applyPan, autoScaleAll, handleBoxZoom } from './ChartNavigation';
10
+ export type { NavigationContext } from './ChartNavigation';
11
+ export { prepareSeriesData, renderOverlay } from './ChartRenderer';
12
+ export type { RenderContext } from './ChartRenderer';
13
+ export { ChartImpl, createChart } from './ChartCore';
@@ -0,0 +1,58 @@
1
+ import { SeriesOptions, SeriesUpdateData, ZoomOptions, CursorOptions, ChartEventMap, Bounds } from '../../types';
2
+ import { Series } from '../Series';
3
+ import { FitType, FitOptions } from '../../analysis';
4
+ import { Annotation } from '../annotations';
5
+
6
+ import * as analysis from "../../analysis";
7
+ export interface Chart {
8
+ addSeries(options: SeriesOptions): void;
9
+ removeSeries(id: string): void;
10
+ updateSeries(id: string, data: SeriesUpdateData): void;
11
+ getSeries(id: string): Series | undefined;
12
+ getAllSeries(): Series[];
13
+ appendData(id: string, x: number[] | Float32Array, y: number[] | Float32Array): void;
14
+ setAutoScroll(enabled: boolean): void;
15
+ setMaxPoints(id: string, maxPoints: number): void;
16
+ addFitLine(seriesId: string, type: FitType, options?: FitOptions): string;
17
+ zoom(options: ZoomOptions): void;
18
+ pan(deltaX: number, deltaY: number): void;
19
+ resetZoom(): void;
20
+ getViewBounds(): Bounds;
21
+ enableCursor(options: CursorOptions): void;
22
+ disableCursor(): void;
23
+ resize(width?: number, height?: number): void;
24
+ render(): void;
25
+ on<K extends keyof ChartEventMap>(event: K, handler: (data: ChartEventMap[K]) => void): void;
26
+ off<K extends keyof ChartEventMap>(event: K, handler: (data: ChartEventMap[K]) => void): void;
27
+ destroy(): void;
28
+ exportImage(type?: "png" | "jpeg"): string;
29
+ autoScale(): void;
30
+ setTheme(theme: string | object): void;
31
+ /** Access to data analysis utilities */
32
+ readonly analysis: typeof analysis;
33
+ addAnnotation(annotation: Annotation): string;
34
+ removeAnnotation(id: string): boolean;
35
+ updateAnnotation(id: string, updates: Partial<Annotation>): void;
36
+ getAnnotation(id: string): Annotation | undefined;
37
+ getAnnotations(): Annotation[];
38
+ clearAnnotations(): void;
39
+ exportCSV(options?: ExportOptions): string;
40
+ exportJSON(options?: ExportOptions): string;
41
+ }
42
+ /** Options for data export */
43
+ export interface ExportOptions {
44
+ /** Series IDs to export (default: all) */
45
+ seriesIds?: string[];
46
+ /** Include headers in CSV (default: true) */
47
+ includeHeaders?: boolean;
48
+ /** Decimal precision (default: 6) */
49
+ precision?: number;
50
+ /** CSV delimiter (default: ',') */
51
+ delimiter?: string;
52
+ }
53
+ export declare const MARGINS: {
54
+ top: number;
55
+ right: number;
56
+ bottom: number;
57
+ left: number;
58
+ };
@@ -1,8 +1,9 @@
1
1
  /**
2
2
  * Core module exports
3
3
  */
4
- export { createChart, type Chart, type ChartOptions } from './Chart';
4
+ export { createChart, type Chart, type ChartOptions, type ExportOptions } from './Chart';
5
5
  export { Series } from './Series';
6
6
  export { EventEmitter } from './EventEmitter';
7
7
  export { OverlayRenderer, type PlotArea, type CursorState } from './OverlayRenderer';
8
8
  export { InteractionManager } from './InteractionManager';
9
+ export * from './annotations';
package/dist/index.d.ts CHANGED
@@ -15,8 +15,10 @@
15
15
  export { createChart } from './core/Chart';
16
16
  export { Series } from './core/Series';
17
17
  export { EventEmitter } from './core/EventEmitter';
18
- export type { Chart, ChartOptions } from './core/Chart';
19
- export type { AxisOptions, SeriesOptions, SeriesData, SeriesStyle, SeriesUpdateData, ZoomOptions, CursorOptions, ChartEventMap, Point, Bounds, Range, ScaleType, SeriesType, } from './types';
18
+ export type { Chart, ChartOptions, ExportOptions } from './core/Chart';
19
+ export { AnnotationManager } from './core/annotations';
20
+ export type { Annotation, AnnotationType, HorizontalLineAnnotation, VerticalLineAnnotation, RectangleAnnotation, BandAnnotation, TextAnnotation, ArrowAnnotation, } from './core/annotations';
21
+ export type { AxisOptions, SeriesOptions, SeriesData, SeriesStyle, SeriesUpdateData, ZoomOptions, CursorOptions, ChartEventMap, Point, Bounds, Range, ScaleType, SeriesType, StepMode, ErrorBarStyle, ErrorBarDirection, ScatterSymbol, } from './types';
20
22
  export { LinearScale, LogScale, createScale, type Scale } from './scales';
21
23
  export { NativeWebGLRenderer, interleaveData, parseColor, createRenderer, createNativeRenderer, type IWebGLRenderer, type SeriesRenderData, type RenderOptions, } from './renderer';
22
24
  export { DARK_THEME, LIGHT_THEME, MIDNIGHT_THEME, ELECTROCHEM_THEME, DEFAULT_THEME, createTheme, getThemeByName, type ChartTheme, type GridTheme, type AxisTheme, type LegendTheme, type CursorTheme, } from './theme';
@@ -6,16 +6,31 @@ export interface NativeSeriesRenderData {
6
6
  count: number;
7
7
  style: SeriesStyle;
8
8
  visible: boolean;
9
- type: "line" | "scatter" | "line+scatter";
9
+ type: "line" | "scatter" | "line+scatter" | "step" | "step+scatter" | "band";
10
+ /** For step types: pre-computed step buffer */
11
+ stepBuffer?: WebGLBuffer;
12
+ stepCount?: number;
13
+ /** Optional specific Y-bounds for this series (overrides global bounds) */
14
+ yBounds?: {
15
+ min: number;
16
+ max: number;
17
+ };
10
18
  }
11
19
  export interface NativeRenderOptions {
12
20
  bounds: Bounds;
13
21
  backgroundColor?: [number, number, number, number];
22
+ plotArea?: {
23
+ x: number;
24
+ y: number;
25
+ width: number;
26
+ height: number;
27
+ };
14
28
  }
15
29
  export declare class NativeWebGLRenderer {
16
30
  private canvas;
17
31
  private gl;
18
32
  private dpr;
33
+ setDPR(dpr: number): void;
19
34
  private lineProgram;
20
35
  private pointProgram;
21
36
  private buffers;
@@ -29,6 +44,11 @@ export declare class NativeWebGLRenderer {
29
44
  * Create or update a buffer with interleaved X,Y data
30
45
  */
31
46
  createBuffer(id: string, data: Float32Array): void;
47
+ /**
48
+ * Update a portion of an existing buffer (compatible with WebGL 1.0)
49
+ * Returns true if successful, false if buffer needs recreation
50
+ */
51
+ updateBuffer(id: string, data: Float32Array, offsetInBytes: number): boolean;
32
52
  /**
33
53
  * Get a buffer by ID
34
54
  */
@@ -45,6 +65,7 @@ export declare class NativeWebGLRenderer {
45
65
  * Render a frame
46
66
  */
47
67
  render(series: NativeSeriesRenderData[], options: NativeRenderOptions): void;
68
+ private renderBand;
48
69
  private renderLine;
49
70
  private renderPoints;
50
71
  /**
@@ -67,3 +88,23 @@ export declare class NativeWebGLRenderer {
67
88
  }
68
89
  export declare function parseColor(color: string): [number, number, number, number];
69
90
  export declare function interleaveData(x: Float32Array | Float64Array | number[], y: Float32Array | Float64Array | number[]): Float32Array;
91
+ /**
92
+ * Create step chart vertices from X,Y data
93
+ *
94
+ * @param x X values
95
+ * @param y Y values
96
+ * @param mode Step mode: 'before', 'after', or 'center'
97
+ * @returns Interleaved Float32Array for step line rendering
98
+ *
99
+ * Step modes:
100
+ * - 'after': Step occurs after the point (horizontal then vertical)
101
+ * - 'before': Step occurs before the point (vertical then horizontal)
102
+ * - 'center': Step occurs at the midpoint between points
103
+ */
104
+ export declare function interleaveStepData(x: Float32Array | Float64Array | number[], y: Float32Array | Float64Array | number[], mode?: 'before' | 'after' | 'center'): Float32Array;
105
+ /**
106
+ * Interleaves data for band rendering
107
+ * Produces [x1, y1, x1, y2, x2, y1, x2, y2, ...]
108
+ * which is ready for gl.TRIANGLE_STRIP
109
+ */
110
+ export declare function interleaveBandData(x: Float32Array | Float64Array | number[], y1: Float32Array | Float64Array | number[], y2: Float32Array | Float64Array | number[]): Float32Array;